clowne 1.3.0 → 1.4.0

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: 3f0d72961e8144605b8f0dbd7953161f17ec4c585c67b3e5bde80d84b3664f1b
4
- data.tar.gz: 5981d937f60d54993ab6bee595598dbc0b52ac99e38e29ef84f5007661929c5b
3
+ metadata.gz: 78d20c6640a5bbd59c580555212a4bc17efc623ed2e3e5f0f3b2a8c343e8a7a1
4
+ data.tar.gz: da533b87dff544ca0ed704507918595bcbdee69145c5c5d4cde7a8ada0333ee5
5
5
  SHA512:
6
- metadata.gz: ecd7010d94b67e2f0c9f19d2dbde4b6b302481156be2657199d6d9fa98c142807f1b006ddb306a2fd8cb3b2d72b3fd4e1708e34c5fe3541ddd0b2320b5e63112
7
- data.tar.gz: d56c783b4eed7af9ac5e478cfc2b2154b74644ea03fcc84f9fb7bd54c4e2ac8505355bd0ba0405c96255046232f3eee12c83671ef64173f29097ab859a9e428f
6
+ metadata.gz: cdcca7b527663200dca117c21ea0ab89b4bc1e642329b42bb3e084e3cec449925987c9b64deb15032f387bb8e171735ef088728c4768b1d0adf09d81c332868b
7
+ data.tar.gz: 65052b5da9fd8f9e31782b0bffe3c9c292da95979ccc4546e8b2e660c2c86bee3caef55b4a9c5f9c5c6bfa23c5d1efdc1d9df4a3f749089ed3a099ccc88e0c25
@@ -0,0 +1,33 @@
1
+ name: JRuby Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rspec-jruby:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ BUNDLE_JOBS: 4
14
+ BUNDLE_RETRY: 3
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/cache@v1
18
+ with:
19
+ path: /home/runner/bundle
20
+ key: bundle-${{ hashFiles('**/gemfiles/jruby.gemfile') }}-${{ hashFiles('**/*.gemspec') }}
21
+ restore-keys: |
22
+ bundle-
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: jruby-9.2.15.0
26
+ - name: Bundle install
27
+ run: |
28
+ bundle config path /home/runner/bundle
29
+ bundle config --global gemfile gemfiles/jruby.gemfile
30
+ bundle install
31
+ - name: Run RSpec
32
+ run: |
33
+ bundle exec rspec --force-color
@@ -0,0 +1,35 @@
1
+ name: TruffleRuby Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rspec-truffle:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ BUNDLE_JOBS: 4
14
+ BUNDLE_RETRY: 3
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/cache@v1
18
+ with:
19
+ path: /home/runner/bundle
20
+ key: bundle-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}
21
+ restore-keys: |
22
+ bundle-
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: truffleruby-head
26
+ bundler: 2.2.15
27
+ bundler-cache: true
28
+
29
+ - name: Bundle install
30
+ run: |
31
+ bundle config path /home/runner/bundle
32
+ bundle install
33
+ - name: Run RSpec
34
+ run: |
35
+ bundle exec rspec --force-color
@@ -0,0 +1,51 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rspec:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ BUNDLE_JOBS: 4
14
+ BUNDLE_RETRY: 3
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [2.7]
19
+ gemfile: ["gemfiles/railsmaster.gemfile"]
20
+ include:
21
+ - ruby: ruby-head
22
+ gemfile: "gemfiles/railsmaster.gemfile"
23
+ - ruby: 3.0
24
+ gemfile: "Gemfile"
25
+ - ruby: 2.7
26
+ gemfile: "Gemfile"
27
+ - ruby: 2.6.5
28
+ gemfile: "Gemfile"
29
+ - ruby: 2.5.7
30
+ gemfile: "gemfiles/activerecord42.gemfile"
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - uses: actions/cache@v1
34
+ with:
35
+ path: /home/runner/bundle
36
+ key: bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles(matrix.gemfile) }}-${{ hashFiles('**/*.gemspec') }}
37
+ restore-keys: |
38
+ bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-
39
+ - uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ - name: Bundle install
43
+ run: |
44
+ bundle config path /home/runner/bundle
45
+ bundle config --global gemfile ${{ matrix.gemfile }}
46
+ bundle install
47
+ bundle update
48
+ - name: Run RSpec
49
+ run: |
50
+ bundle exec rspec --force-color
51
+
@@ -0,0 +1,20 @@
1
+ name: Lint Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.7
17
+ - name: Lint Ruby code with RuboCop
18
+ run: |
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  require:
2
2
  # add after moving docs to another tool
3
- - 'standard/cop/semantic_blocks'
3
+ - 'standard/cop/block_single_line_braces'
4
4
  - 'rubocop-md'
5
5
 
6
6
  inherit_gem:
