middleman-dato 0.0.1.rc12 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +7 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +9 -1070
  5. data/Gemfile +8 -8
  6. data/Rakefile +14 -5
  7. data/foo.rb +12 -0
  8. data/lib/dato/client.rb +14 -9
  9. data/lib/dato/entities_repo.rb +43 -0
  10. data/lib/dato/field_type/boolean.rb +9 -0
  11. data/lib/dato/field_type/date.rb +9 -0
  12. data/lib/dato/field_type/date_time.rb +9 -0
  13. data/lib/dato/field_type/file.rb +30 -0
  14. data/lib/dato/field_type/float.rb +9 -0
  15. data/lib/dato/field_type/image.rb +23 -0
  16. data/lib/dato/field_type/integer.rb +9 -0
  17. data/lib/dato/field_type/lat_lon.rb +16 -0
  18. data/lib/dato/field_type/link.rb +9 -0
  19. data/lib/dato/field_type/links.rb +9 -0
  20. data/lib/dato/field_type/seo.rb +21 -0
  21. data/lib/dato/field_type/string.rb +9 -0
  22. data/lib/dato/field_type/text.rb +9 -0
  23. data/lib/dato/field_type/video.rb +48 -0
  24. data/lib/dato/json_api_entity.rb +75 -0
  25. data/lib/dato/meta_tags/article_modified_time.rb +3 -3
  26. data/lib/dato/meta_tags/article_publisher.rb +3 -3
  27. data/lib/dato/meta_tags/base.rb +12 -19
  28. data/lib/dato/meta_tags/description.rb +4 -4
  29. data/lib/dato/meta_tags/image.rb +5 -8
  30. data/lib/dato/meta_tags/og_locale.rb +2 -2
  31. data/lib/dato/meta_tags/og_meta_tag.rb +2 -4
  32. data/lib/dato/meta_tags/og_site_name.rb +2 -2
  33. data/lib/dato/meta_tags/og_type.rb +5 -5
  34. data/lib/dato/meta_tags/robots.rb +2 -4
  35. data/lib/dato/meta_tags/title.rb +5 -4
  36. data/lib/dato/meta_tags/twitter_card.rb +3 -3
  37. data/lib/dato/meta_tags/twitter_meta_tag.rb +2 -4
  38. data/lib/dato/meta_tags/twitter_site.rb +2 -2
  39. data/lib/dato/meta_tags/url.rb +4 -4
  40. data/lib/dato/meta_tags_builder.rb +13 -13
  41. data/lib/dato/middleman_extension.rb +15 -23
  42. data/lib/dato/record.rb +77 -46
  43. data/lib/dato/records_repo.rb +106 -0
  44. data/lib/dato/space.rb +36 -0
  45. data/lib/middleman-dato.rb +5 -2
  46. data/middleman-dato.gemspec +14 -13
  47. data/spec/dato/entities_repo_spec.rb +41 -0
  48. data/spec/dato/field_type/file_spec.rb +20 -0
  49. data/spec/dato/field_type/image_spec.rb +24 -0
  50. data/spec/dato/field_type/lat_lon_spec.rb +18 -0
  51. data/spec/dato/field_type/seo_spec.rb +31 -0
  52. data/spec/dato/field_type/video_spec.rb +32 -0
  53. data/spec/dato/json_api_entity_spec.rb +123 -0
  54. data/spec/dato/meta_tags/article_modified_time_spec.rb +16 -14
  55. data/spec/dato/meta_tags/image_spec.rb +39 -0
  56. data/spec/dato/meta_tags/og_locale_spec.rb +14 -12
  57. data/spec/dato/record_spec.rb +137 -78
  58. data/spec/dato/records_repo_spec.rb +125 -0
  59. data/spec/spec_helper.rb +14 -12
  60. metadata +58 -13
  61. data/lib/dato/field.rb +0 -43
  62. data/lib/dato/fields/belongs_to.rb +0 -21
  63. data/lib/dato/fields/file.rb +0 -22
  64. data/lib/dato/fields/seo.rb +0 -37
  65. data/lib/dato/repo.rb +0 -111
  66. data/lib/middleman_extension.rb +0 -1
  67. data/spec/dato/field_spec.rb +0 -110
@@ -1 +0,0 @@
1
- require "middleman-dato"
@@ -1,110 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Dato::Field do
4
- describe ".value" do
5
- let(:attribute) { "bar" }
6
- let(:field) { { field_type: "text" } }
7
-
8
- it "returns the field value" do
9
- expect(described_class.value(attribute, field)).to eq("bar")
10
- end
11
-
12
- context "if the field is marked to be localizable" do
13
- let(:field) { { field_type: "text", localized: true } }
14
-
15
- before do
16
- allow(I18n).to receive(:locale).and_return("en")
17
- end
18
-
19
- context "if it has a translation for the current locale" do
20
- let(:attribute) { { en: "baz" } }
21
-
22
- it "returns the field value translation" do
23
- expect(described_class.value(attribute, field)).to eq("baz")
24
- end
25
- end
26
-
27
- context "else" do
28
- let(:attribute) { { fr: "baz" } }
29
-
30
- it "returns nil" do
31
- expect(described_class.value(attribute, field)).to be_nil
32
- end
33
- end
34
- end
35
-
36
- describe "field types" do
37
- let(:client) { double("Client") }
38
-
39
- before do
40
- allow(Dato::Client).to receive(:new).and_return(client)
41
- allow(client).to receive(:records).and_return(data: [
42
- {
43
- id: 1,
44
- attributes: {},
45
- links: {
46
- content_type: {
47
- linkage: {
48
- id: "foo",
49
- type: "content_type"
50
- }
51
- }
52
- }
53
- }
54
- ])
55
- allow(client).to receive(:space).and_return(
56
- data: {
57
- links: {
58
- content_types: {
59
- linkage: [
60
- {
61
- id: "foo",
62
- type: "content_type"
63
- }
64
- ]
65
- }
66
- }
67
- },
68
- included: [
69
- {
70
- attributes: {
71
- name: "foo",
72
- singleton: false
73
- },
74
- id: "foo",
75
- links: {
76
- fields: {
77
- linkage: []
78
- },
79
- singleton_record: {
80
- linkage: nil
81
- }
82
- },
83
- type: "content_type"
84
- }
85
- ]
86
- )
87
-
88
- Dato::Repo.instance.connection_options = {}
89
- Dato::Repo.instance.sync!
90
- end
91
-
92
- [
93
- { type: "image", value: {}, result: Dato::Fields::File.new({}) },
94
- { type: "file", value: {}, result: Dato::Fields::File.new({}) },
95
- { type: "date", value: "2015-06-09", result: Date.new(2015, 6, 9) },
96
- { type: "seo", value: {}, result: Dato::Fields::Seo.new({}) },
97
- { type: "belongs_to", value: 1, result: Dato::Record.new({ id: 1 }, fields: {}) }
98
- ].each do |data|
99
- context "if the field has '#{data[:type]}' type" do
100
- let(:attribute) { data[:value] }
101
- let(:field) { { field_type: data[:type] } }
102
-
103
- it "converts the value to the specific type" do
104
- expect(described_class.value(attribute, field)).to eq(data[:result])
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end