jsonb_accessor 1.3.8 → 1.4

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: fc33a0dd7ef12bf1804fd787f0f8cfa8e8ddc7ee3973c6dd0fb1a172a6d3342c
4
- data.tar.gz: 2defa503de6becb46bc44be77e52ba2f42073e33cb142e5ac07f6ca396f6c38c
3
+ metadata.gz: 6e76b0bf2b54d9887af7fd350b39c958817b7c5633513962f1fb6620f397e017
4
+ data.tar.gz: 862e5b32701dcccb72e4cc722671c907072414bc8dc2a747a0df84650f79e623
5
5
  SHA512:
6
- metadata.gz: dd0b9dfc9b5d595c5c3c03ee7eb75050eb3755329010c1f7ad4df81f466f4b19717aa4ab4ef628fc49a71dc3134f95bb64202b993fc18b1413c0267bbbe37221
7
- data.tar.gz: 762df4f22bc02d367ee20cee9056deabcdc0782a1afeb3592a992227cbcedb8ec9dec6d9aa38d998fe61fa9f42f53c79dd1036426d925d3e3568f39f0e82bf6b
6
+ metadata.gz: '08f23e84686da1f3ae4c475e159ea2815323cc6f08a8549890f42b3e7a044c0f0867a5c70171084633f9feb898e23b67bc612672b5276fb256dd48adb3d279cd'
7
+ data.tar.gz: 834b8130f8046c965131ca88049b39e1a675ba02b4d4637b622db0b2da84e1b556090482697929e665eb03d3eb867da95fc31171d9c9b2b8669f3449975b2a95
@@ -24,7 +24,7 @@ jobs:
24
24
  needs: lint
25
25
  services:
26
26
  db:
27
- image: postgres:9.4
27
+ image: postgres
28
28
  env:
29
29
  POSTGRES_HOST_AUTH_METHOD: trust
30
30
  POSTGRES_DB: jsonb_accessor
@@ -36,99 +36,40 @@ jobs:
36
36
  fail-fast: false
37
37
  matrix:
38
38
  include:
39
- - gemfile: activerecord_5.0.0
40
- ruby: '2.4'
41
-
42
- - gemfile: activerecord_5.1.0
43
- ruby: '2.4'
44
-
45
- - gemfile: activerecord_5.2.0
46
- ruby: '2.4'
47
-
48
- - gemfile: activerecord_5.0.0
49
- ruby: '2.5'
50
-
51
- - gemfile: activerecord_5.1.0
52
- ruby: '2.5'
53
-
54
- - gemfile: activerecord_5.2.0
55
- ruby: '2.5'
56
-
57
- - gemfile: activerecord_6.0.0
58
- ruby: '2.5'
59
-
60
- - gemfile: activerecord_6.1.0
61
- ruby: '2.5'
62
-
63
- - gemfile: activerecord_5.0.0
64
- ruby: '2.6'
65
-
66
- - gemfile: activerecord_5.1.0
67
- ruby: '2.6'
68
-
69
- - gemfile: activerecord_5.2.0
70
- ruby: '2.6'
71
-
72
- - gemfile: activerecord_6.0.0
73
- ruby: '2.6'
74
-
75
- - gemfile: activerecord_6.1.0
76
- ruby: '2.6'
77
-
78
- - gemfile: activerecord_5.0.0
79
- ruby: '2.7'
80
-
81
- - gemfile: activerecord_5.1.0
82
- ruby: '2.7'
83
-
84
- - gemfile: activerecord_5.2.0
85
- ruby: '2.7'
86
-
87
- - gemfile: activerecord_6.0.0
88
- ruby: '2.7'
89
-
90
- - gemfile: activerecord_6.1.0
91
- ruby: '2.7'
92
-
93
- - gemfile: activerecord_7.0.1
94
- ruby: '2.7'
95
-
96
- - gemfile: activerecord_6.1.0
39
+ - gemfile: activerecord_6.1
97
40
  ruby: '3.0'
