wcc-contentful 0.3.0 → 0.4.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -1
  3. data/Gemfile +0 -2
  4. data/README.md +1 -0
  5. data/bin/console +4 -3
  6. data/bin/rails +2 -0
  7. data/lib/wcc/contentful.rb +2 -32
  8. data/lib/wcc/contentful/exceptions.rb +0 -33
  9. data/lib/wcc/contentful/model.rb +0 -1
  10. data/lib/wcc/contentful/store/postgres_store.rb +2 -2
  11. data/lib/wcc/contentful/version.rb +1 -1
  12. data/wcc-contentful.gemspec +5 -3
  13. metadata +36 -35
  14. data/.circleci/config.yml +0 -51
  15. data/.gitignore +0 -26
  16. data/.rubocop.yml +0 -242
  17. data/.rubocop_todo.yml +0 -19
  18. data/.travis.yml +0 -5
  19. data/CHANGELOG.md +0 -180
  20. data/CODE_OF_CONDUCT.md +0 -74
  21. data/LICENSE.txt +0 -21
  22. data/Rakefile +0 -8
  23. data/lib/generators/wcc/USAGE +0 -24
  24. data/lib/generators/wcc/model_generator.rb +0 -90
  25. data/lib/generators/wcc/templates/.keep +0 -0
  26. data/lib/generators/wcc/templates/Procfile +0 -3
  27. data/lib/generators/wcc/templates/contentful_shell_wrapper +0 -385
  28. data/lib/generators/wcc/templates/menu/generated_add_menus.ts +0 -192
  29. data/lib/generators/wcc/templates/menu/models/menu.rb +0 -23
  30. data/lib/generators/wcc/templates/menu/models/menu_button.rb +0 -23
  31. data/lib/generators/wcc/templates/page/generated_add_pages.ts +0 -50
  32. data/lib/generators/wcc/templates/page/models/page.rb +0 -23
  33. data/lib/generators/wcc/templates/release +0 -9
  34. data/lib/generators/wcc/templates/wcc_contentful.rb +0 -17
  35. data/lib/wcc/contentful/model/dropdown_menu.rb +0 -7
  36. data/lib/wcc/contentful/model/menu.rb +0 -6
  37. data/lib/wcc/contentful/model/menu_button.rb +0 -16
  38. data/lib/wcc/contentful/model/page.rb +0 -8
  39. data/lib/wcc/contentful/model/redirect.rb +0 -19
  40. data/lib/wcc/contentful/model_validators.rb +0 -121
  41. data/lib/wcc/contentful/model_validators/dsl.rb +0 -166
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ec3b6e59e9d2f5a5e4ce7c7c3198b5bd2c26fd7
4
- data.tar.gz: 6dcc462e7d3d993d7a7dd0717e560b5c63a59c40
3
+ metadata.gz: c54cd88861b87469555e71fe1a83ee70cbfe6dfe
4
+ data.tar.gz: e0fbecf29c3dde28acf284ecce0973a0ceca9669
5
5
  SHA512:
6
- metadata.gz: cb4c3982f588c90189a82dbe9b7b11080d1981cd6ce89ade2b9169c0a463e5bb6f2e7e20500fc921548d77af77a7d85f43edd0ff913a0788afd1c388c6c7d7fc
7
- data.tar.gz: 420d4070c5f4e977f68cfc0d61d431b114d0324d90764f042f0035e8e071fe563a5ddb0bcbca69929364f9c6f67b18e02c77c16a7db83859d69a7f2546b7e8f7
6
+ metadata.gz: 21d1522d8f7655123eebba0f2a768c279fdb8907f8333445255113dbf78b45ec64479f92c15053622bda2e222724be7ce903d350c5f677bbd94d9ee2bb2e753d
7
+ data.tar.gz: a84363867c283dea04e32120b71cbb0fe5fa15d58f4e2da242f28144ee59976740b5f78f9e52988ee15738aa9242113bf0fc4d9ae22ae9f73debd2721258ccd9
data/.rspec CHANGED
@@ -1,4 +1,4 @@
1
+ --require spec_helper
1
2
  --format documentation
2
3
  --color
3
- --require spec_helper
4
4
  --order rand
data/Gemfile CHANGED
@@ -2,7 +2,5 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
5
  # Specify your gem's dependencies in wcc-contentful.gemspec
