application_seeds 0.7.0 → 0.8.0
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.
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +12 -0
- data/lib/application_seeds/version.rb +1 -1
- data/lib/application_seeds.rb +8 -0
- data/spec/application_seeds_spec.rb +18 -0
- metadata +4 -4
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -542,6 +542,18 @@ method let's you easly account for slight differences is attribute names
|
|
542
542
|
across applications.
|
543
543
|
|
544
544
|
|
545
|
+
### Fetching the label for a specific seed
|
546
|
+
|
547
|
+
```ruby
|
548
|
+
ApplicationSeeds.label_for_id(:people, 636095969)
|
549
|
+
```
|
550
|
+
|
551
|
+
This call will return the label (as a symbol) of the seed data entry
|
552
|
+
that corresponds to the given seed type and id. ID or UUID may be used
|
553
|
+
to identify the seed data entry. `nil` will be returned if no seed data
|
554
|
+
entry could be found with the specified ID.
|
555
|
+
|
556
|
+
|
545
557
|
### Reset id column sequence numbers
|
546
558
|
|
547
559
|
```ruby
|
data/lib/application_seeds.rb
CHANGED
@@ -154,6 +154,14 @@ module ApplicationSeeds
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
+
#
|
158
|
+
# Fetch the label for the associated seed type and ID.
|
159
|
+
#
|
160
|
+
def label_for_id(seed_type, id)
|
161
|
+
x = seed_labels[seed_type.to_s].select { |label, ids| ids[:integer] == id || ids[:uuid] == id }
|
162
|
+
x.keys.first.to_sym if x && x.keys.first
|
163
|
+
end
|
164
|
+
|
157
165
|
private
|
158
166
|
|
159
167
|
def dataset_path(dataset)
|
@@ -231,6 +231,15 @@ describe "ApplicationSeeds" do
|
|
231
231
|
expect(ApplicationSeeds.config_value(:whaa)).to be_nil
|
232
232
|
end
|
233
233
|
end
|
234
|
+
|
235
|
+
describe "fetching the label for an id" do
|
236
|
+
it "can fetch the label for a given id" do
|
237
|
+
expect(ApplicationSeeds.label_for_id(:people, 636095969)).to eql(:joe_smith)
|
238
|
+
end
|
239
|
+
it "returns nil if the id could not be found" do
|
240
|
+
expect(ApplicationSeeds.label_for_id(:people, 111111111)).to be_nil
|
241
|
+
end
|
242
|
+
end
|
234
243
|
end
|
235
244
|
|
236
245
|
describe "with a nested dataset" do
|
@@ -306,6 +315,15 @@ describe "ApplicationSeeds" do
|
|
306
315
|
expect(@person['company_id']).to eql("00000000-0000-0000-0000-000047393448")
|
307
316
|
end
|
308
317
|
end
|
318
|
+
|
319
|
+
describe "fetching the label for an uuid" do
|
320
|
+
it "can fetch the label for a given uuid" do
|
321
|
+
expect(ApplicationSeeds.label_for_id(:people, '00000000-0000-0000-0000-000010284664')).to eql(:john_walsh)
|
322
|
+
end
|
323
|
+
it "returns nil if the uuid could not be found" do
|
324
|
+
expect(ApplicationSeeds.label_for_id(:people, '00000000-0000-0000-0000-000011111111')).to be_nil
|
325
|
+
end
|
326
|
+
end
|
309
327
|
end
|
310
328
|
|
311
329
|
describe "with data type specific key types configured" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: application_seeds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash:
|
126
|
+
hash: -4366839030827640870
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
segments:
|
134
134
|
- 0
|
135
|
-
hash:
|
135
|
+
hash: -4366839030827640870
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
138
|
rubygems_version: 1.8.23
|