98
41
 
99
- - gemfile: activerecord_6.1.0
42
+ - gemfile: activerecord_6.1
100
43
  ruby: '3.1'
101
44
 
102
- - gemfile: activerecord_6.1.0
45
+ - gemfile: activerecord_6.1
103
46
  ruby: '3.2'
104
47
 
105
- - gemfile: activerecord_7.0.1
48
+ - gemfile: activerecord_7.0
106
49
  ruby: '3.0'
107
50
 
108
- - gemfile: activerecord_7.0.1
51
+ - gemfile: activerecord_7.0
109
52
  ruby: '3.1'
110
53
 
111
- - gemfile: activerecord_7.0.1
54
+ - gemfile: activerecord_7.0
112
55
  ruby: '3.2'
113
56
 
114
- - gemfile: activerecord_5.1.0
115
- ruby: 'jruby-9.3'
116
-
117
- - gemfile: activerecord_5.2.0
118
- ruby: 'jruby-9.3'
57
+ - gemfile: activerecord_7.1
58
+ ruby: '3.0'
119
59
 
120
- - gemfile: activerecord_6.0.0
121
- ruby: 'jruby-9.3'
60
+ - gemfile: activerecord_7.1
61
+ ruby: '3.1'
122
62
 
123
- - gemfile: activerecord_6.1.0
124
- ruby: 'jruby-9.3'
63
+ - gemfile: activerecord_7.1
64
+ ruby: '3.2'
125
65
 
126
- # waiting for https://github.com/jruby/activerecord-jdbc-adapter/issues/1125 to be addressed
127
- # - gemfile: activerecord_7.0.1
128
- # ruby: 'jruby-9.4'
66
+ - gemfile: activerecord_7.0
67
+ ruby: 'jruby-9.4'
129
68
 
130
69
  name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
131
70
 
71
+ env:
72
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
132
73
  steps:
133
74
  - uses: actions/checkout@v3
134
75
 
@@ -140,8 +81,7 @@ jobs:
140
81
 
141
82
  - name: Bundle install
142
83
  run: |
143
- bundle config set gemfile "${GITHUB_WORKSPACE}/gemfiles/${{ matrix.gemfile }}.gemfile"
144
- bundle install --jobs 4 --retry 3
84
+ bundle install
145
85
 
146
86
  - name: Setup DB
147
87
  run: |
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
data/Appraisals CHANGED
@@ -1,25 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "activerecord-5.0.0" do
4
- gem "activerecord", "~> 5.0.0"
5
- end
6
-
7
- appraise "activerecord-5.1.0" do
8
- gem "activerecord", "~> 5.1.3"
9
- end
10
-
11
- appraise "activerecord-5.2.0" do
12
- gem "activerecord", "~> 5.2.8"
13
- end
14
-
15
- appraise "activerecord-6.0.0" do
16
- gem "activerecord", "~> 6.0.6"
3
+ appraise "activerecord-6.1" do
4
+ gem "activerecord", "~> 6.1"
17
5
  end
18
6
 
19
- appraise "activerecord-6.1.0" do
20
- gem "activerecord", "~> 6.1"
7
+ appraise "activerecord-7.0" do
8
+ gem "activerecord", "~> 7.0.8"
21
9
  end
22
10
 
23
- appraise "activerecord-7.0.1" do
24
- gem "activerecord", "~> 7.0.1"
11
+ appraise "activerecord-7.1" do
12
+ gem "activerecord", "~> 7.1"
25
13
  end
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Changelog
2
2
  ## [Unreleased]
3
3
 
