auxiliary_rails 0.1.8 → 0.2.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: 55024b258096ba35ea6d1ae4279ee9193d8c127d96186f86c91842b5436e7745
4
- data.tar.gz: dccf5c0d9d4de4776af52ef0b55a3ca7b78debf1077019f55483e034df290753
3
+ metadata.gz: 6270fee8c57097f95277b91cb770228af36551459ebd01fbbe1900ff43a5b4b3
4
+ data.tar.gz: 6b6e074c5751b729106fe2dcdc1f606474a95f6575eb8df0b1cbd68d54ebbe7b
5
5
  SHA512:
6
- metadata.gz: 98e16100b8ac8cf42af60dfbd6ee79ef906f2537cce8170c1cd14eff4bda1890757f6b44d14b69140924541c4366b6f85b4d7063d7752add414583bf3134cd3d
7
- data.tar.gz: 05e38836a6ed91b0df116239d0f3643c59615dc7ff074f7cfbedc15408a7e774dacc97f877a703ae82f4f6ed41f4b8588e9df6c18c2eef14255e37bdb46a6a16
6
+ metadata.gz: 77302dee8e26ab571731ee47779f70ade277fc5c476f197259a18d321336c0952f45bb69bba62bcde6d52cba677c979ac00646cc8e8165e7288da023cabb5642
7
+ data.tar.gz: 450261a1b391e70b1cd7b926bb0cb4985f2f82021713041be5f6f04a403ea0b48eb9b8623ea2178c40a10533d05013067997dd15868def2a686947187af9fccc
@@ -20,6 +20,12 @@ Metrics/BlockLength:
20
20
  ExcludedMethods:
21
21
  - describe
22
22
 
23
+ #################### RSpec ################################
24
+
25
+
26
+ RSpec/MultipleExpectations:
27
+ Max: 3
28
+
23
29
  #################### Style ###############################
24
30
 
25
31
  Style/Documentation:
@@ -1,5 +1,10 @@
1
1
  # AuxiliaryRails Changelog
2
2
 
3
+ ## v0.2.0
4
+
5
+ * Commands migration to `dry-initializer`
6
+ * Commands usage examples
7
+
3
8
  ## v0.1.7
4
9
 
5
10
  * Bundle update (nokogiri 1.10.4, rake 12)
@@ -11,7 +16,7 @@
11
16
 
12
17
  ## v0.1.5
13
18
 
14
- * Fix Gemfile.lock
19
+ * Fix `Gemfile.lock`
15
20
 
16
21
  ## v0.1.4
17
22
 
@@ -28,7 +33,7 @@
28
33
 
29
34
  ## v0.1.2
30
35
 
31
- * Fix Gemfile.lock
36
+ * Fix `Gemfile.lock`
32
37
 
33
38
  ## v0.1.1
34
39
 
@@ -1,67 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- auxiliary_rails (0.1.8)
4
+ auxiliary_rails (0.2.0)
5
+ dry-initializer-rails
5
6
  thor
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- actioncable (5.2.3)
11
- actionpack (= 5.2.3)
11
+ actioncable (6.0.2.1)
12
+ actionpack (= 6.0.2.1)
12
13
  nio4r (~> 2.0)
13
14
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.3)
15
- actionpack (= 5.2.3)
16
- actionview (= 5.2.3)
17
- activejob (= 5.2.3)
15
+ actionmailbox (6.0.2.1)
16
+ actionpack (= 6.0.2.1)
17
+ activejob (= 6.0.2.1)
18
+ activerecord (= 6.0.2.1)
19
+ activestorage (= 6.0.2.1)
20
+ activesupport (= 6.0.2.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.2.1)
23
+ actionpack (= 6.0.2.1)
24
+ actionview (= 6.0.2.1)
25
+ activejob (= 6.0.2.1)
18
26
  mail (~> 2.5, >= 2.5.4)
19
27
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.3)
21
- actionview (= 5.2.3)
22
- activesupport (= 5.2.3)
23
- rack (~> 2.0)
28
+ actionpack (6.0.2.1)
29
+ actionview (= 6.0.2.1)
30
+ activesupport (= 6.0.2.1)
31
+ rack (~> 2.0, >= 2.0.8)
24
32
  rack-test (>= 0.6.3)
25
33
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.3)
28
- activesupport (= 5.2.3)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.2.1)
36
+ actionpack (= 6.0.2.1)
37
+ activerecord (= 6.0.2.1)
38
+ activestorage (= 6.0.2.1)
39
+ activesupport (= 6.0.2.1)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.2.1)
42
+ activesupport (= 6.0.2.1)
29
43
  builder (~> 3.1)
