ghost-seeder 0.0.1 → 0.0.2

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: c2b69d6c521290ff1914d9076db5500f11156354
4
- data.tar.gz: 0145efeafd3e6770b5fb443336ccf299ff5cd8ec
3
+ metadata.gz: 8efe6335c40e83c8f2fbfda35552b5d3b9f279d4
4
+ data.tar.gz: e658faa47583c196120efb8ddd25001a69247273
5
5
  SHA512:
6
- metadata.gz: db9caa0b3bae4efd34164e04514d97883d7c354311372ef7b70bd0312c45bd419dfde2d837a7146e966afddf10a8b603826f8631345834ebc159846f525e2799
7
- data.tar.gz: 7f8c893c437cd56b4ec103abc0addc9443a85f3eea646e51f498d0c47a22e05ed2d38fcca222763fa9222234966560e4b20f04987823be7d4887911671fe153e
6
+ metadata.gz: d020f1ca0927c702e8ca60dda487da3a486c8432d1842ebc7bb4c5e25ceecf2d072bbced09b33e61eeff788ddce4c17fef92aba645c3d36b3702a1c2b7feba0f
7
+ data.tar.gz: 54d1b2ff437e4c9b52ab77dc0d36bf3624d9838a8be0e4bd778517cfe23aee1b212c23ccdb548f104850d319ec94b74e96bf74b61d0fcb0c2fb42b1ce4c7e5e8
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # changelog
2
+
3
+ ## v0.0.1
4
+
5
+ _initial release_
6
+
7
+ * imported from old implementation
8
+
9
+ ## v0.0.2
10
+
11
+ * allow fixtures to be simpler by providing some defaults in models
@@ -24,13 +24,17 @@ module Ghost
24
24
  File.read(
25
25
  "./config/seed/fixtures/#{identifier}.yml"
26
26
  )
27
- ).result(YamlBindings.new.helper)
27
+ ).result(yaml_bindings.helper)
28
28
  )
29
29
  end
30
30
 
31
31
  def seeds
32
32
  load_fixtures klass.to_s.downcase.pluralize
33
33
  end
34
+
35
+ def yaml_bindings
36
+ YamlBindings.new
37
+ end
34
38
  end
35
39
 
36
40
  attr_reader :record, :attributes
@@ -52,6 +56,11 @@ module Ghost
52
56
 
53
57
  private
54
58
 
59
+ def yaml_bindings_helper(method)
60
+ @yaml_bindings ||= self.class.yaml_bindings
61
+ @yaml_bindings.send(method)
62
+ end
63
+
55
64
  def first_user
56
65
  @first_user ||= User.first
57
66
  end
@@ -24,14 +24,6 @@ module Ghost
24
24
  Faker::Hipster.paragraph(2, true, 2)
25
25
  end
26
26
 
27
- # def lipsum_html
28
- # Faker::Lorem.paragraph(5, true, 5)
29
- # end
30
- #
31
- # def lipsum_small
32
- # Faker::Lorem.sentence
33
- # end
34
-
35
27
  def fake_sentence
36
28
  Faker::Hipster.sentence
37
29
  end
@@ -12,7 +12,7 @@ module Ghost
12
12
 
13
13
  def attributes_for_create
14
14
  html = "<p>#{record.markdown.split("\n").join("</p><p>")}</p>"
15
- attributes.merge(
15
+ defaults.merge(attributes).merge(
16
16
  author_id: first_user.id,
17
17
  created_by: first_user.id,
18
18
  updated_by: first_user.id,
@@ -20,6 +20,19 @@ module Ghost
20
20
  html: html
21
21
  )
22
22
  end
23
+
24
+ def defaults
25
+ {
26
+ created_at: Time.now,
27
+ updated_at: Time.now,
28
+ published_at: Time.now,
29
+ page: false,
30
+ featured: false,
31
+ language: "en_US",
32
+ status: "published",
33
+ uuid: yaml_bindings_helper(:uuid)
34
+ }
35
+ end
23
36
  end
24
37
  end
25
38
  end
@@ -11,11 +11,17 @@ module Ghost
11
11
  private
12
12
 
13
13
  def attributes_for_create
14
- attributes.merge(
14
+ defaults.merge(attributes).merge(
15
15
  created_by: first_user.id,
16
16
  updated_by: first_user.id
17
17
  )
18
18
  end
19
+
20
+ def defaults
21
+ {
22
+ uuid: yaml_bindings_helper(:uuid)
23
+ }
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -1,5 +1,5 @@
1
1
  module Ghost
2
2
  module Seeder
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghost-seeder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Andrés Correa
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - CODE_OF_CONDUCT.md
108
109
  - Gemfile
109
110
  - LICENSE