watir_model 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2e75024846f7980a3bcefaefbcc5f9f1a4661e9
4
- data.tar.gz: 385e78e0816e7f276622c8cd2377f804e7bfef12
3
+ metadata.gz: 274dcadc9cddab4d7cacdd063b01a37327679463
4
+ data.tar.gz: 75988bb4db16b6908a81d763640ce34baa35989e
5
5
  SHA512:
6
- metadata.gz: fafe4c3d76271bf146a7a3826f4d8059a87e2032b2d1bd9e416e1d3f3c66c8c3620e0b2185eabb50eaf6742160ceb186b95658d27a3ece01d763df3dcd0202d3
7
- data.tar.gz: ad4cf6a0161fd9c0a8b81fe01ef1ac4a434ba50ccd76804c54db769641a7c347266b5be8901a359a4f8811443d1772e476ef990f26384fb78afae0e5c30a7e0a
6
+ metadata.gz: c1ad427cd4b8b9dcc630205b7ff80db52c1249bd8413c79173b629849b06d58616b8c745aaf067c36b50d0b78489d853a88745555f558fcaf9247002167f1069
7
+ data.tar.gz: cfca5bbf471cb2f19841dab263d8f42366991b7f01b5ccc93ac892debe1dd205b8da4f8dd9285628794da7610d1066a3cd9a9188f798e6ce5ff2d693344d3496
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.5.2 (2018-01-06)
2
+
3
+ * implement create method for ConfigModel to populate from yaml via ENV variable
4
+
1
5
  ### 0.5.1 (2018-01-05)
2
6
 
3
7
  * deprecate `#to_hash` in favor of more correct `#to_h`
@@ -0,0 +1,3 @@
1
+ :from_yaml:
2
+ :default: foo
3
+ :secondary: bar
@@ -1,6 +1,11 @@
1
- require 'pp'
2
-
3
1
  class ConfigModel < WatirModel
2
+ def self.create(hash = {})
3
+ file = factory_file(self)
4
+ env = ENV[self.to_s.underscore.upcase]
5
+ data = data_from_yaml(file, env)
6
+ new(data.merge hash)
7
+ end
8
+
4
9
  def default_value(key, block)
5
10
  ENV[key.to_s.upcase] || instance_exec(&block)
6
11
  end
@@ -1,4 +1,6 @@
1
1
  require 'active_support/hash_with_indifferent_access'
2
+ require 'active_support/core_ext/string'
3
+
2
4
  require 'json'
3
5
  require 'date'
4
6
  require 'time'
@@ -113,7 +115,7 @@ class WatirModel
113
115
  end
114
116
 
115
117
  def factory_file(type)
116
- Dir.glob("#{WatirModel.yml_directory}/#{type.to_s[/[^:]*$/].downcase}.yml").first
118
+ Dir.glob("#{WatirModel.yml_directory}/#{type.to_s[/[^:]*$/].underscore}.yml").first
117
119
  end
118
120
 
119
121
  def data_from_yaml(file, value)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "watir_model"
5
- spec.version = "0.5.1"
5
+ spec.version = "0.5.2"
6
6
  spec.authors = ["Titus Fortner"]
7
7
  spec.email = ["titusfortner@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
@@ -110,6 +110,7 @@ files:
110
110
  - Rakefile
111
111
  - config/alternate/address.yml
112
112
  - config/data/address.yml
113
+ - config/data/default_model.yml
113
114
  - lib/config_model.rb
114
115
  - lib/watir_model.rb
115
116
  - watir_model.gemspec