faker_maker 0.7.0 → 0.7.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
  SHA256:
3
- metadata.gz: e265f317bfd43d44382e9db7e9359c7c0bf21e946b361c3d0973d9ca0cd9c6d1
4
- data.tar.gz: 5765b8eff404d6e8156ef05b5dc3fff0fd1f747d53fb5e2bd8a50867ed459f47
3
+ metadata.gz: 4f977406ece1d14881538014e4b76cb2d6d93d2753163414211170223dea9c83
4
+ data.tar.gz: 315e1e877b305628ffdd659b0afa7003554cf778d3b32eadb950b40c7b300f2b
5
5
  SHA512:
6
- metadata.gz: 68c81cf0d7fc4be3bd21e303fb2315bbfd0b99b438292e6a5e525451a39e21ccf72d309210f0ad7c868a67c510534c540b94f3c80f321924783fdc5babe90350
7
- data.tar.gz: 17aa8890f8e86834810742ecc6d10784c2a4e673af059db8f0249a7bfb4cd9b84335cf34ad416b879f7b824632cbd9003bbcba8340a55a82b8100985f19741dd
6
+ metadata.gz: b8d80e848a217be01b2425e2538a9923b101fbd1eaf51e8fbb51878516f4078dbe6a96540ae8ae306fecc65dc099362b6af85e7c83553f256d3fc4243f20719e
7
+ data.tar.gz: 9717105b014298cada262689873234a136c131c51433441e91184a3ea7cfabbd9912320539bfb8a3c17485c266bde3c2bb969665bdc197ca40f5fa2987ad6221
data/.gitignore CHANGED
@@ -10,3 +10,5 @@
10
10
  Gemfile.lock
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+
14
+ .DS_Store
data/README.md CHANGED
@@ -123,28 +123,6 @@ FakerMaker.factory :basket do
123
123
  end
124
124
  ```
125
125
 
126
- JSON keys are often have a different stylistic convention than Ruby's snake-case so you can override the attribute's name when is come to generating JSON:
127
-
128
- ```ruby
129
- FakerMaker.factory :item do
130
- name( json: 'productName' ) { Faker::Commerce.product_name }
131
- price( json: 'ticketPrice' ) { Faker::Commerce.price }
132
- end
133
- ```
134
-
135
- so in Ruby you would access the attribute using the attribute name as in:
136
-
137
- ```ruby
138
- item = FM[:item].build
139
- puts item
140
- ```
141
-
142
- but `item.to_json` would produce:
143
-
144
- ```javascript
145
- {"productName":"Enormous Silk Pants","ticketPrice":55.35}
146
- ```
147
-
148
126
  ### Building instances
149
127
 
150
128
  Instances are Plain Ol' Ruby Objects and the attributes are attached with getters and setters with their values assigned to the value return from their block at build time.
@@ -157,6 +135,14 @@ result = FakerMaker[:basket].build
157
135
 
158
136
  will generate a new instance using the Basket factory. Because an actual class is defined, you can instantiate an object directly through `Basket.new` but that will not populate any of the attributes.
159
137
 
138
+ It's possible to override attributes at build-time:
139
+
140
+ ```ruby
141
+ result = FakerMaker[:item].build{ |i| i.name = 'Electric Sheep' }
142
+ ```
143
+
144
+ Calling `result.to_json` will give a stringified JSON representation. Because ActiveSupport is used under the covers, `as_json` will give you a `Hash` rather than the stringified version.
145
+
160
146
  As a convenience, you can request a JSON representation directly:
161
147
 
162
148
  ```ruby
@@ -17,13 +17,13 @@ module FakerMaker
17
17
  end
18
18
 
19
19
  def attach_attribute attribute
20
- @attributes << attribute
20
+ @attributes << attribute
21
21
  end
22
22
 
23
23
  def build
24
24
  instance = instantiate
25
25
  populate_instance instance
26
- yield self if block_given?
26
+ yield instance if block_given?
27
27
  instance
28
28
  end
29
29
 
@@ -1,3 +1,3 @@
1
1
  module FakerMaker
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -126,7 +126,6 @@ files:
126
126
  - bin/console
127
127
  - bin/setup
128
128
  - faker_maker.gemspec
129
- - lib/.DS_Store
130
129
  - lib/faker_maker.rb
131
130
  - lib/faker_maker/attribute.rb
132
131
  - lib/faker_maker/base.rb
Binary file