mongoid-cached-json 1.6.0 → 1.7.1

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.
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
4
+ Gem.loaded_specs.key?('ruby-gem-release')
5
+ require_relative '../../script/release'
6
+ require 'ruby-gem-release/rspec'
7
+
8
+ RSpec.describe MongoidCachedJsonRelease do
9
+ include RubyGemRelease::RSpec
10
+
11
+ let(:root) { File.expand_path('../..', __dir__) }
12
+ let(:version_path) { 'lib/mongoid-cached-json/version.rb' }
13
+ let(:fixture_files) do
14
+ %w[
15
+ mongoid-cached-json.gemspec script/release.rb lib/**/*.rb CHANGELOG.md
16
+ CONTRIBUTING.md LICENSE.md README.md UPGRADING.md
17
+ ]
18
+ end
19
+ let(:placeholder) { '* Your contribution here.' }
20
+ let(:note) { '* [#1](https://github.com/mongoid/mongoid-cached-json/pull/1): Added a feature.' }
21
+
22
+ def changelog(notes)
23
+ [
24
+ '### 1.2.0 (Next)', '', notes, placeholder, '',
25
+ '### 1.1.0 (2026/01/01)', '', '* Previous release.', ''
26
+ ].join("\n")
27
+ end
28
+
29
+ def write_version(project, version)
30
+ source = File.read(File.join(root, version_path))
31
+ project.write(version_path, source.sub(/VERSION = (['"])[^'"]+\1/, "VERSION = '#{version}'"))
32
+ end
33
+
34
+ def with_project(notes)
35
+ with_release_project do |project|
36
+ project.environment.merge!(ENV.to_h.slice('MONGOID_VERSION'))
37
+ project.copy_files(path: root, files: fixture_files)
38
+ project.configure_workflow(require: 'script/release', builder: 'MongoidCachedJsonRelease.workflow')
39
+ project.write('CHANGELOG.md', changelog(notes))
40
+ write_version(project, '1.2.0')
41
+ project.commit!
42
+ yield project
43
+ end
44
+ end
45
+
46
+ it 'builds the standard ruby-gem-release workflow' do
47
+ expect(described_class.workflow).to be_a(RubyGemRelease::Workflow::RubyGem)
48
+ end
49
+
50
+ it 'dates the release and prepares the next patch version' do
51
+ with_project(note) do |project|
52
+ project.release!
53
+
54
+ released = project.remote_file('v1.2.0', 'CHANGELOG.md')
55
+ expect(released).to match(%r{\A### 1\.2\.0 \(\d{4}/\d{2}/\d{2}\)\n\n})
56
+ expect(released).to include(note)
57
+ expect(released).not_to include('(Next)', placeholder)
58
+ expect(project.remote_file('v1.2.0', version_path)).to include("VERSION = '1.2.0'")
59
+ pending = project.remote_file('master', 'CHANGELOG.md')
60
+ expect(pending).to start_with("### 1.2.1 (Next)\n\n#{placeholder}\n\n### 1.2.0 (")
61
+ expect(project.remote_file('master', version_path)).to include("VERSION = '1.2.1'")
62
+ expect(project.git('status', '--porcelain')).to be_empty
63
+ end
64
+ end
65
+
66
+ it 'rejects placeholder-only notes without changing files or remote refs' do
67
+ with_project('') do |project|
68
+ original = project.git('rev-parse', 'origin/master')
69
+ project.run_task('release:workflow:capture')
70
+
71
+ expect { project.run_task('release:validate') }.to raise_error(RuntimeError, /no pending changelog notes/)
72
+ expect(project.git('status', '--porcelain')).to be_empty
73
+ expect(project.git('rev-parse', 'origin/master')).to eq(original)
74
+ end
75
+ end
76
+ end
77
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,11 @@
1
+ if ENV['COVERAGE'] == 'true'
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ track_files 'lib/**/*.rb'
5
+ add_filter '/spec/'
6
+ end
7
+ end
8
+
1
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
10
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
11
 
@@ -11,8 +19,22 @@ end
11
19
 
12
20
  Mongoid.configure do |config|
13
21
  config.connect_to('cached_json_test')
22
+ if Mongoid::VERSION.to_i >= 5
23
+ config.clients['default']['hosts'] = [ENV.fetch('MONGODB_HOST', 'localhost:27017')]
24
+ else
25
+ config.sessions['default']['hosts'] = [ENV.fetch('MONGODB_HOST', 'localhost:27017')]
26
+ end
14
27
  end
15
28
 
29
+ if ActiveSupport::VERSION::MAJOR >= 6
30
+ require 'active_support/cache/mem_cache_store'
31
+ else
32
+ require 'active_support/cache/dalli_store'
33
+ end
34
+
35
+ MEMCACHE_STORE = ActiveSupport::VERSION::MAJOR >= 6 ? :mem_cache_store : :dalli_store
36
+ MEMCACHE_STORE_CLASS = ActiveSupport::Cache.lookup_store(MEMCACHE_STORE).class
37
+
16
38
  RSpec.configure do |config|
17
39
  config.raise_errors_for_deprecations!
18
40
  config.after :each do
@@ -4,6 +4,7 @@ class JsonEmployee
4
4
 
5
5
  field :name
6
6
  field :nickname, default: 'My Favorite'
7
+ field :is_left_handed, type: Boolean, default: false
7
8
  belongs_to :json_manager
8
9
 
9
10
  json_fields \
@@ -12,8 +12,13 @@ class JsonManager
12
12
  belongs_to :supervisor, class_name: 'JsonSupervisor', required: false
13
13
  end
14
14
 
15
+ def has_left_handed_employee?
16
+ json_employees.any? { |e| e.is_left_handed? }
17
+ end
18
+
15
19
  json_fields \
16
20
  name: {},
17
21
  ssn: { properties: :all },
18
- employees: { type: :reference, definition: :json_employees }
22
+ employees: { type: :reference, definition: :json_employees },
23
+ has_left_handed_employee: { type: :reference, definition: :has_left_handed_employee? }
19
24
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-cached-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Windsor
8
8
  - Daniel Doubrovkine
9
9
  - Frank Macreery
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-06-01 00:00:00.000000000 Z
13
+ date: 2026-11-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mongoid
@@ -26,23 +26,31 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '3.0'
29
- description:
29
+ description:
30
30
  email: dblock@dblock.org
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".github/workflows/danger-comment.yml"
36
+ - ".github/workflows/danger.yml"
37
+ - ".github/workflows/lint.yml"
38
+ - ".github/workflows/release.yml"
39
+ - ".github/workflows/test.yml"
35
40
  - ".gitignore"
36
41
  - ".rspec"
37
42
  - ".rubocop.yml"
38
43
  - ".rubocop_todo.yml"
39
- - ".travis.yml"
44
+ - ".spellcheck.txt"
40
45
  - CHANGELOG.md
41
46
  - CONTRIBUTING.md
47
+ - Dangerfile
42
48
  - Gemfile
43
49
  - LICENSE.md
44
50
  - README.md
51
+ - RELEASING.md
45
52
  - Rakefile
53
+ - UPGRADING.md
46
54
  - lib/mongoid-cached-json.rb
47
55
  - lib/mongoid-cached-json/array.rb
48
56
  - lib/mongoid-cached-json/cached_json.rb
@@ -52,13 +60,20 @@ files:
52
60
  - lib/mongoid-cached-json/mongoid_criteria.rb
53
61
  - lib/mongoid-cached-json/version.rb
54
62
  - mongoid-cached-json.gemspec
63
+ - script/release.rb
64
+ - spec/all_fields_spec.rb
55
65
  - spec/array_spec.rb
56
66
  - spec/benchmark_spec.rb
67
+ - spec/cache_version_spec.rb
57
68
  - spec/cached_json_spec.rb
58
69
  - spec/config_spec.rb
70
+ - spec/coverage_spec.rb
59
71
  - spec/dalli_spec.rb
72
+ - spec/field_cache_spec.rb
60
73
  - spec/hash_spec.rb
74
+ - spec/model_cache_spec.rb
61
75
  - spec/mongoid_criteria_spec.rb
76
+ - spec/release/release_spec.rb
62
77
  - spec/spec_helper.rb
63
78
  - spec/support/awesome_artwork.rb
64
79
  - spec/support/awesome_image.rb
@@ -91,7 +106,7 @@ homepage: http://github.com/mongoid/mongoid-cached-json
91
106
  licenses:
92
107
  - MIT
93
108
  metadata: {}
94
- post_install_message:
109
+ post_install_message:
95
110
  rdoc_options: []
96
111
  require_paths:
97
112
  - lib
@@ -106,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
121
  - !ruby/object:Gem::Version
107
122
  version: 1.3.6
108
123
  requirements: []
109
- rubygems_version: 3.0.3
110
- signing_key:
124
+ rubygems_version: 3.5.22
125
+ signing_key:
111
126
  specification_version: 4
112
127
  summary: Cached-json is a DSL for describing JSON representations of Mongoid models.
113
128
  test_files: []
data/.travis.yml DELETED
@@ -1,40 +0,0 @@
1
- sudo: false
2
-
3
- script: bundle exec rake spec
4
-
5
- services:
6
- - mongodb
7
- - memcache
8
-
9
- rvm:
10
- - 2.0.0
11
- - 2.1.10
12
- - 2.2.10
13
- - 2.3.7
14
- - 2.4.6
15
- - 2.5.5
16
- - 2.6.3
17
-
18
- env:
19
- - MONGOID_VERSION=3
20
- - MONGOID_VERSION=4
21
- - MONGOID_VERSION=5
22
- - MONGOID_VERSION=6
23
- - MONGOID_VERSION=7
24
-
25
- cache: bundler
26
-
27
- matrix:
28
- include:
29
- - rvm: 2.6.3
30
- env: RUBOCOP=true
31
- script: bundle exec rake rubocop
32
- exclude:
33
- - rvm: 2.0.0
34
- env: MONGOID_VERSION=6
35
- - rvm: 2.1.10
36
- env: MONGOID_VERSION=6
37
- - rvm: 2.0.0
38
- env: MONGOID_VERSION=7
39
- - rvm: 2.1.10
40
- env: MONGOID_VERSION=7