Class: BiocGem::Command
- Inherits:
-
Object
- Object
- BiocGem::Command
- Defined in:
- lib/bioc_gem/command.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
- #run_new(options) ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ Command
Returns a new instance of Command.
10 11 12 13 |
# File 'lib/bioc_gem/command.rb', line 10 def initialize(argv = ARGV) @argv = argv.clone @parser = Parser.new end |
Instance Attribute Details
#parser ⇒ Object
Returns the value of attribute parser.
8 9 10 |
# File 'lib/bioc_gem/command.rb', line 8 def parser @parser end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/bioc_gem/command.rb', line 15 def run parser.parse!(@argv) command = parser.command = parser. public_send("run_#{command}", ) if [:new].include?(command) end |
#run_new(options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bioc_gem/command.rb', line 24 def run_new() config = parser. require_name = config.gem_require_name package_name = config.bioc_package_name output_directory = config.output_directory target = File.join(output_directory, package_name) base = File.("../../template/newgem", __dir__) Dir.mktmpdir do |tmpdir| Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |f| src = File.(f, base) next unless File.file?(src) str = File.read(src) erb = ERB.new(str) str = erb.result(binding) trg = File.(f, tmpdir) fname = File.basename(trg, ".tt") fname.gsub!("new_gem_entry", config.gem_require_name) dirname = File.dirname(trg) FileUtils.mkdir_p(dirname) File.write(File.join(dirname, fname), str) end FileUtils.cp_r(tmpdir, target) end warn "Created #{target}" end |