Class: BiocGem::Parser
- Inherits:
-
Object
- Object
- BiocGem::Parser
- Defined in:
- lib/bioc_gem/parser.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse!(args = ARGV) ⇒ Object
- #parse_options_new(args) ⇒ Object
Constructor Details
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/bioc_gem/parser.rb', line 6 def command @command end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/bioc_gem/parser.rb', line 6 def @options end |
Instance Method Details
#parse!(args = ARGV) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/bioc_gem/parser.rb', line 15 def parse!(args = ARGV) @command = args.shift&.to_sym if [:new].include?(command) public_send("parse_options_#{command}", args) else warn "Unknown command #{command}" nil end end |
#parse_options_new(args) ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bioc_gem/parser.rb', line 25 def (args) opt_parser = OptionParser.new do |parser| parser. = "Usage: biocgem new [options]" parser.on("-o", "--output [DIR]", "Output directory") do |dir| .output_directory = dir end parser.on("-n", "--bioc_package_name VAL", "e.g. org.Hs.eg.db") do |n| .bioc_package_name = n end parser.on("-s", "--bioc_sqlite_database_name VAL", "e.g. org.Hs.eg.sqlite") do |db| .bioc_sqlite_database_name = db end parser.on("--gem_icon [VAL]", "e.g. :family:") do |icon| .gem_icon = icon end parser.on("--gem_constant_name [VAL]", "e.g. OrgHsEgDb") do |c| .gem_constant_name = c end parser.on("--gem_require_name [VAL]", "e.g. org_hs_eg_db") do |rname| .gem_require_name = rname end parser.on("-m", "--bioc_package_md5sum [VAL]", "check md5sum") do |md5| .bioc_package_md5sum = md5 end parser.on("--bioc_package_sha256sum [VAL]", "check sha256sum") do |sha256| .bioc_package_sha256sum = sha256 end parser.on("--bioc_version [VAL]", "e.g. 3.14") do |bv| .bioc_version = bv end parser.on("-v", "--bioc_package_version VAL", "e.g. 3.14.0") do |v| .bioc_package_version = v end end opt_parser.parse!(args) .gem_icon ||= ":notes:" .gem_constant_name ||= \ .bioc_package_name .split(".").map(&:capitalize).join .gem_require_name.nil? .gem_require_name ||= \ .bioc_package_name .split(".").map(&:downcase).join("_") .bioc_version ||= "release" end |