Gems, put an executable script in path? like rails?

A

Aaron Smith

Hey all, how do you put an executable in your path through gems.. like
when installing rails. you have a new command called "rails" what are
they doing to do that? - Thanks
 
A

Anthony Eden

When constructing your gem spec you need to include the bindir and the
executables array. For example, here is the relevant code from the
Rakefile for ActiveWarehouse ETL:

spec = Gem::Specification.new do |s|
#snip
s.bindir = "bin" # Use these for applications.
s.executables = ['etl']
s.default_executable = "etl"
# snip
end

This would cause the script bin/etl to appear as an executable script
on the system where the gem is installed. Inside my bin/etl script I
usually delegate to code that's actually in lib, however you may
implement as you see fit. HTH.

V/r
Anthony Eden
 
A

aaron smith

When constructing your gem spec you need to include the bindir and the
executables array. For example, here is the relevant code from the
Rakefile for ActiveWarehouse ETL:

spec = Gem::Specification.new do |s|
#snip
s.bindir = "bin" # Use these for applications.
s.executables = ['etl']
s.default_executable = "etl"
# snip
end

This would cause the script bin/etl to appear as an executable script
on the system where the gem is installed. Inside my bin/etl script I
usually delegate to code that's actually in lib, however you may
implement as you see fit. HTH.

V/r
Anthony Eden

Hey all, how do you put an executable in your path through gems.. like
when installing rails. you have a new command called "rails" what are
they doing to do that? - Thanks


Thanks that worked perfectly.
Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top