30
44
  erubi (~> 1.4)
31
45
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.3)
34
- activesupport (= 5.2.3)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.2.1)
48
+ activesupport (= 6.0.2.1)
35
49
  globalid (>= 0.3.6)
36
- activemodel (5.2.3)
37
- activesupport (= 5.2.3)
38
- activerecord (5.2.3)
39
- activemodel (= 5.2.3)
40
- activesupport (= 5.2.3)
41
- arel (>= 9.0)
42
- activestorage (5.2.3)
43
- actionpack (= 5.2.3)
44
- activerecord (= 5.2.3)
50
+ activemodel (6.0.2.1)
51
+ activesupport (= 6.0.2.1)
52
+ activerecord (6.0.2.1)
53
+ activemodel (= 6.0.2.1)
54
+ activesupport (= 6.0.2.1)
55
+ activestorage (6.0.2.1)
56
+ actionpack (= 6.0.2.1)
57
+ activejob (= 6.0.2.1)
58
+ activerecord (= 6.0.2.1)
45
59
  marcel (~> 0.3.1)
46
- activesupport (5.2.3)
60
+ activesupport (6.0.2.1)
47
61
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
62
  i18n (>= 0.7, < 2)
49
63
  minitest (~> 5.1)
50
64
  tzinfo (~> 1.1)
51
- arel (9.0.0)
65
+ zeitwerk (~> 2.2)
52
66
  ast (2.4.0)
53
- builder (3.2.3)
67
+ builder (3.2.4)
54
68
  coderay (1.1.2)
55
69
  concurrent-ruby (1.1.5)
56
- crass (1.0.4)
70
+ crass (1.0.5)
57
71
  diff-lcs (1.3)
58
- erubi (1.8.0)
72
+ dry-initializer (3.0.2)
73
+ dry-initializer-rails (3.1.1)
74
+ dry-initializer (>= 2.4, < 4)
75
+ rails (> 3.0)
76
+ erubi (1.9.0)
59
77
  globalid (0.4.2)
60
78
  activesupport (>= 4.2.0)
61
- i18n (1.6.0)
79
+ i18n (1.7.0)
62
80
  concurrent-ruby (~> 1.0)
63
- jaro_winkler (1.5.3)
64
- loofah (2.2.3)
81
+ jaro_winkler (1.5.4)
82
+ loofah (2.4.0)
65
83
  crass (~> 1.0.2)
66
84
  nokogiri (>= 1.5.9)
67
85
  mail (2.7.1)
@@ -72,85 +90,88 @@ GEM
72
90
  mimemagic (0.3.3)
73
91
  mini_mime (1.0.2)
74
92
  mini_portile2 (2.4.0)
75
- minitest (5.11.3)
76
- nio4r (2.4.0)
77
- nokogiri (1.10.4)
93
+ minitest (5.13.0)
94
+ nio4r (2.5.2)
95
+ nokogiri (1.10.7)
78
96
  mini_portile2 (~> 2.4.0)
79
- parallel (1.17.0)
80
- parser (2.6.3.0)
97
+ parallel (1.19.1)
98
+ parser (2.7.0.1)
81
99
  ast (~> 2.4.0)
82
100
  pry (0.12.2)
83
101
  coderay (~> 1.1.0)
84
102
  method_source (~> 0.9.0)
85
- rack (2.0.7)
103
+ rack (2.0.8)
86
104
  rack-test (1.1.0)
87
105
  rack (>= 1.0, < 3)
88
- rails (5.2.3)
89
- actioncable (= 5.2.3)
90
- actionmailer (= 5.2.3)
91
- actionpack (= 5.2.3)
92
- actionview (= 5.2.3)
93
- activejob (= 5.2.3)
94
- activemodel (= 5.2.3)
95
- activerecord (= 5.2.3)
96
- activestorage (= 5.2.3)
97
- activesupport (= 5.2.3)
106
+ rails (6.0.2.1)
107
+ actioncable (= 6.0.2.1)
108
+ actionmailbox (= 6.0.2.1)
109
+ actionmailer (= 6.0.2.1)
110
+ actionpack (= 6.0.2.1)
111
+ actiontext (= 6.0.2.1)
112
+ actionview (= 6.0.2.1)
113
+ activejob (= 6.0.2.1)
114
+ activemodel (= 6.0.2.1)
115
+ activerecord (= 6.0.2.1)
116
+ activestorage (= 6.0.2.1)
117
+ activesupport (= 6.0.2.1)
98
118
  bundler (>= 1.3.0)