8
6
  gemspec
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://badge.fury.io/rb/wcc-contentful)
2
2
  [![CircleCI](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful)
3
+ [![Coverage Status](https://coveralls.io/repos/github/watermarkchurch/wcc-contentful/badge.svg?branch=master)](https://coveralls.io/github/watermarkchurch/wcc-contentful?branch=master)
3
4
 
4
5
  Full documentation: https://www.rubydoc.info/github/watermarkchurch/wcc-contentful
5
6
 
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "wcc/contentful"
4
+ require 'bundler/setup'
5
+ require 'wcc/contentful'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "wcc/contentful"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/bin/rails CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # This command will automatically be run when you run "rails" with Rails gems
3
5
  # installed from the root of your application.
4
6
 
@@ -12,7 +12,6 @@ require 'wcc/contentful/services'
12
12
  require 'wcc/contentful/simple_client'
13
13
  require 'wcc/contentful/store'
14
14
  require 'wcc/contentful/content_type_indexer'
15
- require 'wcc/contentful/model_validators'
16
15
  require 'wcc/contentful/model'
17
16
  require 'wcc/contentful/model_methods'
18
17
  require 'wcc/contentful/model_singleton_methods'
@@ -26,6 +25,8 @@ module WCC::Contentful
26
25
  class << self
27
26
  # Gets the current configuration, after calling WCC::Contentful.configure
28
27
  attr_reader :configuration
28
+
29
+ attr_reader :types
29
30
  end
30
31
 
31
32
  # Configures the WCC::Contentful gem to talk to a Contentful space.
@@ -52,8 +53,6 @@ module WCC::Contentful
52
53
  def self.init!
53
54
  raise ArgumentError, 'Please first call WCC:Contentful.configure' if configuration.nil?
54
55
 
55
- @mutex ||= Mutex.new
56
-
57
56
  # we want as much as possible the raw JSON from the API so use the management
58
57
  # client if possible
59
58
  client = Services.instance.management_client ||
@@ -75,35 +74,6 @@ module WCC::Contentful
75
74
 
76
75
  WCC::Contentful::ModelBuilder.new(@types).build_models
77
76
 
78
- # Extend all model types w/ validation & extra fields
79
- @types.each_value do |t|
80
- file = File.dirname(__FILE__) + "/contentful/model/#{t.name.underscore}.rb"
81
- require file if File.exist?(file)
82
- end
83
-
84
77
  require_relative 'contentful/client_ext' if defined?(::Contentful)
85
78
  end
86
-
87
- # Runs validations over the content types returned from the Contentful API.
88
- # Validations are configured on predefined model classes using the
89
- # `validate_field` directive. Example:
90
- # validate_field :top_button, :Link, :optional, link_to: 'menuButton'
91
- # This results in a WCC::Contentful::ValidationError
92
- # if the 'topButton' field in the 'menu' content type is not a link.
93
- def self.validate_models!
94
- # Ensure application models are loaded before we validate
95
- Dir[Rails.root.join('app/models/**/*.rb')].each { |file| require file } if defined?(Rails)
96
-
97
- content_types = WCC::Contentful::ModelValidators.transform_content_types_for_validation(
98
- @content_types
99
- )
100
- errors = WCC::Contentful::Model.schema.call(content_types)
101
- raise WCC::Contentful::ValidationError, errors.errors unless errors.success?
102
- end
103
-
104
- # TODO: https://zube.io/watermarkchurch/development/c/2234 init graphql
105
- # def self.init_graphql!
106
- # require 'wcc/contentful/graphql'
107
- # etc...
108
- # end
109
79
  end
@@ -1,39 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WCC::Contentful
4
- # Raised by {WCC::Contentful.validate_models!} if a content type in the space
5
- # does not match the validation defined on the associated model.
6
- class ValidationError < StandardError
7
- Message =
8
- Struct.new(:path, :error) do
9
- def to_s
10
- "#{path}: #{error}"
11
- end
12
- end
13
-
14
- attr_reader :errors
15
-
16
- def initialize(errors)
17
- @errors = ValidationError.join_msg_keys(errors)
18
- super("Content Type Schema from Contentful failed validation!\n #{@errors.join("\n ")}")
19
- end
20
-
21
- # Turns the error messages hash into an array of message structs like:
22
- # menu.fields.name.type: must be equal to String
23
- def self.join_msg_keys(hash)
24
- ret =
25
- hash.map do |k, v|
26
- if v.is_a?(Hash)
27
- msgs = join_msg_keys(v)
28
- msgs.map { |msg| Message.new(k.to_s + '.' + msg.path, msg.error) }
29
- else
30
- v.map { |msg| Message.new(k.to_s, msg) }
31
- end
32
- end
33
- ret.flatten(1)
34
- end
35
- end
36
-
37
4
  class SyncError < StandardError
38
5
  end
39
6
 
@@ -38,7 +38,6 @@
38
38
  # @api Model
39
39
  class WCC::Contentful::Model
40
40
  extend WCC::Contentful::Helpers
41
- extend WCC::Contentful::ModelValidators
42
41
 
43
42
  # The Model base class maintains a registry which is best expressed as a
44
43
  # class var.
@@ -109,7 +109,7 @@ module WCC::Contentful::Store
109
109
  resolve_includes(
110
110
  JSON.parse(row['data']),
111
111
  @options[:include]
112
- )
112
+ )
113
113
  )
114
114
  end
115
115
  arr
@@ -122,7 +122,7 @@ module WCC::Contentful::Store
122
122
  resolve_includes(
123
123
  JSON.parse(row['data']),
124
124
  @options[:include]
125
- )
125
+ )
126
126
  end
