Class: SchemaDev::Config
- Inherits:
-
Object
- Object
- SchemaDev::Config
- Defined in:
- lib/schema_dev/config.rb
Defined Under Namespace
Classes: Tuple
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#quick ⇒ Object
Returns the value of attribute quick.
Class Method Summary collapse
-
._reset ⇒ Object
for use by rspec.
- .load ⇒ Object
Instance Method Summary collapse
- #db? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Config
constructor
once we no longer support ruby 1.9.3, can switch to native keyword args.
-
#matrix(opts = {}) ⇒ Object
once we no longer support ruby 1.9.3, can switch to native keyword args.
Constructor Details
#initialize(opts = {}) ⇒ Config
once we no longer support ruby 1.9.3, can switch to native keyword args
40 41 42 43 44 45 46 47 48 |
# File 'lib/schema_dev/config.rb', line 40 def initialize(opts={}) # once we no longer support ruby 1.9.3, can switch to native keyword args opts = opts.keyword_args(ruby: :required, rails: :required, db: nil, exclude: nil, notify: nil, quick: nil) @ruby = Array.wrap(opts.ruby) @rails = Array.wrap(opts.rails) @db = Array.wrap(opts.db) @exclude = Array.wrap(opts.exclude).map(&:symbolize_keys).map {|tuple| Tuple.new(tuple)} @notify = Array.wrap(opts.notify) @quick = Array.wrap(opts.quick || {ruby: @ruby.last, rails: @rails.last, db: @db.andand.last}) end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
15 16 17 |
# File 'lib/schema_dev/config.rb', line 15 def db @db end |
#quick ⇒ Object
Returns the value of attribute quick.
15 16 17 |
# File 'lib/schema_dev/config.rb', line 15 def quick @quick end |
Class Method Details
._reset ⇒ Object
for use by rspec
17 |
# File 'lib/schema_dev/config.rb', line 17 def self._reset ; @@config = nil end |
.load ⇒ Object
19 20 21 |
# File 'lib/schema_dev/config.rb', line 19 def self.load @@config ||= new((YAML.load Pathname.new(CONFIG_FILE).read).symbolize_keys) end |
Instance Method Details
#db? ⇒ Boolean
50 51 52 |
# File 'lib/schema_dev/config.rb', line 50 def db? @db.any? end |
#matrix(opts = {}) ⇒ Object
once we no longer support ruby 1.9.3, can switch to native keyword args
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/schema_dev/config.rb', line 54 def matrix(opts={}) # once we no longer support ruby 1.9.3, can switch to native keyword args opts = opts.keyword_args(quick: false, ruby: nil, rails: nil, db: nil) use_ruby = @ruby use_rails = @rails use_db = @db if opts.quick use_ruby = @quick.map{|q| q[:ruby]} use_rails = @quick.map{|q| q[:rails]} use_db = @quick.map{|q| q[:db]} end use_ruby = Array.wrap(opts.ruby) if opts.ruby use_rails = Array.wrap(opts.rails) if opts.rails use_db = Array.wrap(opts.db) if opts.db @matrix ||= begin m = use_ruby.product(use_rails) m = m.product(use_db).map(&:flatten) if db? m = m.map { |_ruby, _rails, _db| Tuple.new(ruby: _ruby, rails: _rails, db: _db) } m.reject(&it.match_any?(@exclude)).map(&:to_hash) end end |