99
- railties (= 5.2.3)
119
+ railties (= 6.0.2.1)
100
120
  sprockets-rails (>= 2.0.0)
101
121
  rails-dom-testing (2.0.3)
102
122
  activesupport (>= 4.2.0)
103
123
  nokogiri (>= 1.6)
104
- rails-html-sanitizer (1.2.0)
105
- loofah (~> 2.2, >= 2.2.2)
106
- railties (5.2.3)
107
- actionpack (= 5.2.3)
108
- activesupport (= 5.2.3)
124
+ rails-html-sanitizer (1.3.0)
125
+ loofah (~> 2.3)
126
+ railties (6.0.2.1)
127
+ actionpack (= 6.0.2.1)
128
+ activesupport (= 6.0.2.1)
109
129
  method_source
110
130
  rake (>= 0.8.7)
111
- thor (>= 0.19.0, < 2.0)
131
+ thor (>= 0.20.3, < 2.0)
112
132
  rainbow (3.0.0)
113
- rake (12.3.3)
114
- rspec (3.8.0)
115
- rspec-core (~> 3.8.0)
116
- rspec-expectations (~> 3.8.0)
117
- rspec-mocks (~> 3.8.0)
118
- rspec-core (3.8.2)
119
- rspec-support (~> 3.8.0)
120
- rspec-expectations (3.8.4)
133
+ rake (13.0.1)
134
+ rspec (3.9.0)
135
+ rspec-core (~> 3.9.0)
136
+ rspec-expectations (~> 3.9.0)
137
+ rspec-mocks (~> 3.9.0)
138
+ rspec-core (3.9.1)
139
+ rspec-support (~> 3.9.1)
140
+ rspec-expectations (3.9.0)
121
141
  diff-lcs (>= 1.2.0, < 2.0)
122
- rspec-support (~> 3.8.0)
123
- rspec-mocks (3.8.1)
142
+ rspec-support (~> 3.9.0)
143
+ rspec-mocks (3.9.1)
124
144
  diff-lcs (>= 1.2.0, < 2.0)
125
- rspec-support (~> 3.8.0)
126
- rspec-support (3.8.2)
127
- rubocop (0.74.0)
145
+ rspec-support (~> 3.9.0)
146
+ rspec-support (3.9.2)
147
+ rubocop (0.78.0)
128
148
  jaro_winkler (~> 1.5.1)
129
149
  parallel (~> 1.10)
130
150
  parser (>= 2.6)
131
151
  rainbow (>= 2.2.2, < 4.0)
132
152
  ruby-progressbar (~> 1.7)
133
153
  unicode-display_width (>= 1.4.0, < 1.7)
134
- rubocop-performance (1.4.1)
154
+ rubocop-performance (1.5.2)
135
155
  rubocop (>= 0.71.0)
136
- rubocop-rspec (1.35.0)
137
- rubocop (>= 0.60.0)
156
+ rubocop-rspec (1.37.1)
157
+ rubocop (>= 0.68.1)
138
158
  ruby-progressbar (1.10.1)
139
- sprockets (3.7.2)
159
+ sprockets (4.0.0)
140
160
  concurrent-ruby (~> 1.0)
141
161
  rack (> 1, < 3)
142
162
  sprockets-rails (3.2.1)
143
163
  actionpack (>= 4.0)
144
164
  activesupport (>= 4.0)
145
165
  sprockets (>= 3.0.0)
146
- thor (0.20.3)
166
+ thor (1.0.1)
147
167
  thread_safe (0.3.6)
148
- tzinfo (1.2.5)
168
+ tzinfo (1.2.6)
149
169
  thread_safe (~> 0.1)
150
170
  unicode-display_width (1.6.0)
151
171
  websocket-driver (0.7.1)
152
172
  websocket-extensions (>= 0.1.0)
153
173
  websocket-extensions (0.1.4)
174
+ zeitwerk (2.2.2)
154
175
 
155
176
  PLATFORMS
156
177
  ruby
@@ -159,8 +180,8 @@ DEPENDENCIES
159
180
  auxiliary_rails!
160
181
  bundler (~> 2.0)
161
182
  pry
