Module: AlpacaComplete::Utils
- Defined in:
- lib/AlpacaComplete/utils.rb
Class Method Summary collapse
-
.get_banner ⇒ Object
}}}.
-
.load_yaml(path) ⇒ Object
}}}.
-
.option_parser(args) ⇒ Object
{{{.
-
.run(cmd, path, uncomplete = "") ⇒ Object
}}}.
Class Method Details
.get_banner ⇒ Object
}}}
48 49 50 51 52 53 54 |
# File 'lib/AlpacaComplete/utils.rb', line 48 def # {{{ return <<-BANNAR.gsub(/^\s*/) Usage: alpacaComplete [OPTIONS] --------------------------------------------------------------------- BANNAR end |
.load_yaml(path) ⇒ Object
}}}
75 76 77 78 79 80 |
# File 'lib/AlpacaComplete/utils.rb', line 75 def load_yaml( path )# {{{ return nil until File.exist?(path) require 'yaml' ::YAML::load_file( path ) end |
.option_parser(args) ⇒ Object
{{{
7 8 9 10 11 12 13 14 15 16 17 18 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 |
# File 'lib/AlpacaComplete/utils.rb', line 7 def option_parser( args )# {{{ args << '-h' if args.empty? = {} optparse = OptionParser.new do |opts| opts. = opts.on('-h','--help','HELP') do puts opts exit end opts.on('-t CMD', '--type CMD', 'command type') do |l| [:command] = l.to_sym end opts.on('-w VAL', '--word VAL', 'uncomplete word') do |l| [:word] = l end opts.on('-f VAL', '--filepath VAL', 'rails path') do |l| [:path] = l end opts.on('-v', '--version', 'Version') do puts ::AlpacaComplete::VERSION exit end end optparse.parse! args [:files] = args.to_a { command: [:command], path: [:path], word: [:word], uncomplete: [:locale] } end |
.run(cmd, path, uncomplete = "") ⇒ Object
}}}
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/AlpacaComplete/utils.rb', line 56 def run( cmd, path, uncomplete="" )# {{{ case cmd when :locale # TODO :権限を委譲する locales = ::AlpacaComplete::LocaleComplete.complete( path, uncomplete ) locales.each do |k, v| puts ":key =>#{k} :value =>#{v}" end when :assets_image assets = ::AlpacaComplete::AssetsComplete.complete( path, uncomplete, :image ) assets.each { |file_path| puts file_path } # when :assets_stylesheets # when :assets_javascripts end end |