@@ -14,15 +14,16 @@ AllCops:
14
14
  - 'gemfiles/vendor/**/*'
15
15
  - 'clowne.gemspec'
16
16
  DisplayCopNames: true
17
- TargetRubyVersion: 2.5
17
+ TargetRubyVersion: 2.7
18
18
 
19
19
  Markdown:
20
20
  WarnInvalid: true
21
21
 
22
- Standard/SemanticBlocks:
23
- Enabled: false
24
-
25
22
  Lint/Void:
26
23
  Exclude:
27
24
  - 'docs/README.md'
28
25
  - 'README.md'
26
+
27
+ Lint/ConstantDefinitionInBlock:
28
+ Exclude:
29
+ - 'spec/**/*'
data/CHANGELOG.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # Change log
2
2
 
3
- ## 1.1.0 (2019-03-20)
3
+ ## 1.3.0 (2021-05-11)
4
+
5
+ - Added Ruby 3.0 support ([@pomartel][])
6
+ - Fixed Ruby 2.7 warnings ([@mpestov][])
7
+
8
+ ## 1.2.0 (2020-07-03)
4
9
 
10
+ - Added TruffleRuby support ([@ssnickolay][])
11
+ - Added Ruby 2.7 support ([@Sub-Xaero][])
12
+ - Fixed JRuby support
13
+ - Fixed all dependencies vulnerabilities
14
+ - Documents moved to Docsify engine ([@ssnickolay][])
15
+
16
+ ## 1.1.0 (2019-03-20)
5
17
 
6
18
  - Add `after_clone` declaration. ([@elardo][])
7
19
  - Add opporotunity to include belongs_to association for active_record adapter. ([@madding][])