162
- rails (~> 5.2)
163
- rake (~> 12.3)
183
+ rails (>= 5.2, < 7)
184
+ rake
164
185
  rspec (~> 3.8)
165
186
  rubocop
166
187
  rubocop-performance
data/README.md CHANGED
@@ -8,7 +8,7 @@ Collection of classes, configs, scripts, generators for Ruby on Rails helping yo
8
8
 
9
9
  ## Installation
10
10
 
11
- Add one of these lines to your application's Gemfile:
11
+ Add one of these lines to your application's `Gemfile`:
12
12
 
13
13
  ```ruby
14
14
  # version released to RubyGems
@@ -56,7 +56,10 @@ rails generate auxiliary_rails:install_rubocop
56
56
  rails generate auxiliary_rails:install_rubocop --no-specify-gems
57
57
 
58
58
  # API resource generator
59
- rails generate auxiliary_rails:api_resource NAME
59
+ rails generate auxiliary_rails:api_resource
60
+
61
+ # Command generator
62
+ rails generate auxiliary_rails:command
60
63
  ```
61
64
 
62
65
  ### View Helpers
@@ -35,12 +35,13 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency 'bundler', '~> 2.0'
37
37
  spec.add_development_dependency 'pry'
38
- spec.add_development_dependency 'rails', '~> 5.2'
39
- spec.add_development_dependency 'rake', '~> 12.3'
38
+ spec.add_development_dependency 'rails', '>= 5.2', '< 7'
39
+ spec.add_development_dependency 'rake'
40
40
  spec.add_development_dependency 'rspec', '~> 3.8'
41
41
  spec.add_development_dependency 'rubocop'
42
42
  spec.add_development_dependency 'rubocop-performance'
43
43
  spec.add_development_dependency 'rubocop-rspec'
44
44
 
45
+ spec.add_runtime_dependency 'dry-initializer-rails'
45
46
  spec.add_runtime_dependency 'thor'
46
47
  end
@@ -1,9 +1,10 @@
1
+ require 'dry-initializer-rails'
1
2
  require 'active_model'
2
3
 
3
4
  module AuxiliaryRails
4
5
  class AbstractCommand
5
- include ActiveModel::Model
6
- include ActiveModel::Attributes
6
+ extend Dry::Initializer
7
+ include ActiveModel::Validations
7
8
 
8
9
  def self.call(*args)
9
10
  new(*args).call
@@ -13,10 +14,6 @@ module AuxiliaryRails
13
14
  raise NotImplementedError
14
15
  end
15
16
 
16
- def errors
17
- @errors ||= ActiveModel::Errors.new(self)
18
- end
19
-
20
17
  def failure?
21
18
  status?(:failure)
22
19
  end
@@ -31,16 +28,18 @@ module AuxiliaryRails
31
28
  status?(:success)
32
29
  end
33
30
 
31
+ # Shortcut for `ActiveRecord::Base.transaction`
34
32
  def transaction(&block)
35
33
  ActiveRecord::Base.transaction(&block) if block_given?
36
34
  end
37
35
 
38
36
  # Method for ActiveModel::Errors
39
37
  def read_attribute_for_validation(attr_name)
38
+ attr_name = attr_name.to_sym
40
39
  if attr_name == :command
41
40
  self
42
41
  else
43
- attribute(attr_name)
42
+ self.class.dry_initializer.attributes(self)[attr_name]
44
43
  end
45
44
  end
46
45
 
@@ -1,3 +1,3 @@
1
1
  module AuxiliaryRails
