sinclair 1.1.1 → 1.1.2

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +1 -208
  4. data/Gemfile +3 -1
  5. data/README.md +4 -0
  6. data/Rakefile +5 -3
  7. data/lib/sinclair.rb +2 -0
  8. data/lib/sinclair/matchers.rb +2 -0
  9. data/lib/sinclair/matchers/add_method.rb +4 -2
  10. data/lib/sinclair/matchers/add_method_to.rb +2 -0
  11. data/lib/sinclair/method_definition.rb +2 -0
  12. data/lib/sinclair/options_parser.rb +2 -0
  13. data/lib/sinclair/version.rb +3 -2
  14. data/sinclair.gemspec +17 -16
  15. data/spec/integration/matcher_spec.rb +2 -0
  16. data/spec/integration/readme/matcher_spec.rb +2 -0
  17. data/spec/integration/readme/my_class_spec.rb +3 -1
  18. data/spec/integration/readme_spec.rb +2 -0
  19. data/spec/integration/yard/matchers/add_method_to_spec.rb +2 -0
  20. data/spec/integration/yard/options_parser_spec.rb +2 -0
  21. data/spec/integration/yard/sinclair_spec.rb +2 -0
  22. data/spec/lib/sinclair/matchers/add_method_spec.rb +2 -0
  23. data/spec/lib/sinclair/matchers/add_method_to_spec.rb +11 -9
  24. data/spec/lib/sinclair/matchers_spec.rb +2 -0
  25. data/spec/lib/sinclair/method_definition_spec.rb +4 -2
  26. data/spec/lib/sinclair/options_parser_spec.rb +4 -2
  27. data/spec/lib/sinclair_spec.rb +16 -8
  28. data/spec/spec_helper.rb +4 -2
  29. data/spec/support/fixture_helpers.rb +4 -2
  30. data/spec/support/models/dummy_builder.rb +9 -5
  31. data/spec/support/models/dummy_options_parser.rb +15 -11
  32. data/spec/support/models/initial_valuer.rb +2 -0
  33. data/spec/support/models/my_builder.rb +2 -0
  34. data/spec/support/models/my_class.rb +2 -0
  35. data/spec/support/models/my_concern.rb +2 -0
  36. data/spec/support/models/my_model.rb +2 -0
  37. data/spec/support/models/person.rb +2 -0
  38. data/spec/support/models/purchase.rb +2 -0
  39. data/spec/support/models/validator_builder.rb +3 -1
  40. metadata +19 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2734e2007f6c98dc270ea39df18e07aed7f9324
4
- data.tar.gz: d570bf309c48f65b080b0db7da0301968fb055c4
3
+ metadata.gz: 4f1722c4f4642983d8bffccddbac5dc76a18b592
4
+ data.tar.gz: 943f6a96fab30c1eb6d191a7948b69581c079099
5
5
  SHA512:
