module OptparsePlus::ClassMethods
Public Instance Methods
new_with_yaml(config_yaml_source=nil) { |opt| ... }
click to toggle source
# File lib/optparse_plus.rb, line 18 def new_with_yaml(config_yaml_source=nil) cur_file = extract_cur_file_path(caller[0]) config_yaml_source ||= read_after_program_end(cur_file) opt = OptPlus.create_opt(config_yaml_source) if block_given? yield opt else opt end end
read_after_program_end(cur_file)
click to toggle source
# File lib/optparse_plus.rb, line 10 def read_after_program_end(cur_file) own_source = open(cur_file) {|f| f.read } last_token = Ripper.lex(own_source)[-1] return nil unless last_token[1] == :on___end__ start = last_token[0][0] own_source.lines[start..-1].join end
windows?()
click to toggle source
# File lib/optparse_plus.rb, line 30 def windows? /mswin(?!ce)|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM end
Private Instance Methods
extract_cur_file_path(caller_info)
click to toggle source
# File lib/optparse_plus.rb, line 36 def extract_cur_file_path(caller_info) if windows? and /\A[A-Z]:/i =~ caller_info caller_info.split(/:/, 3)[0, 2].join(':') else caller_info.split(/:/)[0] end end