2
- VERSION = '0.1.8'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -0,0 +1,44 @@
1
+ require 'rails'
2
+
3
+ module AuxiliaryRails
4
+ class CommandGenerator < ::Rails::Generators::NamedBase
5
+ desc 'Stubs out a new Command and spec.'
6
+
7
+ source_root File.expand_path('templates/commands', __dir__)
8
+
9
+ class_option :path,
10
+ type: :string,
11
+ default: 'app/commands',
12
+ desc: 'Command location'
13
+
14
+ def create_command_file
15
+ FileUtils.mkdir_p(command_file_path)
16
+ template 'command_template.rb',
17
+ "#{command_file_path}/#{command_file_name}.rb"
18
+ end
19
+
20
+ def create_command_spec_file
21
+ FileUtils.mkdir_p(command_spec_path)
22
+ template 'command_spec_template.rb',
23
+ "#{command_spec_path}/#{command_file_name}_spec.rb"
24
+ end
25
+
26
+ private
27
+
28
+ def command_class_name
29
+ "#{class_name.gsub(/Command$/, '')}Command"
30
+ end
31
+
32
+ def command_file_name
33
+ command_class_name.underscore
34
+ end
35
+
36
+ def command_file_path
37
+ options[:path]
38
+ end
39
+
40
+ def command_spec_path
41
+ command_file_path.gsub(/^app\//, 'spec/')
42
+ end
43
+ end
44
+ end
@@ -2,7 +2,7 @@ require 'rails'
2
2
 
3
3
  module AuxiliaryRails
4
4
  class InstallCommandsGenerator < ::Rails::Generators::Base
5
- source_root File.expand_path('templates', __dir__)
5
+ source_root File.expand_path('templates/commands', __dir__)
6
6
 
7
7
  def copy_application_command_file
8
8
  copy_file 'application_command_template.rb',
@@ -0,0 +1,11 @@
1
+ require 'rails_helper'
2
+
3
+ describe <%= command_class_name %> do
4
+ describe '#call' do
5
+ it 'succeeds' do
6
+ # TODO: implement spec for command
7
+ # expect(described_class.call).to be_success
8
+ skip
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class <%= command_class_name %> < ApplicationCommand
2
+ def call
3
+ # TODO: implement <%= command_class_name %>.call method
4
+ success!
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auxiliary_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Babenko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-27 00:00:00.000000000 Z
12
+ date: 2020-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,30 +43,36 @@ dependencies:
43
43
  name: rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '5.2'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '7'
49
52
  type: :development
50
53
  prerelease: false
51
54
  version_requirements: !ruby/object:Gem::Requirement
52
55
  requirements:
53
- - - "~>"
56
+ - - ">="
54
57
  - !ruby/object:Gem::Version
55
58
  version: '5.2'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '7'
56
62
  - !ruby/object:Gem::Dependency
57
63
  name: rake
58
64
  requirement: !ruby/object:Gem::Requirement
59
65
  requirements:
60
- - - "~>"
66
+ - - ">="
61
67
  - !ruby/object:Gem::Version
62
- version: '12.3'
68
+ version: '0'
63
69
  type: :development
64
70
  prerelease: false
65
71
  version_requirements: !ruby/object:Gem::Requirement
66
72
  requirements:
67
- - - "~>"
73
+ - - ">="
68
74
  - !ruby/object:Gem::Version
69
- version: '12.3'
75
+ version: '0'
70
76
  - !ruby/object:Gem::Dependency
71
77
  name: rspec
72
78
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +129,20 @@ dependencies:
123
129
  - - ">="
124
130
  - !ruby/object:Gem::Version
125
131
  version: '0'
132
+ - !ruby/object:Gem::Dependency
133
+ name: dry-initializer-rails
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ type: :runtime
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
126
146
  - !ruby/object:Gem::Dependency
127
147
  name: thor
128
148
  requirement: !ruby/object:Gem::Requirement
@@ -174,6 +194,7 @@ files:
174
194
  - lib/auxiliary_rails/version.rb
175
195
  - lib/auxiliary_rails/view_helpers.rb
176
196
  - lib/generators/auxiliary_rails/api_resource_generator.rb
197
+ - lib/generators/auxiliary_rails/command_generator.rb
177
198
  - lib/generators/auxiliary_rails/install_commands_generator.rb
178
199
  - lib/generators/auxiliary_rails/install_errors_generator.rb
179
200
  - lib/generators/auxiliary_rails/install_generator.rb
@@ -182,8 +203,10 @@ files:
182
203
  - lib/generators/auxiliary_rails/templates/apis/api_helper_template.rb.erb
183
204
  - lib/generators/auxiliary_rails/templates/apis/api_resource_spec_template.rb.erb
184
205
  - lib/generators/auxiliary_rails/templates/apis/api_resource_template.rb.erb
185
- - lib/generators/auxiliary_rails/templates/application_command_template.rb
186
206
  - lib/generators/auxiliary_rails/templates/application_error_template.rb
207
+ - lib/generators/auxiliary_rails/templates/commands/application_command_template.rb
208
+ - lib/generators/auxiliary_rails/templates/commands/command_spec_template.rb
209
+ - lib/generators/auxiliary_rails/templates/commands/command_template.rb
187
210
  - lib/generators/auxiliary_rails/templates/rubocop/rubocop_auxiliary_rails_template.yml
188
211
  - lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml
189
212
  - templates/rails/elementary.rb