clowne 0.0.1 → 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.rubocop.yml +49 -0
- data/.rufo +3 -0
- data/.travis.yml +37 -3
- data/CHANGELOG.md +11 -0
- data/Gemfile +12 -3
- data/LICENSE.txt +1 -1
- data/README.md +532 -14
- data/Rakefile +6 -8
- data/clowne.gemspec +16 -15
- data/gemfiles/activerecord42.gemfile +6 -0
- data/gemfiles/jruby.gemfile +6 -0
- data/gemfiles/railsmaster.gemfile +7 -0
- data/lib/clowne.rb +36 -2
- data/lib/clowne/adapters/active_record.rb +27 -0
- data/lib/clowne/adapters/active_record/association.rb +34 -0
- data/lib/clowne/adapters/active_record/associations.rb +30 -0
- data/lib/clowne/adapters/active_record/associations/base.rb +63 -0
- data/lib/clowne/adapters/active_record/associations/has_and_belongs_to_many.rb +20 -0
- data/lib/clowne/adapters/active_record/associations/has_many.rb +21 -0
- data/lib/clowne/adapters/active_record/associations/has_one.rb +30 -0
- data/lib/clowne/adapters/active_record/associations/noop.rb +19 -0
- data/lib/clowne/adapters/active_record/dsl.rb +33 -0
- data/lib/clowne/adapters/base.rb +69 -0
- data/lib/clowne/adapters/base/finalize.rb +19 -0
- data/lib/clowne/adapters/base/nullify.rb +19 -0
- data/lib/clowne/adapters/registry.rb +61 -0
- data/lib/clowne/cloner.rb +93 -0
- data/lib/clowne/declarations.rb +30 -0
- data/lib/clowne/declarations/exclude_association.rb +24 -0
- data/lib/clowne/declarations/finalize.rb +20 -0
- data/lib/clowne/declarations/include_association.rb +45 -0
- data/lib/clowne/declarations/nullify.rb +20 -0
- data/lib/clowne/declarations/trait.rb +44 -0
- data/lib/clowne/dsl.rb +14 -0
- data/lib/clowne/ext/string_constantize.rb +23 -0
- data/lib/clowne/plan.rb +81 -0
- data/lib/clowne/planner.rb +40 -0
- data/lib/clowne/version.rb +3 -1
- metadata +73 -12
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'clowne/plan'
|
4
|
+
|
5
|
+
module Clowne
|
6
|
+
class Planner # :nodoc: all
|
7
|
+
class << self
|
8
|
+
# Compile plan for cloner with traits
|
9
|
+
def compile(cloner, traits: nil)
|
10
|
+
declarations = cloner.declarations.dup
|
11
|
+
|
12
|
+
declarations += compile_traits(cloner, traits) unless traits.nil?
|
13
|
+
|
14
|
+
declarations.each_with_object(Plan.new(cloner.adapter.registry)) do |declaration, plan|
|
15
|
+
declaration.compile(plan)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Extend previously compiled plan with an arbitrary block
|
20
|
+
# NOTE: It doesn't modify the plan itself but return a copy
|
21
|
+
def enhance(plan, block)
|
22
|
+
trait = Clowne::Declarations::Trait.new.tap { |t| t.extend_with(block) }
|
23
|
+
|
24
|
+
trait.compiled.each_with_object(plan.dup) do |declaration, new_plan|
|
25
|
+
declaration.compile(new_plan)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def compile_traits(cloner, traits)
|
32
|
+
traits.map do |id|
|
33
|
+
trait = cloner.traits[id]
|
34
|
+
raise ConfigurationError, "Trait not found: #{id}" if trait.nil?
|
35
|
+
trait.compiled
|
36
|
+
end.flatten
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/clowne/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clowne
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
+
- Sverchkov Nikolay
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -16,14 +17,14 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
+
version: '1.14'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
+
version: '1.14'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,28 +40,61 @@ dependencies:
|
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '10.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
+
name: rspec
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
46
|
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
+
version: '3.0'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: factory_bot
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.8'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.8'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.51'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.51'
|
84
|
+
description: A flexible gem for cloning your models.
|
56
85
|
email:
|
57
|
-
-
|
86
|
+
- palkan@evilmartians.com
|
87
|
+
- ssnikolay@gmail.com
|
58
88
|
executables: []
|
59
89
|
extensions: []
|
60
90
|
extra_rdoc_files: []
|
61
91
|
files:
|
62
92
|
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".rubocop.yml"
|
95
|
+
- ".rufo"
|
63
96
|
- ".travis.yml"
|
97
|
+
- CHANGELOG.md
|
64
98
|
- Gemfile
|
65
99
|
- LICENSE.txt
|
66
100
|
- README.md
|
@@ -68,7 +102,34 @@ files:
|
|
68
102
|
- bin/console
|
69
103
|
- bin/setup
|
70
104
|
- clowne.gemspec
|
105
|
+
- gemfiles/activerecord42.gemfile
|
106
|
+
- gemfiles/jruby.gemfile
|
107
|
+
- gemfiles/railsmaster.gemfile
|
71
108
|
- lib/clowne.rb
|
109
|
+
- lib/clowne/adapters/active_record.rb
|
110
|
+
- lib/clowne/adapters/active_record/association.rb
|
111
|
+
- lib/clowne/adapters/active_record/associations.rb
|
112
|
+
- lib/clowne/adapters/active_record/associations/base.rb
|
113
|
+
- lib/clowne/adapters/active_record/associations/has_and_belongs_to_many.rb
|
114
|
+
- lib/clowne/adapters/active_record/associations/has_many.rb
|
115
|
+
- lib/clowne/adapters/active_record/associations/has_one.rb
|
116
|
+
- lib/clowne/adapters/active_record/associations/noop.rb
|
117
|
+
- lib/clowne/adapters/active_record/dsl.rb
|
118
|
+
- lib/clowne/adapters/base.rb
|
119
|
+
- lib/clowne/adapters/base/finalize.rb
|
120
|
+
- lib/clowne/adapters/base/nullify.rb
|
121
|
+
- lib/clowne/adapters/registry.rb
|
122
|
+
- lib/clowne/cloner.rb
|
123
|
+
- lib/clowne/declarations.rb
|
124
|
+
- lib/clowne/declarations/exclude_association.rb
|
125
|
+
- lib/clowne/declarations/finalize.rb
|
126
|
+
- lib/clowne/declarations/include_association.rb
|
127
|
+
- lib/clowne/declarations/nullify.rb
|
128
|
+
- lib/clowne/declarations/trait.rb
|
129
|
+
- lib/clowne/dsl.rb
|
130
|
+
- lib/clowne/ext/string_constantize.rb
|
131
|
+
- lib/clowne/plan.rb
|
132
|
+
- lib/clowne/planner.rb
|
72
133
|
- lib/clowne/version.rb
|
73
134
|
homepage: https://github.com/palkan/clowne
|
74
135
|
licenses:
|
@@ -85,13 +146,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
146
|
version: '0'
|
86
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
148
|
requirements:
|
88
|
-
- - "
|
149
|
+
- - ">"
|
89
150
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
151
|
+
version: 1.3.1
|
91
152
|
requirements: []
|
92
153
|
rubyforge_project:
|
93
154
|
rubygems_version: 2.6.13
|
94
155
|
signing_key:
|
95
156
|
specification_version: 4
|
96
|
-
summary:
|
157
|
+
summary: A flexible gem for cloning your models.
|
97
158
|
test_files: []
|