4
+ ## [1.4] - 2023-10-15
5
+ ### Breaking change
6
+ - `jsonb_accessor` dropped support for Ruby 2 and Rails versions lower than 6.1. Support for ActiveRecord::Enum was also
7
+ dropped because ActiveRecord 7.1 now requires each enum field to be backed by a database column. Enums will still work
8
+ when using AR versions lower than 7.1. This is a limitation of Rails, not of this gem.
9
+
10
+ ### Fixed
11
+
12
+ - Bug fix: An array of datetimes previously caused an error. https://github.com/madeintandem/jsonb_accessor/pull/169. Thanks @bekicot.
13
+ - Rails 7.1 is officially supported and tested against.
14
+
15
+ ## [1.3.10] - 2023-05-30
16
+ ### No changes
17
+ A new release was necessary to fix the corrupted 1.3.9 Java release on RubyGems.
18
+
19
+ ## [1.3.9] - 2023-05-30
20
+ ### No changes
21
+ A new release was necessary to fix the corrupted 1.3.8 Java release on RubyGems.
22
+
4
23
  ## [1.3.8] - 2023-05-29
5
24
  ### Fixes
6
25
 
data/Dockerfile CHANGED
@@ -1,12 +1,12 @@
1
- ARG RUBY_VERSION=latest
2
- FROM ruby:${RUBY_VERSION}
1
+ ARG RUBY_VERSION
2
+ ARG RUBY_PLATFORM
3
+ FROM ${RUBY_PLATFORM}:${RUBY_VERSION}
3
4
 
4
- WORKDIR /usr/src/app
5
+ RUN apt-get update && apt-get install -y --no-install-recommends git
5
6
 
6
- RUN mkdir -p lib/jsonb_accessor
7
- COPY lib/jsonb_accessor/version.rb ./lib/jsonb_accessor/
8
- COPY *.gemspec Gemfile* ./
7
+ WORKDIR /usr/src/app
9
8
 
9
+ COPY lib/jsonb_accessor/version.rb ./lib/jsonb_accessor/version.rb
10
+ COPY jsonb_accessor.gemspec Gemfile ./
10
11
  RUN bundle install
11
-
12
- COPY . .
12
+ COPY . ./
data/Makefile ADDED
@@ -0,0 +1,7 @@
1
+ build-gem:
2
+ @docker build --build-arg RUBY_PLATFORM=ruby --build-arg RUBY_VERSION=3.2.2 -t jsonb_accessor-ruby:3.2.2 .
3
+ @docker run --rm -v $(PWD):/usr/src/app -w /usr/src/app jsonb_accessor-ruby:3.2.2 gem build
4
+
5
+ build-gem-java:
6
+ @docker build --build-arg RUBY_PLATFORM=jruby --build-arg RUBY_VERSION=9.4.2-jdk -t jsonb_accessor-jruby:9.4.2-jdk .
7
+ @docker run --rm -v $(PWD):/usr/src/app -w /usr/src/app jsonb_accessor-jruby:9.4.2-jdk gem build --platform java
data/README.md CHANGED
@@ -318,7 +318,8 @@ Because this gem promotes attributes nested into the JSON column to first level
318
318
 
319
319
  ## Dependencies
320
320
 
