Class: SBConstants::Options
- Inherits:
-
Object
- Object
- SBConstants::Options
- Defined in:
- lib/sbconstants/options.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#query_config ⇒ Object
Returns the value of attribute query_config.
-
#query_file ⇒ Object
Returns the value of attribute query_file.
-
#source_dir ⇒ Object
Returns the value of attribute source_dir.
-
#templates_dir ⇒ Object
Returns the value of attribute templates_dir.
-
#use_swift ⇒ Object
Returns the value of attribute use_swift.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #queries ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
62 63 64 65 |
# File 'lib/sbconstants/options.rb', line 62 def initialize self.query_file = File.('../../sbconstants/identifiers.yml', __FILE__) self.source_dir = Dir.pwd end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def destination @destination end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def dry_run @dry_run end |
#output_path ⇒ Object
Returns the value of attribute output_path.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def output_path @output_path end |
#prefix ⇒ Object
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def prefix @prefix end |
#query_config ⇒ Object
Returns the value of attribute query_config.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def query_config @query_config end |
#query_file ⇒ Object
Returns the value of attribute query_file.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def query_file @query_file end |
#source_dir ⇒ Object
Returns the value of attribute source_dir.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def source_dir @source_dir end |
#templates_dir ⇒ Object
Returns the value of attribute templates_dir.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def templates_dir @templates_dir end |
#use_swift ⇒ Object
Returns the value of attribute use_swift.
6 7 8 |
# File 'lib/sbconstants/options.rb', line 6 def use_swift @use_swift end |
Class Method Details
.parse(argv) ⇒ Object
19 20 21 22 23 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 55 56 57 58 59 60 |
# File 'lib/sbconstants/options.rb', line 19 def self.parse argv = self.new OptionParser.new do |opts| opts. = "Usage: DESTINATION_FILE [options]" opts.on('-d', '--dry-run', 'Output to STDOUT') do |dry_run| .dry_run = dry_run end opts.on('-p', '--prefix=<prefix>', 'Only match identifiers with <prefix>') do |prefix| .prefix = prefix end opts.on('-s', '--source-dir=<source>', 'Directory containing storyboards') do |source_dir| .source_dir = source_dir end opts.on('-t', '--templates-dir=<templates>', 'Directory containing the templates to use for code formatting') do |templates_dir| .templates_dir = templates_dir end opts.on('-q', '--queries=<queries>', 'YAML file containing queries') do |queries| .query_file = queries end opts.on('-v', '--verbose', 'Verbose output') do |verbose| .verbose = verbose end opts.on('-w', '--swift', 'Output to a Swift File') do |use_swift| .use_swift = use_swift end end.parse!(argv) if argv.first.nil? .dry_run = true .output_path = 'no file given' else .output_path = argv.first.chomp(File.extname(ARGV.first)) end end |
Instance Method Details
#queries ⇒ Object
67 68 69 70 |
# File 'lib/sbconstants/options.rb', line 67 def queries load_queries if @queries.nil? @queries end |