Class: PhilColumns::Configuration
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- PhilColumns::Configuration
- Defined in:
- lib/phil_columns/configuration.rb
Constant Summary collapse
- TAG_REGEX =
/^~@?(\w+)$/
Instance Method Summary collapse
- #config_filepath ⇒ Object
-
#down ⇒ Object
Not sure why we need these explicit proxies.
- #dry_run ⇒ Object
- #exclusion_tags ⇒ Object
- #inclusion_tags ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #operation ⇒ Object
- #partitioned_tags ⇒ Object
- #save_to_file ⇒ Object
- #slice(*keys) ⇒ Object
- #tags ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 |
# File 'lib/phil_columns/configuration.rb', line 10 def initialize( ={} ) @_config = Hashie::Mash.new( read_config_file ). merge( ) super( _config ) end |
Instance Method Details
#config_filepath ⇒ Object
36 37 38 |
# File 'lib/phil_columns/configuration.rb', line 36 def config_filepath Pathname.new( '.phil_columns' ) end |
#down ⇒ Object
Not sure why we need these explicit proxies
41 |
# File 'lib/phil_columns/configuration.rb', line 41 def down; _config.down; end |
#dry_run ⇒ Object
42 |
# File 'lib/phil_columns/configuration.rb', line 42 def dry_run; _config.dry_run; end |
#exclusion_tags ⇒ Object
27 28 29 30 |
# File 'lib/phil_columns/configuration.rb', line 27 def .first. map { |tag| TAG_REGEX.match( tag )[1] } end |
#inclusion_tags ⇒ Object
32 33 34 |
# File 'lib/phil_columns/configuration.rb', line 32 def .last end |
#operation ⇒ Object
43 |
# File 'lib/phil_columns/configuration.rb', line 43 def operation; _config.operation; end |
#partitioned_tags ⇒ Object
23 24 25 |
# File 'lib/phil_columns/configuration.rb', line 23 def @partitioned_tags ||= .partition { |tag| TAG_REGEX.match( tag ) } end |
#save_to_file ⇒ Object
58 59 60 61 62 |
# File 'lib/phil_columns/configuration.rb', line 58 def save_to_file File.open( config_filepath, 'w' ) do |f| f.write( YAML::dump( config_as_hash )) end end |
#slice(*keys) ⇒ Object
54 55 56 |
# File 'lib/phil_columns/configuration.rb', line 54 def slice( *keys ) Hashie::Mash.new( _config.select { |k,v| keys.map( &:to_s ).include?( k.to_s ) } ) end |
#tags ⇒ Object
17 18 19 20 21 |
# File 'lib/phil_columns/configuration.rb', line 17 def (_config[:tags].nil? || _config[:tags].empty?) ? _config. : _config. end |
#version ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/phil_columns/configuration.rb', line 45 def version if _config.down && _config.version == 'all' '0' else _config.version end end |