127
127
  arr
128
128
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module WCC
4
4
  module Contentful
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0-alpha'
6
6
  end
7
7
  end
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Watermark Dev']
11
11
  spec.email = ['dev@watermark.org']
12
12
 
13
- spec.summary = File.readlines('README.md').join
14
- spec.description = 'Contentful API wrapper library for Watermark apps'
15
- spec.homepage = 'https://github.com/watermarkchurch/wcc-contentful'
13
+ spec.summary = File.readlines(File.expand_path('README.md', __dir__)).join
14
+ spec.description = 'Contentful API wrapper library exposing an ActiveRecord-like interface'
15
+ spec.homepage = 'https://github.com/watermarkchurch/wcc-contentful/wcc-contentful'
16
16
  spec.license = 'MIT'
17
17
 
18
18
  spec.required_ruby_version = '>= 2.3'
@@ -24,12 +24,14 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.require_paths = ['lib']
26
26
 
27
+ spec.add_development_dependency 'coveralls'
27
28
  spec.add_development_dependency 'dotenv', '~> 2.2'
28
29
  spec.add_development_dependency 'httplog', '~> 1.0'
29
30
  spec.add_development_dependency 'rake', '~> 10.0'
30
31
  spec.add_development_dependency 'rspec', '~> 3.0'
31
32
  spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
32
33
  spec.add_development_dependency 'rubocop', '~> 0.52'
34
+ spec.add_development_dependency 'simplecov', '~> 0.16.1'
33
35
  spec.add_development_dependency 'vcr', '~> 4.0'
34
36
  spec.add_development_dependency 'webmock', '~> 3.0'
35
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-contentful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0.pre.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coveralls
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: dotenv
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.52'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.16.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.16.1
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: vcr
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -366,26 +394,17 @@ dependencies:
366
394
  - - "~>"
367
395
  - !ruby/object:Gem::Version
368
396
  version: 0.3.1
369
- description: Contentful API wrapper library for Watermark apps
397
+ description: Contentful API wrapper library exposing an ActiveRecord-like interface
370
398
  email:
371
399
  - dev@watermark.org
372
400
  executables: []
373
401
  extensions: []
374
402
  extra_rdoc_files: []
375
403
  files:
376
- - ".circleci/config.yml"
377
- - ".gitignore"
378
404
  - ".rspec"
379
- - ".rubocop.yml"
380
- - ".rubocop_todo.yml"
381
- - ".travis.yml"
382
- - CHANGELOG.md
383
- - CODE_OF_CONDUCT.md
384
405
  - Gemfile
385
406
  - Guardfile
386
- - LICENSE.txt
387
407
  - README.md
388
- - Rakefile
389
408
  - app/controllers/wcc/contentful/application_controller.rb
390
409
  - app/controllers/wcc/contentful/webhook_controller.rb
391
410
  - app/jobs/wcc/contentful/delayed_sync_job.rb
@@ -396,18 +415,6 @@ files:
396
415
  - bin/setup
397
416
  - config/initializers/mime_types.rb
398
417
  - config/routes.rb
399
- - lib/generators/wcc/USAGE
400
- - lib/generators/wcc/model_generator.rb
401
- - lib/generators/wcc/templates/.keep
402
- - lib/generators/wcc/templates/Procfile
403
- - lib/generators/wcc/templates/contentful_shell_wrapper
404
- - lib/generators/wcc/templates/menu/generated_add_menus.ts
405
- - lib/generators/wcc/templates/menu/models/menu.rb
406
- - lib/generators/wcc/templates/menu/models/menu_button.rb
407
- - lib/generators/wcc/templates/page/generated_add_pages.ts
408
- - lib/generators/wcc/templates/page/models/page.rb
409
- - lib/generators/wcc/templates/release
410
- - lib/generators/wcc/templates/wcc_contentful.rb
411
418
  - lib/wcc/contentful.rb
412
419
  - lib/wcc/contentful/client_ext.rb
413
420
  - lib/wcc/contentful/configuration.rb
@@ -420,16 +427,9 @@ files:
420
427
  - lib/wcc/contentful/helpers.rb
