Module: SitemapMaker::Utils

Defined in:
lib/SitemapMaker/utils.rb

Constant Summary collapse

DEFAULT_LEVEL =
3

Class Method Summary collapse

Class Method Details

.get_bannerObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/SitemapMaker/utils.rb', line 48

def get_banner
  return <<-BANNAR
Usage:
alpacaComplete [OPTIONS]

etc..
sitemap_maker -l 3 -f data.csv -t http://dlab-inc.jp/
---------------------------------------------------------------------
  BANNAR
end

.option_parser(args) ⇒ Object



6
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/SitemapMaker/utils.rb', line 6

def option_parser args
  args << '-h' if args.empty?

  options = {}
  optparse = OptionParser.new do |opts|
    opts.banner  = get_banner.gsub(/^\s*/, '')

    opts.on('-h','--help','HELP') do
      puts opts
      exit
    end

    opts.on('-l', '--deep_level VAL', 'deep_level') do |l|
      options[:level] = l
      options[:level] ||= SitemapMaker::Utils::DEFAULT_LEVEL
    end

    opts.on('-f VAL', '--filepath VAL', 'output path') do |l|
      options[:path] = l
    end

    opts.on('-t VAL', '--target VAL', 'target url') do |l|
      options[:target] = l
    end

    opts.on('-v', '--version', 'Version') do
      puts SitemapMaker::VERSION
      exit
    end

  end

  optparse.parse! args
  options[:files]  = args.to_a

  {
    level:      options[:level],
    path:       options[:path],
    target:     options[:target],
  }
end

.run(cmd, path, uncomplete = "") ⇒ Object



59
60
61
62
63
64
# File 'lib/SitemapMaker/utils.rb', line 59

def run cmd, path, uncomplete=""
  case cmd
  when "locale"
    puts SitemapMaker::LocaleComplete.complete path, uncomplete
  end
end