@@ -44,3 +56,6 @@ See [migration guide](https://clowne.evilmartians.io/docs/from_v02_to_v10.html)
44
56
  [@ssnickolay]: https://github.com/ssnickolay
45
57
  [@elardo]: https://github.com/elardo
46
58
  [@madding]: https://github.com/madding
59
+ [@pomartel]: https://github.com/pomartel
60
+ [@mpestov]: https://github.com/mpestov
61
+ [@Sub-Xaero]: https://github.com/Sub-Xaero
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  gem "pry-byebug", platform: :mri
7
7
 
8
- gem "sqlite3", "~> 1.4.1", platform: :ruby
8
+ gem "sqlite3", "~> 1.4.2", platform: :ruby
9
9
  gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platform: :jruby
10
10
  gem "jdbc-sqlite3", platform: :jruby
11
11
 
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/clowne.svg)](https://badge.fury.io/rb/clowne)
2
- [![Build Status](https://travis-ci.org/clowne-rb/clowne.svg?branch=master)](https://travis-ci.org/clowne-rb/clowne)
3
- [![Test Coverage](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/test_coverage)](https://codeclimate.com/github/clowne-rb/clowne/test_coverage)
2
+ [![Build Status](https://github.com/clowne-rb/clowne/actions/workflows/rspec.yml/badge.svg?branch=master)](https://github.com/clowne-rb/clowne/actions?query=branch%3Amaster+)
4
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/maintainability)](https://codeclimate.com/github/clowne-rb/clowne/maintainability)
5
4
  [![Docs](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://clowne.evilmartians.io)
6
5
 
data/clowne.gemspec CHANGED
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
31
31
  spec.add_development_dependency 'factory_bot', '~> 5'
32
- spec.add_development_dependency 'rubocop', '~> 0.75.0'
33
- spec.add_development_dependency 'rubocop-md', '~> 0.3.0'
34
- spec.add_development_dependency 'rubocop-rspec', '~> 1.36.0'
35
- spec.add_development_dependency 'standard', '~> 0.1.5'
32
+ spec.add_development_dependency 'rubocop', '~> 1.22'
33
+ spec.add_development_dependency 'rubocop-md', '~> 1'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.5'
35
+ spec.add_development_dependency 'standard', '~> 1.4.0'
36
36
  end
data/docs/.rubocop.yml CHANGED
@@ -8,11 +8,8 @@ Lint/Void:
8
8
  Metrics/AbcSize:
9
9
  Enabled: false
10
10
 
11
- Standard/SemanticBlocks:
12
- Enabled: false
13
-
14
11
  Metrics/BlockLength:
15
12
  Enabled: false
16
13
 
17
- Metrics/LineLength:
14
+ Layout/LineLength:
18
15
  Enabled: false
data/docs/parameters.md CHANGED
@@ -75,7 +75,7 @@ class UserCloner < Clowne::Cloner
75
75
  include_association :profile, params: Proc.new do |params, user|
76
76
  {
77
77
  name: params[:profile][:name],
78
- email: user.email,
78
+ email: user.email
79
79
  }
80
80
  end
81
81
  end
@@ -5,7 +5,6 @@ module Clowne
5
5
  class ActiveRecord
6
6
  module Associations
7
7
  class BelongsTo < Base
8
- # rubocop: disable Metrics/MethodLength
9
8
  def call(record)
10
9
  child = association
11
10
  return record unless child
@@ -5,7 +5,6 @@ module Clowne
5
5
  class ActiveRecord
6
6
  module Associations
7
7
  class HasOne < Base
8
- # rubocop: disable Metrics/MethodLength
9
8
  def call(record)
10
9
  child = association
11
10
  return record unless child
@@ -15,7 +15,7 @@ module Clowne
15
15
  belongs_to: BelongsTo,
16
16
  has_one: HasOne,
17
17
  has_many: HasMany,
18
- has_and_belongs_to_many: HABTM,
18
+ has_and_belongs_to_many: HABTM
19
19
  }.freeze
20
20
 
21
21
  # Returns an association cloner class for reflection
@@ -8,7 +8,6 @@ module Clowne
8
8
 
9
9
  class Association
10
10
  class << self
11
- # rubocop: disable Metrics/ParameterLists
12
11
  def call(source, record, declaration, adapter:, params:, **_options)
13
12
  reflection = source.class.reflections[declaration.name.to_s]
14
13
 
@@ -17,7 +17,7 @@ module Clowne
17
17
 
18
18
  class << self
19
19
  # Duplicate record and remember record <-> clone relationship in operation
20
- # Cab be overrided in special adapter
20
+ # Can be overrided in special adapter
21
21
  # +record+:: Instance of record (ActiveRecord or Sequel)
22
22
  def dup_record(record)
23
23
  record.dup.tap do |clone|
@@ -27,7 +27,7 @@ module Clowne
27
27
  end
28
28
 
29
29
  # Operation class which using for cloning
30
- # Cab be overrided in special adapter
30
+ # Can be overrided in special adapter
31
31
  def operation_class
32
32
  Clowne::Utils::Operation
33
33
  end
@@ -13,7 +13,7 @@ module Clowne
13
13
  SEQUEL_2_CLONER = {
14
14
  one_to_one: OneToOne,
15
15
  one_to_many: OneToMany,
16
- many_to_many: ManyToMany,
16
+ many_to_many: ManyToMany
17
17
  }.freeze
18
18
 
19
19
  # Returns an association cloner class for reflection
@@ -6,7 +6,6 @@ module Clowne
6
6
  module Resolvers
7
7
  class Association
8
8
  class << self
9
- # rubocop: disable Metrics/ParameterLists
10
9
  def call(source, record, declaration, adapter:, params:, **_options)
11
10
  with_clonable(source, record, declaration) do
12
11
  reflection = source.class.association_reflections[declaration.name.to_sym]
data/lib/clowne/cloner.rb CHANGED
@@ -8,6 +8,7 @@ require "clowne/utils/operation"
8
8
 
9
9
  module Clowne # :nodoc: all
10
10
  class UnprocessableSourceError < StandardError; end
11
+
11
12
  class ConfigurationError < StandardError; end
12
13
 
13
14
  class Cloner
@@ -43,7 +44,6 @@ module Clowne # :nodoc: all
43
44
  @traits[name].extend_with(block)
44
45
  end
45
46
 
46
- # rubocop: disable Metrics/AbcSize, Metrics/MethodLength
47
47
  def call(object, **options, &block)
48
48
  raise(UnprocessableSourceError, "Nil is not cloneable object") if object.nil?
49
49
 
@@ -17,7 +17,7 @@ module Clowne
17
17
  @compiled = compile
18
18
  end
19
19
 
20
- alias declarations compiled
20
+ alias_method :declarations, :compiled
21
21
 
22
22
  def dup
23
23
  self.class.new.tap do |duped|
@@ -8,7 +8,7 @@ module Clowne
8
8
  module_function
9
9
 
10
10
  def add(id, declaration = nil, &block)
11
- declaration = block if block_given?
11
+ declaration = block if block
12
12
 
13
13
  if declaration.is_a?(Class)
14
14
  DSL.send(:define_method, id) do |*args, **hargs, &inner_block|
@@ -11,7 +11,7 @@ module Clowne
11
11
  end
12
12
  end
13
13
 
14
- alias then yield_self
14
+ alias_method :then, :yield_self
15
15
  end
16
16
 
17
17
  # See https://github.com/jruby/jruby/issues/5220
@@ -5,9 +5,10 @@ module Clowne
5
5
  module AfterClone # :nodoc: all
6
6
  def self.call(source, record, declaration, params:, **_options)
7
7
  operation = Clowne::Utils::Operation.current
8
+ params ||= {}
8
9
  operation.add_after_clone(
9
10
  proc do
10
- declaration.block.call(source, record, params)
11
+ declaration.block.call(source, record, **params.merge(mapper: operation.mapper))
11
12
  end
12
13
  )
13
14
  record
@@ -3,7 +3,6 @@
3
3
  module Clowne
4
4
  class Resolvers
5
5
  module InitAs # :nodoc: all
6
- # rubocop: disable Metrics/ParameterLists
7
6
  def self.call(source, _record, declaration, params:, adapter:, **_options)
8
7
  adapter.init_record(declaration.block.call(source, **params))
9
8
  end
@@ -20,7 +20,6 @@ module Clowne
20
20
  extract_options! options
21
21
  end
22
22
 
23
- # rubocop: disable Metrics/AbcSize
24
23
  def match(expected, _actual)
25
24
  @actual = plan.declarations
26
25
  .find { |key, decl| key == :association && decl.name == expected }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clowne
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
data/lib/clowne.rb CHANGED
@@ -9,11 +9,10 @@ require "clowne/adapters/base"
9
9
  # Declarative models cloning
10
10
  module Clowne
11
11
  # List of built-in adapters
12
- # rubocop:disable Layout/AlignHash
13
12
  ADAPTERS = {
14
- base: "Base",
13
+ base: "Base",
15
14
  active_record: "ActiveRecord",
16
- sequel: "Sequel",
15
+ sequel: "Sequel"
17
16
  }.freeze
18
17
  # rubocop:enable Layout/AlignHash
19
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clowne
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-12 00:00:00.000000000 Z
12
+ date: 2022-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -79,56 +79,56 @@ dependencies:
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.75.0
82
+ version: '1.22'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.75.0
89
+ version: '1.22'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: rubocop-md
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.3.0
96
+ version: '1'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.3.0
103
+ version: '1'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rubocop-rspec
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.36.0
110
+ version: '2.5'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.36.0
117
+ version: '2.5'
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: standard
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.1.5
124
+ version: 1.4.0
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.1.5
131
+ version: 1.4.0
132
132
  description: A flexible gem for cloning your models.
133
133
  email:
134
134
  - palkan@evilmartians.com
@@ -139,11 +139,14 @@ extra_rdoc_files: []
139
139
  files:
140
140
  - ".codeclimate.yml"
141
141
  - ".gitattributes"
142
+ - ".github/workflows/rspec-jruby.yml"
143
+ - ".github/workflows/rspec-truffle.yml"
144
+ - ".github/workflows/rspec.yml"
145
+ - ".github/workflows/rubocop.yml"
142
146
  - ".gitignore"
143
147
  - ".rspec"
144
148
  - ".rubocop.yml"
145
149
  - ".rufo"
146
- - ".travis.yml"
147
150
  - CHANGELOG.md
148
151
  - Gemfile
149
152
  - LICENSE.txt
@@ -270,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
273
  - !ruby/object:Gem::Version
271
274
  version: '0'
272
275
  requirements: []
273
- rubygems_version: 3.0.3
276
+ rubygems_version: 3.0.3.1
274
277
  signing_key:
275
278
  specification_version: 4
276
279
  summary: A flexible gem for cloning your models
data/.travis.yml DELETED
@@ -1,45 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
-
5
- notifications:
6
- email: false
7
-
8
- before_install:
9
- - gem install bundler
10
-
11
- before_script:
12
- # Only generate coverage report for the specified job
13
- - if [ "$CC_REPORT" == "true" ]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; fi
14
- - if [ "$CC_REPORT" == "true" ]; then chmod +x ./cc-test-reporter; fi
15
- - if [ "$CC_REPORT" == "true" ]; then ./cc-test-reporter before-build; fi
16
- script:
17
- - bundle exec rake
18
- - if [ "$CC_REPORT" == "true" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
19
-
20
- matrix:
21
- fast_finish: true
22
- include:
23
- - rvm: ruby-head
24
- gemfile: gemfiles/railsmaster.gemfile
25
- - rvm: jruby-9.2.8.0
26
- gemfile: gemfiles/jruby.gemfile
27
- - rvm: 3.0
28
- gemfile: Gemfile
29
- - rvm: 2.7
30
- gemfile: Gemfile
31
- - rvm: 2.6.5
32
- gemfile: Gemfile
33
- - rvm: 2.5.7
34
- gemfile: Gemfile
35
- - rvm: 2.4.9
36
- gemfile: gemfiles/activerecord42.gemfile
37
- - rvm: truffleruby-head
38
- gemfile: Gemfile
39
- allow_failures:
40
- - rvm: ruby-head
41
- gemfile: gemfiles/railsmaster.gemfile
42
- - rvm: jruby-9.2.8.0
43
- gemfile: gemfiles/jruby.gemfile
44
- - rvm: truffleruby-head
45
- gemfile: Gemfile