421
428
  - lib/wcc/contentful/indexed_representation.rb
422
429
  - lib/wcc/contentful/model.rb
423
- - lib/wcc/contentful/model/dropdown_menu.rb
424
- - lib/wcc/contentful/model/menu.rb
425
- - lib/wcc/contentful/model/menu_button.rb
426
- - lib/wcc/contentful/model/page.rb
427
- - lib/wcc/contentful/model/redirect.rb
428
430
  - lib/wcc/contentful/model_builder.rb
429
431
  - lib/wcc/contentful/model_methods.rb
430
432
  - lib/wcc/contentful/model_singleton_methods.rb
431
- - lib/wcc/contentful/model_validators.rb
432
- - lib/wcc/contentful/model_validators/dsl.rb
433
433
  - lib/wcc/contentful/rails.rb
434
434
  - lib/wcc/contentful/services.rb
435
435
  - lib/wcc/contentful/simple_client.rb
@@ -446,7 +446,7 @@ files:
446
446
  - lib/wcc/contentful/sys.rb
447
447
  - lib/wcc/contentful/version.rb
448
448
  - wcc-contentful.gemspec
449
- homepage: https://github.com/watermarkchurch/wcc-contentful
449
+ homepage: https://github.com/watermarkchurch/wcc-contentful/wcc-contentful
450
450
  licenses:
451
451
  - MIT
452
452
  metadata: {}
@@ -461,16 +461,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
461
461
  version: '2.3'
462
462
  required_rubygems_version: !ruby/object:Gem::Requirement
463
463
  requirements:
464
- - - ">="
464
+ - - ">"
465
465
  - !ruby/object:Gem::Version
466
- version: '0'
466
+ version: 1.3.1
467
467
  requirements: []
468
468
  rubyforge_project:
469
- rubygems_version: 2.5.2
469
+ rubygems_version: 2.6.11
470
470
  signing_key:
471
471
  specification_version: 4
472
472
  summary: '[![Gem Version](https://badge.fury.io/rb/wcc-contentful.svg)](https://badge.fury.io/rb/wcc-contentful)
473
- [![CircleCI](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful) Full
473
+ [![CircleCI](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful)
474
+ [![Coverage Status](https://coveralls.io/repos/github/watermarkchurch/wcc-contentful/badge.svg?branch=master)](https://coveralls.io/github/watermarkchurch/wcc-contentful?branch=master) Full
474
475
  documentation: https://www.rubydoc.info/github/watermarkchurch/wcc-contentful #
475
476
  WCC::Contentful ## Installation Add this line to your application''s Gemfile: ```ruby
476
477
  gem ''wcc-contentful'', require: ''wcc/contentful/rails'' ``` And then execute: $
data/.circleci/config.yml DELETED
@@ -1,51 +0,0 @@
1
- version: 2
2
- jobs:
3
- build:
4
- docker:
5
- - image: circleci/ruby:2.3.3-node
6
- environment:
7
- RAILS_ENV: test
8
- POSTGRES_CONNECTION: postgresql://ubuntu:@127.0.0.1:5432/circle_ruby_test
9
- - image: postgres:10
10
- environment:
11
- - POSTGRES_USER: ubuntu
12
- - POSTGRES_DB: circle_ruby_test
13
- steps:
14
- - checkout
15
- # Restore bundle cache
16
- - restore_cache:
17
- key: rails-{{ checksum "wcc-contentful.gemspec" }}
18
-
19
- # Bundle install dependencies
20
- - run: bundle install --path /tmp/vendor/bundle
21
-
22
- # Store bundle cache
23
- - save_cache:
24
- key: rails-{{ checksum "wcc-contentful.gemspec" }}
25
- paths:
26
- - /tmp/vendor/bundle
27
-
28
- # run Danger
29
- # - type: shell
30
- # command: |
31
- # bundle exec danger
32
-
33
- # run rubocop
34
- - type: shell
35
- command: |
36
- bundle exec rubocop
37
-
38
- # Run rspec in parallel
39
- - type: shell
40
- command: |
41
- bundle exec rspec --profile 10 \
42
- --format RspecJunitFormatter \
43
- --out test_results/rspec.xml \
44
- --format documentation \
45
- --order rand \
46
- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
47
-
48
- # Save test results for timing analysis
49
- - store_test_results:
50
- path: test_results
51
-
data/.gitignore DELETED
@@ -1,26 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- Gemfile.lock
14
-
15
- # exports and error logs from contentful
16
- contentful-export*
17
- contentful-*-error-log-*
18
-
19
- # User local env
20
- .envrc
21
- .env*
22
-
23
- node_modules
24
-
25
- log/
26
- tmp/