6
- metadata.gz: 4cbe6a2654818eedc3aac238d6689e61210d1e2fe9ad1dfc892bc340474b9ccc49a1474a2fa4e69dabf3dd3975ddc003120cc2a7db31c4a32b74ea3b55fc8924
7
- data.tar.gz: daf0ff8fbe75d336c0651dc27298b530a12b1c2709e67b3a6b2dd3c64407a5ddbb1ff14d0a92dd018a3df4f1f143508c0812e4075f4317a0f2105b214dc01f49
6
+ metadata.gz: 93744c9aafc218ca2f0a26b767f620c6e7c14362601ab26a113ad238345b6e6e6d92558ee6e1dd0b5c40c1b463e9370954b680d7f8f91a05b1253fc9cdbaaeac
7
+ data.tar.gz: dfbf362cbdd528984e72e2d066e14be6bd9ca3eeddc9cff339fe7c9809617c17761ada63792f383f0ea3b8e1d13397af912b872c42eb542cca0a089f4e1d8a4b
data/.rubocop.yml CHANGED
@@ -1 +1,11 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*_spec.rb'
9
+
10
+ Metrics/LineLength:
11
+ Max: 100
data/.rubocop_todo.yml CHANGED
@@ -1,214 +1,7 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-06-29 18:23:09 +0000 using RuboCop version 0.57.2.
3
+ # on 2018-07-10 13:04:21 +0000 using RuboCop version 0.57.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
- # Include: **/*.gemspec
13
- Gemspec/OrderedDependencies:
14
- Exclude:
15
- - 'sinclair.gemspec'
16
-
17
- # Offense count: 1
18
- # Cop supports --auto-correct.
19
- # Configuration parameters: EnforcedStyleAlignWith.
20
- # SupportedStylesAlignWith: either, start_of_block, start_of_line
21
- Layout/BlockAlignment:
22
- Exclude:
23
- - 'spec/lib/sinclair/method_definition_spec.rb'
24
-
25
- # Offense count: 1
26
- # Cop supports --auto-correct.
27
- Layout/EmptyLineAfterMagicComment:
28
- Exclude:
29
- - 'sinclair.gemspec'
30
-
31
- # Offense count: 3
32
- # Cop supports --auto-correct.
33
- # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
34
- Layout/ExtraSpacing:
35
- Exclude:
36
- - 'sinclair.gemspec'
37
- - 'spec/lib/sinclair_spec.rb'
38
- - 'spec/spec_helper.rb'
39
-
40
- # Offense count: 3
41
- # Cop supports --auto-correct.
42
- # Configuration parameters: Width, IgnoredPatterns.
43
- Layout/IndentationWidth:
44
- Exclude:
45
- - 'spec/lib/sinclair/method_definition_spec.rb'
46
- - 'spec/support/fixture_helpers.rb'
47
-
48
- # Offense count: 1
49
- # Cop supports --auto-correct.
50
- # Configuration parameters: EnforcedStyle.
51
- # SupportedStyles: space, no_space
52
- Layout/SpaceAroundEqualsInParameterDefault:
53
- Exclude:
54
- - 'spec/support/models/validator_builder.rb'
55
-
56
- # Offense count: 1
57
- # Cop supports --auto-correct.
58
- # Configuration parameters: EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
59
- # SupportedStyles: space, no_space
60
- # SupportedStylesForEmptyBraces: space, no_space
61
- Layout/SpaceInsideBlockBraces:
62
- EnforcedStyle: space
63
-
64
- # Offense count: 2
65
- # Cop supports --auto-correct.
66
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
67
- # SupportedStyles: space, no_space, compact
68
- # SupportedStylesForEmptyBraces: space, no_space
69
- Layout/SpaceInsideHashLiteralBraces:
70
- Exclude:
71
- - 'spec/lib/sinclair/options_parser_spec.rb'
72
-
73
- # Offense count: 4
74
- # Cop supports --auto-correct.
75
- # Configuration parameters: EnforcedStyle.
76
- # SupportedStyles: space, no_space
77
- Layout/SpaceInsideStringInterpolation:
78
- Exclude:
79
- - 'spec/lib/sinclair_spec.rb'
80
- - 'spec/support/models/dummy_builder.rb'
81
-
82
- # Offense count: 2
83
- # Cop supports --auto-correct.
84
- # Configuration parameters: EnforcedStyle.
85
- # SupportedStyles: final_newline, final_blank_line
86
- Layout/TrailingBlankLines:
87
- Exclude:
88
- - 'lib/sinclair/version.rb'
89
- - 'sinclair.gemspec'
90
-
91
- # Offense count: 1
92
- # Cop supports --auto-correct.
93
- # Configuration parameters: AllowInHeredoc.
94
- Layout/TrailingWhitespace:
95
- Exclude:
96
- - 'spec/integration/matcher_spec.rb'
97
-
98
- # Offense count: 1
99
- Lint/ParenthesesAsGroupedExpression:
100
- Exclude:
101
- - 'spec/support/fixture_helpers.rb'
102
-
103
- # Offense count: 9
104
- # Configuration parameters: CountComments, ExcludedMethods.
105
- Metrics/BlockLength:
106
- Max: 119
107
-
108
- # Offense count: 4
109
- # Cop supports --auto-correct.
110
- # Configuration parameters: AutoCorrect, EnforcedStyle.
111
- # SupportedStyles: nested, compact
112
- Style/ClassAndModuleChildren:
113
- Exclude:
114
- - 'spec/support/models/dummy_builder.rb'
115
- - 'spec/support/models/dummy_options_parser.rb'
116
-
117
- # Offense count: 6
118
- Style/Documentation:
119
- Exclude:
120
- - 'spec/**/*'
121
- - 'test/**/*'
122
- - 'lib/sinclair.rb'
123
- - 'lib/sinclair/matchers.rb'
124
- - 'lib/sinclair/matchers/add_method.rb'
125
- - 'lib/sinclair/matchers/add_method_to.rb'
126
- - 'lib/sinclair/method_definition.rb'
127
- - 'lib/sinclair/options_parser.rb'
128
-
129
- # Offense count: 1
130
- # Cop supports --auto-correct.
131
- Style/Encoding:
132
- Exclude:
133
- - 'sinclair.gemspec'
134
-
135
- # Offense count: 1
136
- # Cop supports --auto-correct.
137
- Style/ExpandPathArguments:
138
- Exclude:
139
- - 'sinclair.gemspec'
140
-
141
- # Offense count: 1
142
- # Cop supports --auto-correct.
143
- # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
144
- # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
145
- Style/HashSyntax:
146
- Exclude:
147
- - 'Rakefile'
148
-
149
- # Offense count: 1
150
- # Cop supports --auto-correct.
151
- Style/MutableConstant:
152
- Exclude:
153
- - 'lib/sinclair/version.rb'
154
-
155
- # Offense count: 3
156
- # Cop supports --auto-correct.
157
- # Configuration parameters: Whitelist.
158
- # Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
159
- Style/NestedParenthesizedCalls:
160
- Exclude:
161
- - 'spec/lib/sinclair/matchers/add_method_to_spec.rb'
162
-
163
- # Offense count: 1
164
- # Cop supports --auto-correct.
165
- # Configuration parameters: PreferredDelimiters.
166
- Style/PercentLiteralDelimiters:
167
- Exclude:
168
- - 'spec/integration/readme/my_class_spec.rb'
169
-
170
- # Offense count: 3
171
- # Cop supports --auto-correct.
172
- Style/Proc:
173
- Exclude:
174
- - 'spec/lib/sinclair/matchers/add_method_to_spec.rb'
175
-
176
- # Offense count: 1
177
- # Cop supports --auto-correct.
178
- Style/RedundantParentheses:
179
- Exclude:
180
- - 'spec/support/fixture_helpers.rb'
181
-
182
- # Offense count: 1
183
- # Cop supports --auto-correct.
184
- Style/RedundantSelf:
185
- Exclude:
186
- - 'spec/lib/sinclair/method_definition_spec.rb'
187
-
188
- # Offense count: 1
189
- # Cop supports --auto-correct.
190
- # Configuration parameters: EnforcedStyle.
191
- # SupportedStyles: use_perl_names, use_english_names
192
- Style/SpecialGlobalVars:
193
- Exclude:
194
- - 'sinclair.gemspec'
195
-
196
- # Offense count: 14
197
- # Cop supports --auto-correct.
198
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
199
- # SupportedStyles: single_quotes, double_quotes
200
- Style/StringLiterals:
201
- Exclude:
202
- - 'Gemfile'
203
- - 'Rakefile'
204
- - 'sinclair.gemspec'
205
- - 'spec/lib/sinclair/method_definition_spec.rb'
206
- - 'spec/lib/sinclair_spec.rb'
207
- - 'spec/spec_helper.rb'
208
- - 'spec/support/models/dummy_builder.rb'
209
-
210
- # Offense count: 8
211
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
212
- # URISchemes: http, https
213
- Metrics/LineLength:
214
- Max: 103
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -27,6 +27,10 @@ Installation
27
27
  bundle install sinclair
