data_magic 0.21 → 0.22

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: fb33fc76ad2d11424680b76db1d254569252983a
4
- data.tar.gz: 5e6eff63a88bf36e2de0ab28db7e6ee56dd2ffea
3
+ metadata.gz: f8e3fd3732d4db189c086a0d1f249477d7dbc629
4
+ data.tar.gz: 902996720a2c99cfae0aff452508cc8abe6c7dc5
5
5
  SHA512:
6
- metadata.gz: 8f2d5248626604deee0f59c8debd9d317350831f6e069f10ea0b8a3b325e709a11ce7c989b08ed8868070056d46cd6dbd2cd0234980cf42d51cd4a9b85e04453
7
- data.tar.gz: 3a3696d44f432555a1365e62824d29d99e68323f72f85dae37d3cdf35f35b226c87a5bdd8926701690a3b7d8db3ad6a292b5ff2f11bd94756e13b512e7cdda59
6
+ metadata.gz: dfd5ea7be34a9deb10f2514d7f50ca4dfe998ec25346d2fdd383008235695a1756b2aa438c59945f59b3f6e7b0c5d48bf81d8a98bdfe428dc21582c51d10ca65
7
+ data.tar.gz: a08950ff0dc236fe3ea6161e7c62810851b6aa4fa5e67bb5f58a3d858121c367cc02abc0ba3ecd28b62722f529d7b735934fbe4bd82cd92d980d8aa2776bb8f7
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.22 / 2015-12-2
2
+ * Enhancements
3
+ * Better handling for nexted hash translation
4
+
1
5
  === Version 0.21 / 2015-4-12
2
6
  * Enhancements
3
7
  * Added support for locale
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'faker', '>= 1.1.2'
21
- gem.add_dependency 'yml_reader', '>= 0.4'
21
+ gem.add_dependency 'yml_reader', '>= 0.6'
22
22
 
23
23
  gem.add_development_dependency 'rspec', '>= 2.12.0'
24
24
  gem.add_development_dependency 'cucumber', '>= 1.2.0'
@@ -1,5 +1,5 @@
1
1
  Feature: Functionality of the data_magic gem
2
-
2
+
3
3
  Background:
4
4
  Given I have read the yaml file from features/yaml
5
5
  When I ask for the data for "dm"
@@ -101,7 +101,7 @@ Feature: Functionality of the data_magic gem
101
101
 
102
102
  Scenario: Getting a random month name
103
103
  Then the value for "some_month" should be a valid month
104
-
104
+
105
105
  Scenario: Getting a random month abbreviation
106
106
  Then the value for "month_abbr" should be a valid month abbreviation
107
107
 
@@ -118,6 +118,16 @@ Feature: Functionality of the data_magic gem
118
118
  Scenario: Getting values from nested entries
119
119
  Then the nested value for this is_nested should be "Nested Value"
120
120
 
121
+ Scenario Outline: Translate values from nested hahs
122
+ Given overwrite @data with translate_nested
123
+ Then the nested hash should include <key>
124
+ And the value for "<key>" should <validate>
125
+ And the value for "<key>" should not mach <negative_validate>
126
+ Examples:
127
+ | key | validate | negative_validate |
128
+ | full_name | have a minimum of 2 words | ~full_name |
129
+ | first_name | be 1 word long | ~first_name |
130
+
121
131
  Scenario: Should be able to call the translator methods on DataMagic module
122
132
  Then I should be able to call the full_name translator
123
133
  And I should be able to call the state translator
@@ -28,7 +28,7 @@ Then /^the value for "(.+)" should be (true|false)$/ do |key, value|
28
28
  end
29
29
 
30
30
  Then /^the value for "(.+)" should be (\d+) word|words long$/ do |key, length|
31
- expect(@data[key].split(' ').size).to eql length.to_i
31
+ expect(@data[key].split(' ').size).to eql length.to_i
32
32
  end
33
33
 
34
34
  Then /^the value for "(.+)" should have a minimum of (\d+) word|wordss$/ do |key, length|
@@ -147,6 +147,10 @@ Then(/^the nested value for this is_nested should be "(.*?)"$/) do |value|
147
147
  expect(@data['this']['is_nested']).to eql value
148
148
  end
149
149
 
150
+ Then(/^the nested hash should include (.*?)$/) do |value|
151
+ expect(@data.keys).to include value
152
+ end
153
+
150
154
  Then(/^the value for "(.*?)" should be a phone number$/) do |value|
151
155
  phone = @data[value]
152
156
  if phone.split(' ').length == 2
@@ -161,3 +165,14 @@ Then(/^I should be able to call the (.+) translator$/) do |method|
161
165
  value = DataMagic.send method
162
166
  expect(value).not_to be_empty
163
167
  end
168
+
169
+
170
+ And(/^the value for "([^"]*)" should not mach (.*)$/) do |key, value|
171
+ expect(@data[key]).not_to eql value
172
+ end
173
+
174
+
175
+ Given(/^overwrite @data with (.*)$/) do |hash|
176
+ # This is a bit dangerous but quick way to make all steps to work with nested data
177
+ @data = @data['this'][hash]
178
+ end
@@ -46,6 +46,9 @@ dm:
46
46
  day_abbr: ~day_of_week_abbr
47
47
  this:
48
48
  is_nested: Nested Value
49
+ translate_nested:
50
+ full_name: ~full_name
51
+ first_name: ~first_name
49
52
 
50
53
  dynamic:
51
54
  blah: ~blah
@@ -50,8 +50,11 @@ module DataMagic
50
50
  data.each do |key, value|
51
51
  unless value.nil?
52
52
  next if !value.respond_to?('[]') || value.is_a?(Numeric)
53
- next if value.is_a?(Hash)
54
- data[key] = translate(value[1..-1]) if value[0,1] == "~"
53
+ if value.is_a?(Hash)
54
+ data[key] = prep_data(value)
55
+ else
56
+ data[key] = translate(value[1..-1]) if value[0,1] == "~"
57
+ end
55
58
  end
56
59
  end
57
60
  data
@@ -1,3 +1,3 @@
1
1
  module DataMagic
2
- VERSION = "0.21"
2
+ VERSION = "0.22"
3
3
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.21'
4
+ version: '0.22'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-12 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yml_reader
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '0.4'
40
+ version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.12.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.12.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cucumber
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.2.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.0
69
69
  description: Provides datasets to application stored in YAML files
@@ -73,11 +73,11 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".ruby-gemset"
79
- - ".ruby-version"
80
- - ".travis.yml"
76
+ - .gitignore
77
+ - .rspec
78
+ - .ruby-gemset
79
+ - .ruby-version
80
+ - .travis.yml
81
81
  - ChangeLog
82
82
  - Gemfile
83
83
  - Guardfile
@@ -114,17 +114,17 @@ require_paths:
114
114
  - lib
115
115
  required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - '>='
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.2.2
127
+ rubygems_version: 2.0.14
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Provides datasets to application via YAML files