Class: Rabbit::Console
- Inherits:
-
Object
- Object
- Rabbit::Console
- Includes:
- GetText
- Defined in:
- lib/rabbit/console.rb
Constant Summary collapse
- @@locale_dir_option_name =
"--locale-dir"
Constants included from GetText
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(logger = nil) ⇒ Console
constructor
A new instance of Console.
- #parse!(args) ⇒ Object
- #read_options_file(parser, options, options_file) ⇒ Object
Methods included from GetText
Constructor Details
Class Method Details
.get_last_name(klass) ⇒ Object
43 44 45 |
# File 'lib/rabbit/console.rb', line 43 def get_last_name(klass) klass.name.split("::").last end |
.parse!(args, logger = nil, &block) ⇒ Object
39 40 41 |
# File 'lib/rabbit/console.rb', line 39 def parse!(args, logger=nil, &block) new(logger).parse!(args, &block) end |
Instance Method Details
#parse!(args) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rabbit/console.rb', line 52 def parse!(args) = OpenStruct.new .logger = @logger .default_logger = @logger .druby_uri = "druby://127.0.0.1:10101" .version = VERSION . = nil .rest = [] .before_hooks = [] .after_hooks = [] (args) parser = OptionParser.new() do |_parser| yield(_parser, ) (_parser, ) end begin = . if and File.exist?() (parser, , ) end .before_hooks.each do |hook| hook.call(self, parser, ) end .rest.concat(parser.parse!(args)) .after_hooks.each do |hook| hook.call(self, parser, ) end rescue @logger.fatal($!.) end [, .logger] end |
#read_options_file(parser, options, options_file) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rabbit/console.rb', line 89 def (parser, , ) = [] File.open() do |file| file.each_line do |line| .concat(Shellwords.split(line)) end end source_info = parser.parse() source_info = source_info.collect do |path| if URI(path).scheme path else if Pathname(path).absolute? path else File.join(File.dirname(), path) end end end .rest.concat(source_info) end |