28
28
  ```
29
29
 
30
+ Yard Documentation
31
+ -------------------
32
+ https://www.rubydoc.info/gems/sinclair/
33
+
30
34
  Usage
31
35
  ---------------
32
36
  The concern builder can actully be used in two ways, as an stand alone object capable of
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
3
2
 
4
- task :default => :spec
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: :spec
5
7
  task test: :spec
data/lib/sinclair.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/all'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
4
  # Matchers module will have the DSL to be included in RSpec in order to have
3
5
  # access to the matchers
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
4
  module Matchers
3
5
  # AddMethod is able to build an instance of Sinclair::Matchers::AddMethodTo
4
6
  class AddMethod < RSpec::Matchers::BuiltIn::BaseMatcher
5
- # as any matcher is expected to implement matches?, we raise a warning on the usage as
6
- # this is only a builder for AddMethodTo
7
+ # as any matcher is expected to implement matches?, we raise a warning on
8
+ # the usage as this is only a builder for AddMethodTo
7
9
  def matches?(_actual)
8
10
  raise SyntaxError, 'You should specify which instance the method is being added to' \
9
11
  "add_method(:#{method}).to(instance)"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
4
  module Matchers
3
5
  # AddMethodTo checks whether a method was or not added by the call of a block
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
4
  # Definition of the code or block to be aded as method
3
5
  class MethodDefinition
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
4
  # Concern for easily adding options
3
5
  #
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
3
5
  end
4
-
data/sinclair.gemspec CHANGED
@@ -1,30 +1,31 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'sinclair/version'
5
6
 
6
7
  Gem::Specification.new do |gem|
7
- gem.name = 'sinclair'
8
- gem.version = Sinclair::VERSION
9
- gem.authors = ["DarthJee"]
10
- gem.email = ["darthjee@gmail.com"]
11
- gem.homepage = 'https://github.com/darthjee/sinclair'
12
- gem.description = 'Gem for easy concern creation'
13
- gem.summary = gem.description
8
+ gem.name = 'sinclair'
9
+ gem.version = Sinclair::VERSION
10
+ gem.authors = ['DarthJee']
11
+ gem.email = ['darthjee@gmail.com']
12
+ gem.homepage = 'https://github.com/darthjee/sinclair'
13
+ gem.description = 'Gem for easy concern creation'
14
+ gem.summary = gem.description
15
+ gem.required_ruby_version = '>= 2.4.0'
14
16
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
18
- gem.require_paths = ["lib"]
17
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
20
+ gem.require_paths = ['lib']
19
21
 
20
22
  gem.add_runtime_dependency 'activesupport', '~> 5.2.0'
21
23
 
22
24
  gem.add_development_dependency 'bundler', '~> 1.6'
25
+ gem.add_development_dependency 'pry-nav'
23
26
  gem.add_development_dependency 'rake', '~> 12.0.0'
24
27
  gem.add_development_dependency 'rspec', '~> 2.14'
25
- gem.add_development_dependency 'simplecov', '~> 0.16.1'
26
28
  gem.add_development_dependency 'rubocop'
27
- gem.add_development_dependency 'pry-nav'
29
+ gem.add_development_dependency 'simplecov', '~> 0.16.1'
28
30
  gem.add_development_dependency 'yard'
29
31
  end
30
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'matchers' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe DefaultValue do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe MyClass do
@@ -14,7 +16,7 @@ describe MyClass do
14
16
  }
15
17
  end
16
18
 
17
- %i(name surname age legs).each do |field|
19
+ %i[name surname age legs].each do |field|
18
20
  it do
19
21
  expect(subject).to respond_to(field)
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Stand Alone' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'yard' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'yard' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: false
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'yarn' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair::Matchers::AddMethod do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair::Matchers::AddMethodTo do
@@ -9,32 +11,32 @@ describe Sinclair::Matchers::AddMethodTo do
9
11
 
10
12
  describe '#matches?' do
11
13
  let(:event_proc) do
12
- Proc.new { klass.send(:define_method, method) {} }
14
+ proc { klass.send(:define_method, method) {} }
13
15
  end
14
16
 
15
17
  context 'when a method is added' do
16
- it { expect(subject.matches? event_proc).to be_truthy }
18
+ it { expect(subject.matches?(event_proc)).to be_truthy }
17
19
  end
18
20
 
19
21
  context 'when a method is not added' do
20
- let(:event_proc) { Proc.new {} }
22
+ let(:event_proc) { proc {} }
21
23
 
22
- it { expect(subject.matches? event_proc).to be_falsey }
24
+ it { expect(subject.matches?(event_proc)).to be_falsey }
23
25
  end
24
26
 
25
27
  context 'when the wrong method is added' do
26
28
  let(:event_proc) do
27
- Proc.new { klass.send(:define_method, :another_method) {} }
29
+ proc { klass.send(:define_method, :another_method) {} }
28
30
  end
29
31
 
30
- it { expect(subject.matches? event_proc).to be_falsey }
32
+ it { expect(subject.matches?(event_proc)).to be_falsey }
31
33
  end
32
34
 
33
35
  context 'when initializing with class' do
34
36
  subject { described_class.new(klass, method) }
35
37
 
36
38
  context 'when a method is added' do
37
- it { expect(subject.matches? event_proc).to be_truthy }
39
+ it { expect(subject.matches?(event_proc)).to be_truthy }
38
40
  end
39
41
  end
40
42
  end
@@ -48,7 +50,7 @@ describe Sinclair::Matchers::AddMethodTo do
48
50
  context 'when method already exited' do
49
51
  before do
50
52
  klass.send(:define_method, method) {}
51
- subject.matches?(Proc.new {})
53
+ subject.matches?(proc {})
52
54
  end
53
55
 
54
56
  it 'returns information on the instance class and method' do
@@ -68,7 +70,7 @@ describe Sinclair::Matchers::AddMethodTo do
68
70
  context 'when method already exited' do
69
71
  before do
70
72
  klass.send(:define_method, method) {}
71
- subject.matches?(Proc.new {})
73
+ subject.matches?(proc {})
72
74
  end
73
75
 
74
76
  it 'returns information on the instance class and method' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair::Matchers do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair::MethodDefinition do
@@ -28,8 +30,8 @@ describe Sinclair::MethodDefinition do
28
30
  context 'when method was defined with a block' do
29
31
  subject do
30
32
  described_class.new(method_name) do
31
- "Self ==> " + self.to_s
32
- end
33
+ 'Self ==> ' + to_s
34
+ end
33
35
  end
34
36
 
35
37
  before do
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair::OptionsParser do
4
6
  let(:klass) { described_class::Dummy }
5
7
  let(:switched) { true }
6
8
  let(:value_1) { 'value1' }
7
- let(:options) { { switch: switched, option_1: value_1, option_2: 2} }
9
+ let(:options) { { switch: switched, option_1: value_1, option_2: 2 } }
8
10
 
9
11
  subject do
10
12
  klass.new(options)
@@ -23,7 +25,7 @@ describe Sinclair::OptionsParser do
23
25
  end
24
26
 
25
27
  context 'when there is an option missing' do
26
- let(:options) { { option_1: 'value1', option_2: 2} }
28
+ let(:options) { { option_1: 'value1', option_2: 2 } }
27
29
 
28
30
  it do
29
31
  expect { subject.the_method }.not_to raise_error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Sinclair do
@@ -94,8 +96,10 @@ describe Sinclair do
94
96
  describe '#eval_and_add_method' do
95
97
  context 'when defining the method once' do
96
98
  before do
97
- subject.add_method(:value, "@value ||= 0")
98
- subject.eval_and_add_method(:defined) { "@value = value + #{ options_object.increment || 1 }" }
99
+ subject.add_method(:value, '@value ||= 0')
100
+ subject.eval_and_add_method(:defined) do
101
+ "@value = value + #{options_object.increment || 1}"
102
+ end
99
103
  subject.build
100
104
  end
101
105
 
@@ -116,9 +120,11 @@ describe Sinclair do
116
120
 
117
121
  context 'when redefining a method already added' do
118
122
  before do
119
- subject.add_method(:value, "@value ||= 0")
120
- subject.add_method(:defined, "100")
121
- subject.eval_and_add_method(:defined) { "@value = value + #{ options_object.increment || 1 }" }
123
+ subject.add_method(:value, '@value ||= 0')
124
+ subject.add_method(:defined, '100')
125
+ subject.eval_and_add_method(:defined) do
126
+ "@value = value + #{options_object.increment || 1}"
127
+ end
122
128
  subject.build
123
129
  end
124
130
 
@@ -130,9 +136,11 @@ describe Sinclair do
130
136
 
131
137
  context 'when readding it' do
132
138
  before do
133
- subject.add_method(:value, "@value ||= 0")
134
- subject.eval_and_add_method(:defined) { "@value = value + #{ options_object.increment || 1 }" }
135
- subject.add_method(:defined, "100")
139
+ subject.add_method(:value, '@value ||= 0')
140
+ subject.eval_and_add_method(:defined) do
141
+ "@value = value + #{options_object.increment || 1}"
142
+ end
143
+ subject.add_method(:defined, '100')
136
144
  subject.build
137
145
  end
138
146
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
 
3
5
  SimpleCov.profiles.define 'gem' do
@@ -9,8 +11,8 @@ SimpleCov.start 'gem'
9
11
  require 'sinclair'
10
12
  require 'pry-nav'
11
13
 
12
- support_files = File.expand_path("spec/support/**/*.rb")
13
- Dir[support_files].each { |file| require file }
14
+ support_files = File.expand_path('spec/support/**/*.rb')
15
+ Dir[support_files].each { |file| require file }
14
16
 
15
17
  RSpec.configure do |config|
16
18
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
 
3
5
  module FixtureHelpers
4
6
  def load_fixture_file(filename)
5
- File.read (['./spec/', 'fixtures', filename].join('/'))
7
+ File.read(['./spec/', 'fixtures', filename].join('/'))
6
8
  end
7
9
 
8
10
  def load_json_fixture_file(filename)
@@ -12,7 +14,7 @@ module FixtureHelpers
12
14
  private
13
15
 
14
16
  def cached_json_fixture_file(filename)
15
- ActiveSupport::JSON.decode(load_fixture_file(filename))
17
+ ActiveSupport::JSON.decode(load_fixture_file(filename))
16
18
  end
17
19
  end
18
20
 
@@ -1,7 +1,11 @@
1
- class Sinclair::DummyBuilder < Sinclair
2
- def init
3
- add_method(:blocked) { 1 }
4
- add_method(:defined, "@value = value + #{ options_object.try(:increment) || 1 }")
5
- add_method(:value, "@value ||= 0")
1
+ # frozen_string_literal: true
2
+
3
+ class Sinclair
4
+ class DummyBuilder < Sinclair
5
+ def init
6
+ add_method(:blocked) { 1 }
7
+ add_method(:defined, "@value = value + #{options_object&.increment || 1}")
8
+ add_method(:value, '@value ||= 0')
9
+ end
6
10
  end
7
11
  end
@@ -1,18 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Sinclair
2
- class OptionsParser::Dummy
3
- include OptionsParser
4
+ module OptionsParser
5
+ class Dummy
6
+ include OptionsParser
4
7
 
5
- def initialize(options)
6
- @options = options.deep_dup
7
- end
8
+ def initialize(options)
9
+ @options = options.deep_dup
10
+ end
8
11
 
9
- def the_method
10
- return 'missing option' if options_object.switch.nil?
12
+ def the_method
13
+ return 'missing option' if options_object.switch.nil?
11
14
 
12
- if options_object.switch
13
- "The value is #{options_object.option_1}"
14
- else
15
- "The value is not #{options_object.option_1} but #{options_object.option_2}"
15
+ if options_object.switch
16
+ "The value is #{options_object.option_1}"
17
+ else
18
+ "The value is not #{options_object.option_1} but #{options_object.option_2}"
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InitialValuer
2
4
  extend ActiveSupport::Concern
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DefaultValue
2
4
  delegate :build, to: :builder
3
5
  attr_reader :klass, :method, :value
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'my_concern'
2
4
 
3
5
  class MyClass
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'validator_builder'
2
4
 
3
5
  module MyConcern
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class MyModel
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Person
2
4
  attr_reader :first_name, :last_name
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Purchase
2
4
  def initialize(value, quantity)
3
5
  @value = value
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ValidationBuilder < Sinclair
2
4
  delegate :expected, to: :options_object
3
5
 
4
- def initialize(klass, options={})
6
+ def initialize(klass, options = {})
5
7
  super
6
8
  end
7
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinclair
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarthJee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,47 +39,47 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: pry-nav
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 12.0.0
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 12.0.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.14'
61
+ version: 12.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.14'
68
+ version: 12.0.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: simplecov
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.16.1
75
+ version: '2.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.16.1
82
+ version: '2.14'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,19 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry-nav
98
+ name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.16.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.16.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: 2.4.0
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
190
  - - ">="