321
- - ActiveRecord >= 5.0
321
+ - Ruby > 3. Lower versions are not tested.
322
+ - ActiveRecord >= 6.1
322
323
  - Postgres >= 9.4 (in order to use the [jsonb column type](http://www.postgresql.org/docs/9.4/static/datatype-json.html)).
323
324
 
324
325
  ## Upgrading
data/bin/console CHANGED
@@ -7,7 +7,7 @@ require "rspec"
7
7
  require File.expand_path("../spec/spec_helper.rb", __dir__)
8
8
 
9
9
  dbconfig = YAML.safe_load(ERB.new(File.read(File.join("db", "config.yml"))).result, aliases: true)
10
- ActiveRecord::Base.establish_connection(dbconfig["development"])
10
+ ActiveRecord::Base.establish_connection(dbconfig["test"])
11
11
 
12
12
  # rubocop:disable Lint/UselessAssignment
13
13
  x = Product.new
data/db/config.yml CHANGED
@@ -2,7 +2,7 @@ default: &default
2
2
  adapter: postgresql
3
3
  database: jsonb_accessor
4
4
  host: <%= ENV.fetch("DATABASE_HOST") { "127.0.0.1" } %>
5
- user: postgres
5
+ username: <%= ENV.fetch("DATABASE_USER") { "postgres" } %>
6
6
 
7
7
  test:
8
8
  <<: *default
data/db/schema.rb CHANGED
@@ -1,18 +1,16 @@
1
- # frozen_string_literal: true
2
-
3
1
  # This file is auto-generated from the current state of the database. Instead
4
2
  # of editing this file, please use the migrations feature of Active Record to
5
3
  # incrementally modify your database, and then regenerate this schema definition.
6
4
  #
7
- # Note that this schema.rb definition is the authoritative source for your
8
- # database schema. If you need to create the application database on another
9
- # system, you should be using db:schema:load, not running all the migrations
10
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
11
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
12
10
  #
13
11
  # It's strongly recommended that you check this file into your version control system.
14
12
 
15
- ActiveRecord::Schema.define(version: 20_150_407_031_737) do
13
+ ActiveRecord::Schema.define(version: 2015_04_07_031737) do
16
14
  # These are extensions that must be enabled in order to support this database
17
15
  enable_extension "plpgsql"
18
16
 
@@ -30,7 +28,8 @@ ActiveRecord::Schema.define(version: 20_150_407_031_737) do
30
28
  t.float "float_type"
31
29
  t.time "time_type"
32
30
  t.date "date_type"
33
- t.datetime "datetime_type"
31
+ t.datetime "datetime_type", precision: nil
34
32
  t.decimal "decimal_type"
35
33
  end
34
+
36
35
  end
data/docker-compose.yml CHANGED
@@ -6,7 +6,8 @@ services:
6
6
  - DATABASE_HOST=postgres
7
7
  build:
8
8
  args:
9
- - RUBY_VERSION=${RUBY_VERSION:-3.2.1}
9
+ - RUBY_VERSION=${RUBY_VERSION:-3.2.2}
10
+ - RUBY_PLATFORM=${RUBY_PLATFORM:-ruby}
10
11
  context: .
11
12
  volumes:
12
13
  - '.:/usr/src/app'
@@ -15,7 +16,7 @@ services:
15
16
 
16
17
 
17
18
  postgres:
18
- image: postgres:12
19
+ image: postgres
19
20
  environment:
20
21
  - POSTGRES_HOST_AUTH_METHOD=trust
21
22
  - POSTGRES_DB=jsonb_accessor
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0"
5
+ gem "activerecord", "~> 7.0.8"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.3"
5
+ gem "activerecord", "~> 7.1"
6
6
 
7
7
  gemspec path: "../"
@@ -17,24 +17,24 @@ Gem::Specification.new do |spec|
17
17
  spec.description = "Adds typed jsonb backed fields to your ActiveRecord models."
18
18
  spec.homepage = "https://github.com/devmynd/jsonb_accessor"
19
19
  spec.license = "MIT"
20
- spec.required_ruby_version = ">= 2"
20
+ spec.required_ruby_version = ">= 3"
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(/png\z/) }
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency "activerecord", ">= 5.0"
28
- spec.add_dependency "activesupport", ">= 5.0"
27
+ spec.add_dependency "activerecord", ">= 6.1"
28
+ spec.add_dependency "activesupport", ">= 6.1"
29
29
  if is_java
30
30
  spec.add_dependency "activerecord-jdbcpostgresql-adapter", ">= 50.0"
31
31
  else
32
32
  spec.add_dependency "pg", ">= 0.18.1"
33
33
  end
34
34
 
35
- spec.add_development_dependency "appraisal", "~> 2.2.0"
35
+ spec.add_development_dependency "appraisal", "~> 2.5"
36
36
  spec.add_development_dependency "awesome_print"
37
- spec.add_development_dependency "database_cleaner", "~> 1.6.0"
37
+ spec.add_development_dependency "database_cleaner-active_record", "~> 2.1"
38
38
  spec.add_development_dependency "pry"
39
39
  spec.add_development_dependency "pry-doc"
40
40
  spec.add_development_dependency "pry-nav"
@@ -24,14 +24,23 @@ module JsonbAccessor
24
24
  return value if value.blank?
25
25
 
26
26
  if attribute_type == :datetime
27
- value = if active_record_default_timezone == :utc
28
- Time.find_zone("UTC").parse(value).in_time_zone
27
+ value = if value.is_a?(Array)
28
+ value.map { |v| parse_date(v) }
29
29
  else
30
- Time.zone.parse(value)
30
+ parse_date(value)
31
31
  end
32
32
  end
33
33
 
34
34
  value
35
35
  end
36
+
37
+ # Parse datetime based on the configured default_timezone
38
+ def parse_date(datetime)
39
+ if active_record_default_timezone == :utc
40
+ Time.find_zone("UTC").parse(datetime).in_time_zone
41
+ else
42
+ Time.zone.parse(datetime)
43
+ end
44
+ end
36
45
  end
37
46
  end
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonbAccessor
4
- VERSION = "1.3.8"
4
+ VERSION = "1.4"
5
+
6
+ def self.enum_support?
7
+ # From AR 7.1 on, enums require a database column.
8
+ Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("7.1")
9
+ end
5
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonb_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crismali
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-05-29 00:00:00.000000000 Z
13
+ date: 2023-10-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.0'
21
+ version: '6.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '5.0'
28
+ version: '6.1'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: activesupport
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '5.0'
35
+ version: '6.1'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '5.0'
42
+ version: '6.1'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: pg
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 2.2.0
63
+ version: '2.5'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 2.2.0
70
+ version: '2.5'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: awesome_print
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -83,19 +83,19 @@ dependencies:
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
- name: database_cleaner
86
+ name: database_cleaner-active_record
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 1.6.0
91
+ version: '2.1'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 1.6.0
98
+ version: '2.1'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: pry
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -214,6 +214,7 @@ files:
214
214
  - Dockerfile
215
215
  - Gemfile
216
216
  - LICENSE.txt
217
+ - Makefile
217
218
  - README.md
218
219
  - Rakefile
219
220
  - UPGRADE_GUIDE.md
@@ -223,12 +224,9 @@ files:
223
224
  - db/migrate/20150407031737_set_up_testing_db.rb
224
225
  - db/schema.rb
225
226
  - docker-compose.yml
226
- - gemfiles/activerecord_5.0.0.gemfile
227
- - gemfiles/activerecord_5.1.0.gemfile
228
- - gemfiles/activerecord_5.2.0.gemfile
229
- - gemfiles/activerecord_6.0.0.gemfile
230
- - gemfiles/activerecord_6.1.0.gemfile
231
- - gemfiles/activerecord_7.0.1.gemfile
227
+ - gemfiles/activerecord_6.1.gemfile
228
+ - gemfiles/activerecord_7.0.gemfile
229
+ - gemfiles/activerecord_7.1.gemfile
232
230
  - jsonb_accessor.gemspec
233
231
  - lib/jsonb_accessor.rb
234
232
  - lib/jsonb_accessor/attribute_query_methods.rb
@@ -249,14 +247,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
247
  requirements:
250
248
  - - ">="
251
249
  - !ruby/object:Gem::Version
252
- version: '2'
250
+ version: '3'
253
251
  required_rubygems_version: !ruby/object:Gem::Requirement
254
252
  requirements:
255
253
  - - ">="
256
254
  - !ruby/object:Gem::Version
257
255
  version: '0'
258
256
  requirements: []
259
- rubygems_version: 3.4.6
257
+ rubygems_version: 3.4.10
260
258
  signing_key:
261
259
  specification_version: 4
262
260
  summary: Adds typed jsonb backed fields to your ActiveRecord models.
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.2.8"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.0.6"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 7.0.1"
6
-
7
- gemspec path: "../"