Class: SBConstants::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/sbconstants/cli.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
15
# File 'lib/sbconstants/cli.rb', line 11

def initialize options
  self.options     = options
  self.constants   = Hash.new { |h,k| h[k] = Set.new }
  self.storyboards = Array.new
end

Instance Attribute Details

#constantsObject

Returns the value of attribute constants.



5
6
7
# File 'lib/sbconstants/cli.rb', line 5

def constants
  @constants
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/sbconstants/cli.rb', line 5

def options
  @options
end

#sectionsObject

Returns the value of attribute sections.



5
6
7
# File 'lib/sbconstants/cli.rb', line 5

def sections
  @sections
end

#storyboardsObject

Returns the value of attribute storyboards.



5
6
7
# File 'lib/sbconstants/cli.rb', line 5

def storyboards
  @storyboards
end

Class Method Details

.run(argv) ⇒ Object



7
8
9
# File 'lib/sbconstants/cli.rb', line 7

def self.run argv
  new(Options.parse(argv)).run
end

Instance Method Details

#runObject



17
18
19
20
21
# File 'lib/sbconstants/cli.rb', line 17

def run
  parse_storyboards
  refute_key_collisions
  write
end

#sanitise_key(key) ⇒ Object



41
42
43
# File 'lib/sbconstants/cli.rb', line 41

def sanitise_key key
  key.gsub(" ", "").gsub("-", "")
end

#sections_grouped_by_keypathObject



33
34
35
36
37
38
39
# File 'lib/sbconstants/cli.rb', line 33

def sections_grouped_by_keypath
  Hash.new { |h,k| h[k] = Set.new }.tap { |sections_grouped_by_keypath|
    constants.each do |constant, locations|
      sections_grouped_by_keypath[locations] << constant
    end
  }
end