data_magic 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/data_magic.gemspec +1 -0
- data/lib/data_magic.rb +2 -1
- data/lib/data_magic/translation.rb +15 -3
- data/lib/data_magic/version.rb +1 -1
- data/spec/lib/translation_spec.rb +13 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c7bbf3adc899115c9e7a9adf920fad08da35db0
|
|
4
|
+
data.tar.gz: 27b97a2d7acffc7b80ed7aec7bd28b6e7e3d22de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef9a452bfdcb01ffb56ac7b45e4a75bbcff617ac00ed3a4baf9cf8383d138e70e8c325ea1daea970951cf207a4d9e8e1896e77893f70a7c8d7bac3423edb2cc2
|
|
7
|
+
data.tar.gz: 8fea34907191332335c7c6a49201140bcd937bdd1b9a46bce24fe3e93f7ea46c5a928cdb09bc58bc094ee48dc121c73353cb88f485cd5fdd720ebbb38247a447
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
=== Version 0.15.2 / 2013-7-17
|
|
2
|
+
* Fixes
|
|
3
|
+
* Display better message when key is not found (Thanks Guillaume Malette)
|
|
4
|
+
* Properly handling numeric values (Thanks Guillaume Malette)
|
|
5
|
+
|
|
1
6
|
=== Version 0.15.1 / 2013-7-11
|
|
2
7
|
* Fixes
|
|
3
8
|
* Fixed error when using sequential with entries that have spaces
|
data/data_magic.gemspec
CHANGED
|
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
|
|
|
7
7
|
gem.platform = Gem::Platform::RUBY
|
|
8
8
|
gem.authors = ["Jeff Morgan"]
|
|
9
9
|
gem.email = ["jeff.morgan@leandog.com"]
|
|
10
|
+
gem.license = 'MIT'
|
|
10
11
|
gem.homepage = "http://github.com/cheezy/data_magic"
|
|
11
12
|
gem.summary = %q{Provides datasets to application via YAML files}
|
|
12
13
|
gem.description = %q{Provides datasets to application stored in YAML files}
|
data/lib/data_magic.rb
CHANGED
|
@@ -20,6 +20,7 @@ module DataMagic
|
|
|
20
20
|
def data_for(key, additional={})
|
|
21
21
|
DataMagic.load('default.yml') unless DataMagic.yml
|
|
22
22
|
data = DataMagic.yml[key.to_s]
|
|
23
|
+
raise ArgumentError, "Undefined key #{key}" unless data
|
|
23
24
|
prep_data data.merge(additional).clone
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -28,7 +29,7 @@ module DataMagic
|
|
|
28
29
|
def prep_data(data)
|
|
29
30
|
data.each do |key, value|
|
|
30
31
|
unless value.nil?
|
|
31
|
-
next
|
|
32
|
+
next if !value.respond_to?('[]') || value.is_a?(Numeric)
|
|
32
33
|
data[key] = translate(value[1..-1]) if value[0,1] == "~"
|
|
33
34
|
end
|
|
34
35
|
end
|
|
@@ -271,15 +271,27 @@ module DataMagic
|
|
|
271
271
|
private
|
|
272
272
|
|
|
273
273
|
def set_index_variable(ary, value)
|
|
274
|
-
|
|
274
|
+
index_hash[index_name(ary)] = value
|
|
275
275
|
end
|
|
276
276
|
|
|
277
277
|
def index_variable_for(ary)
|
|
278
|
-
|
|
278
|
+
value = index_hash[index_name(ary)]
|
|
279
|
+
index_hash[index_name(ary)] = -1 unless value
|
|
280
|
+
index_hash[index_name(ary)]
|
|
279
281
|
end
|
|
280
282
|
|
|
281
283
|
def index_name(ary)
|
|
282
|
-
"
|
|
284
|
+
"#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def index_hash
|
|
288
|
+
dh = data_hash[parent]
|
|
289
|
+
data_hash[parent] = {} unless dh
|
|
290
|
+
data_hash[parent]
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def data_hash
|
|
294
|
+
$data_magic_data_hash ||= {}
|
|
283
295
|
end
|
|
284
296
|
|
|
285
297
|
def process(value)
|
data/lib/data_magic/version.rb
CHANGED
|
@@ -250,6 +250,19 @@ describe "DataMagic translations" do
|
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
+
context "with numeric values" do
|
|
254
|
+
it "doesn't translate values" do
|
|
255
|
+
set_field_value(1)
|
|
256
|
+
example.data_for("key").should have_field_value 1
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
context "with values not in the yaml" do
|
|
261
|
+
it "throws a ArgumentError" do
|
|
262
|
+
expect { example.data_for("inexistant_key") }.to raise_error ArgumentError
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
253
266
|
context "providing date values" do
|
|
254
267
|
it "should provide today's date" do
|
|
255
268
|
set_field_value '~today'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: data_magic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.15.
|
|
4
|
+
version: 0.15.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeff Morgan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-07-
|
|
11
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faker
|
|
@@ -103,7 +103,8 @@ files:
|
|
|
103
103
|
- spec/lib/translation_spec.rb
|
|
104
104
|
- spec/spec_helper.rb
|
|
105
105
|
homepage: http://github.com/cheezy/data_magic
|
|
106
|
-
licenses:
|
|
106
|
+
licenses:
|
|
107
|
+
- MIT
|
|
107
108
|
metadata: {}
|
|
108
109
|
post_install_message:
|
|
109
110
|
rdoc_options: []
|