watir_model 0.5.0 → 0.5.1

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: d4a63d0d44bca88f86db3a5f5a379eacb7e7c1d1
4
- data.tar.gz: dfa9f23bfaadb59ed9e24191c6ae4d17fb3b854b
3
+ metadata.gz: b2e75024846f7980a3bcefaefbcc5f9f1a4661e9
4
+ data.tar.gz: 385e78e0816e7f276622c8cd2377f804e7bfef12
5
5
  SHA512:
6
- metadata.gz: 7981185908b815a682f83c7cd33745732aa512fa3681f6561da8ad9aea7d244a9b3d23ecb05a4e6776a3534a2619bc293d9cb4da91a11dc1d9135a0bb4f9f097
7
- data.tar.gz: dec2feaa6de866aaa79cc1add9b0e1740e0041a831f1184ac51c092fc58fbb06eea1a6d678bc8a45afc11c84873dbad6c4da9c87c309f675337d5d3233e3a928
6
+ metadata.gz: fafe4c3d76271bf146a7a3826f4d8059a87e2032b2d1bd9e416e1d3f3c66c8c3620e0b2185eabb50eaf6742160ceb186b95658d27a3ece01d763df3dcd0202d3
7
+ data.tar.gz: ad4cf6a0161fd9c0a8b81fe01ef1ac4a434ba50ccd76804c54db769641a7c347266b5be8901a359a4f8811443d1772e476ef990f26384fb78afae0e5c30a7e0a
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.5.1 (2018-01-05)
2
+
3
+ * deprecate `#to_hash` in favor of more correct `#to_h`
4
+ * remove support for key `:aliases`
5
+
1
6
  ### 0.5.0 (2017-12-29)
2
7
 
3
8
  * prevent `#convert` when default values won't be used
data/lib/watir_model.rb CHANGED
@@ -2,22 +2,19 @@ require 'active_support/hash_with_indifferent_access'
2
2
  require 'json'
3
3
  require 'date'
4
4
  require 'time'
5
+ require 'faker'
5
6
  require 'yml_reader'
6
7
 
7
8
  class WatirModel
8
9
  class << self
9
10
  include YmlReader
10
11
 
11
- attr_writer :keys, :aliases, :data_types, :defaults, :apis
12
+ attr_writer :keys, :data_types, :defaults, :apis
12
13
 
13
14
  def keys
14
15
  @keys ||= []
15
16
  end
16
17
 
17
- def aliases
18
- @aliases ||= {}
19
- end
20
-
21
18
  def data_types
22
19
  @data_types ||= {}
23
20
  end
@@ -31,20 +28,18 @@ class WatirModel
31
28
  end
32
29
 
33
30
  def valid_keys
34
- keys + aliases.keys + apis.keys
31
+ keys + apis.keys
35
32
  end
36
33
 
37
34
  def inherited(subclass)
38
35
  subclass.keys = keys.dup
39
- subclass.aliases = aliases.dup
40
36
  subclass.apis = apis.dup
41
37
  subclass.defaults = defaults.dup
42
38
  subclass.data_types = data_types.dup
43
39
  end
44
40
 
45
- def key(symbol, data_type: nil, aliases: [], api: nil, &block)
41
+ def key(symbol, data_type: nil, api: nil, &block)
46
42
  keys << symbol unless @keys.include? symbol
47
- aliases.each { |alias_key| self.aliases[alias_key] = symbol }
48
43
  attr_accessor symbol
49
44
  apis[api] = symbol if api
50
45
  data_types[symbol] = data_type if data_type
@@ -105,7 +100,7 @@ class WatirModel
105
100
 
106
101
  def default_value_keys(hash)
107
102
  hash.keys.map do |key|
108
- keys.include?(key) ? key : (aliases[key] || apis[key])
103
+ keys.include?(key) ? key : apis[key]
109
104
  end
110
105
  end
111
106
 
@@ -142,10 +137,6 @@ class WatirModel
142
137
  def update(hash)
143
138
  hash ||= {}
144
139
 
145
- (hash.keys & aliases.keys).each do |alias_key|
146
- hash[aliases[alias_key]] = hash.delete(alias_key)
147
- end
148
-
149
140
  (hash.keys & apis.keys).each do |api_key|
150
141
  hash[apis[api_key]] = hash.delete(api_key)
151
142
  end
@@ -163,16 +154,12 @@ class WatirModel
163
154
  self.class.keys
164
155
  end
165
156
 
166
- def aliases
167
- self.class.aliases
168
- end
169
-
170
157
  def apis
171
158
  self.class.apis
172
159
  end
173
160
 
174
161
  def valid_keys
175
- self.class.apis
162
+ self.class.valid_keys
176
163
  end
177
164
 
178
165
  def [] key
@@ -185,21 +172,26 @@ class WatirModel
185
172
  alias_method :==, :eql?
186
173
 
187
174
  def to_hash(opt = nil)
175
+ warn "#to_hash is deprecated, use #to_h instead"
176
+ to_h opt
177
+ end
178
+
179
+ def to_h(opt = nil)
188
180
  opt ||= keys
189
181
  opt.each_with_object({}) do |key, hash|
190
182
  value = send(key)
191
183
  next if value.nil?
192
- value = value.to_hash if value.is_a? WatirModel
184
+ value = value.to_h if value.is_a? WatirModel
193
185
  hash[key] = value
194
186
  end
195
187
  end
196
188
 
197
189
  def to_json(*)
198
- to_hash.to_json
190
+ to_h.to_json
199
191
  end
200
192
 
201
193
  def to_api
202
- hash = to_hash
194
+ hash = to_h
203
195
  apis.each do |key, value|
204
196
  hash[key] = hash.delete(value)
205
197
  end
data/watir_model.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "watir_model"
5
- spec.version = "0.5.0"
5
+ spec.version = "0.5.1"
6
6
  spec.authors = ["Titus Fortner"]
7
7
  spec.email = ["titusfortner@gmail.com"]
8
8
 
@@ -25,10 +25,10 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_runtime_dependency 'activesupport'
28
+ spec.add_runtime_dependency 'faker', "~> 1.5"
28
29
  spec.add_runtime_dependency 'yml_reader', '>= 0.6'
29
30
 
30
31
  spec.add_development_dependency "bundler", "~> 1.9"
31
32
  spec.add_development_dependency "rake", "~> 10.0"
32
33
  spec.add_development_dependency "rspec", "~> 3.3"
33
- spec.add_development_dependency "faker", "~> 1.5"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-30 00:00:00.000000000 Z
11
+ date: 2018-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: yml_reader
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +94,6 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.3'
83
- - !ruby/object:Gem::Dependency
84
- name: faker
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.5'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.5'
97
97
  description: This is a simple class for modelling test data. It is based on our experience
98
98
  with Watirmark::Model::Factory.
99
99
  email: