adamantium 0.0.11 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +14 -6
  2. data/.rspec +4 -0
  3. data/.travis.yml +10 -19
  4. data/CONTRIBUTING.md +11 -0
  5. data/Gemfile +5 -2
  6. data/Gemfile.devtools +18 -22
  7. data/Guardfile +22 -8
  8. data/README.md +18 -40
  9. data/Rakefile +2 -0
  10. data/adamantium.gemspec +6 -4
  11. data/config/devtools.yml +2 -0
  12. data/config/flay.yml +1 -1
  13. data/config/reek.yml +64 -50
  14. data/config/rubocop.yml +57 -0
  15. data/lib/adamantium.rb +2 -1
  16. data/lib/adamantium/freezer.rb +1 -1
  17. data/lib/adamantium/module_methods.rb +1 -1
  18. data/lib/adamantium/mutable.rb +3 -1
  19. data/lib/adamantium/version.rb +1 -1
  20. data/spec/integration/adamantium_spec.rb +6 -6
  21. data/spec/spec_helper.rb +20 -7
  22. data/spec/unit/adamantium/class_methods/included_spec.rb +6 -4
  23. data/spec/unit/adamantium/flat/class_methods/included_spec.rb +3 -1
  24. data/spec/unit/adamantium/freeze_spec.rb +6 -6
  25. data/spec/unit/adamantium/freezer/class_methods/parse_spec.rb +5 -5
  26. data/spec/unit/adamantium/freezer/deep/class_methods/call_spec.rb +2 -2
  27. data/spec/unit/adamantium/freezer/deep/class_methods/freeze_spec.rb +1 -2
  28. data/spec/unit/adamantium/freezer/flat/class_methods/call_spec.rb +2 -2
  29. data/spec/unit/adamantium/freezer/flat/class_methods/freeze_spec.rb +1 -1
  30. data/spec/unit/adamantium/memoize_spec.rb +6 -6
  31. data/spec/unit/adamantium/module_methods/memoize_spec.rb +12 -12
  32. data/spec/unit/adamantium/module_methods/memoized_predicate_spec.rb +2 -0
  33. data/spec/unit/adamantium/module_methods/original_instance_method_spec.rb +4 -2
  34. data/spec/unit/adamantium/mutable/freeze_spec.rb +2 -1
  35. data/spec/unit/adamantium/mutable/frozen_predicate_spec.rb +2 -0
  36. metadata +29 -10
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4b0049e404dd0b6bead1b53497d23c5fb32ffc51
4
- data.tar.gz: 3945219defdbbda61deaa701742d312329a6fd55
5
- SHA512:
6
- metadata.gz: 452f5edf8c0a14edb3df5b85b9dc9510a7b22215be98359f131a579eb4436e96e4c6ad1512cbe9fe828becc635b339713e53dd9380d7822b7c5c6e60badee790
7
- data.tar.gz: e3914061c61c9fc2cf29750a741e8c993a8492dafec7f41e127b29173e735ad0fc148e4acbc4a394fc2f27ab4976860500532fc13fdf1664e9448da972c045d1
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzMwMWQ3ODI1Y2FlYTlhNTFjZjhlYTM3NWMyOTgwZjk4NmI4ODFjYg==
5
+ data.tar.gz: !binary |-
6
+ M2RmNzViMTg3YjcxNDdmMDg4ZTBmZTAzMWY5MDYzMDg0Y2U4MGZjZg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjU3MDcxN2UzNzU1ZWZlYzEyY2VkMzgzNWJiNTFhNDc0MmMzNWZhNzJkOGYy
10
+ YTRkNjhkMTRiMmIyMzAwZjk0Yjk2NDJlMmZjODY3NTVhNTNlZDcwZDgwMjMx
11
+ ODRjYjZmOGE4OTZlODNmNTIwMDJiYzE0N2ViNmE2NmQ5YjFiNTM=
12
+ data.tar.gz: !binary |-
13
+ ODY0NDUyODM1YTg3OTMwMWJlMTU4YzFhNzUzZmY1NGE1NWE0ZTQzMmRiMDEz
14
+ ZWExY2RhY2Y4YWQ3MTI1MjBlODRhODlhNWE2Y2ZlYjMxMmI5YjgzYWNhM2Uy
15
+ YTY0NWMwYjNmYzc1ZjcxMWU1OThlMWQyNjgwYWE0NzM2YWZiZjk=
data/.rspec CHANGED
@@ -1 +1,5 @@
1
1
  --color
2
+ --format progress
3
+ --profile
4
+ --warnings
5
+ --order random
@@ -3,23 +3,10 @@ before_install: gem install bundler
3
3
  bundler_args: --without yard guard benchmarks
4
4
  script: "bundle exec rake ci"
5
5
  rvm:
6
- - 1.9.2
7
6
  - 1.9.3
8
7
  - 2.0.0
9
8
  - ruby-head
10
9
  - rbx-19mode
11
- notifications:
12
- irc:
13
- channels:
14
- - irc.freenode.org#rom-rb
15
- on_success: never
16
- on_failure: change
17
- email:
18
- recipients:
19
- - dan.kubb@gmail.com
20
- - mbj@schirp-dso.com
21
- on_success: never
22
- on_failure: change
23
10
  matrix:
24
11
  include:
25
12
  - rvm: jruby-19mode
@@ -27,9 +14,13 @@ matrix:
27
14
  - rvm: jruby-head
28
15
  env: JRUBY_OPTS="$JRUBY_OPTS --debug"
29
16
  allow_failures:
30
- # mutant fails
31
- - rvm: 1.9.3
32
- - rvm: 2.0.0
33
- - rvm: rbx-19mode
34
- # broken on travis
35
- - rvm: ruby-head
17
+ - rvm: 1.9.3 # mutant fails
18
+ - rvm: 2.0.0 # mutant fails
19
+ - rvm: ruby-head # travis broken
20
+ - rvm: rbx-19mode # mutant fails
21
+ notifications:
22
+ irc:
23
+ channels:
24
+ - irc.freenode.org#rom-rb
25
+ on_success: never
26
+ on_failure: change
@@ -0,0 +1,11 @@
1
+ Contributing
2
+ ------------
3
+
4
+ * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin.
5
+ * Fork the project.
6
+ * Make your feature addition or bug fix.
7
+ * Follow this [style guide](https://github.com/dkubb/styleguide).
8
+ * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
9
+ * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
10
+ * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
11
+ * Send me a pull request. Bonus points for topic branches.
data/Gemfile CHANGED
@@ -4,5 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
8
- eval File.read('Gemfile.devtools')
7
+ group :development, :test do
8
+ gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
9
+ end
10
+
11
+ eval_gemfile 'Gemfile.devtools'
@@ -2,8 +2,8 @@
2
2
 
3
3
  group :development do
4
4
  gem 'rake', '~> 10.1.0'
5
- gem 'rspec', '~> 2.13.0'
6
- gem 'yard', '~> 0.8.6.2'
5
+ gem 'rspec', '~> 2.14.1'
6
+ gem 'yard', '~> 0.8.7'
7
7
  end
8
8
 
9
9
  group :yard do
@@ -14,37 +14,33 @@ group :guard do
14
14
  gem 'guard', '~> 1.8.1'
15
15
  gem 'guard-bundler', '~> 1.0.0'
16
16
  gem 'guard-rspec', '~> 3.0.2'
17
+ gem 'guard-rubocop', '~> 0.2.0'
18
+ # gem 'guard-mutant', '~> 0.0.1'
17
19
 
18
20
  # file system change event handling
19
- gem 'listen', '~> 1.2.2'
20
- gem 'rb-fchange', '~> 0.0.6', :require => false
21
- gem 'rb-fsevent', '~> 0.9.3', :require => false
22
- gem 'rb-inotify', '~> 0.9.0', :require => false
21
+ gem 'listen', '~> 1.3.0'
22
+ gem 'rb-fchange', '~> 0.0.6', require: false
23
+ gem 'rb-fsevent', '~> 0.9.3', require: false
24
+ gem 'rb-inotify', '~> 0.9.0', require: false
23
25
 
24
26
  # notification handling
25
- gem 'libnotify', '~> 0.8.0', :require => false
26
- gem 'rb-notifu', '~> 0.0.4', :require => false
27
- gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
27
+ gem 'libnotify', '~> 0.8.0', require: false
28
+ gem 'rb-notifu', '~> 0.0.4', require: false
29
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
28
30
  end
29
31
 
30
32
  group :metrics do
31
33
  gem 'coveralls', '~> 0.6.7'
32
- gem 'flay', '~> 2.3.0'
33
- gem 'flog', '~> 4.1.0'
34
- gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
34
+ gem 'flay', '~> 2.4.0'
35
+ gem 'flog', '~> 4.1.1'
36
+ gem 'reek', '~> 1.3.2'
37
+ gem 'rubocop', '~> 0.11.0'
35
38
  gem 'simplecov', '~> 0.7.1'
36
- gem 'yardstick', '~> 0.9.6'
37
-
38
- platforms :ruby_19 do
39
- gem 'yard-spellcheck', '~> 0.1.5'
40
- end
39
+ gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
41
40
 
42
41
  platforms :ruby_19, :ruby_20 do
43
- gem 'mutant', '~> 0.3.0.beta8'
44
- end
45
-
46
- platforms :rbx do
47
- gem 'pelusa', '~> 0.2.2'
42
+ # gem 'mutant', git: 'https://github.com/mbj/mutant.git'
43
+ gem 'yard-spellcheck', '~> 0.1.5'
48
44
  end
49
45
  end
50
46
 
data/Guardfile CHANGED
@@ -2,17 +2,31 @@
2
2
 
3
3
  guard :bundler do
4
4
  watch('Gemfile')
5
+ watch('Gemfile.lock')
6
+ watch(%w{.+.gemspec\z})
5
7
  end
6
8
 
7
- guard :rspec do
8
- # run all specs if the spec_helper or supporting files files are modified
9
- watch('spec/spec_helper.rb') { 'spec' }
10
- watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
9
+ guard :rspec, cli: File.read('.rspec').split.join(' '), keep_failed: false do
10
+ # Run all specs if configuration is modified
11
+ watch('.rspec') { 'spec' }
12
+ watch('Guardfile') { 'spec' }
13
+ watch('Gemfile.lock') { 'spec' }
14
+ watch('spec/spec_helper.rb') { 'spec' }
11
15
 
12
- # run unit specs if associated lib code is modified
13
- watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
14
- watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
16
+ # Run all specs if supporting files files are modified
17
+ watch(%r{\Aspec/(?:fixtures|lib|support|shared)/.+\.rb\z}) { 'spec' }
15
18
 
16
- # run a spec if it is modified
19
+ # Run unit specs if associated app or lib code is modified
20
+ watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}*"] }
21
+ watch(%r{\Alib/(.+)/support/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}/#{m[2]}*"] }
22
+ watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
23
+
24
+ # Run a spec if it is modified
17
25
  watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
18
26
  end
27
+
28
+ guard :rubocop, cli: %w[--config config/rubocop.yml] do
29
+ watch(%r{.+\.(?:rb|rake)\z})
30
+ watch(%r{\Aconfig/rubocop\.yml\z}) { |m| File.dirname(m[0]) }
31
+ watch(%r{(?:.+/)?\.rubocop\.yml\z}) { |m| File.dirname(m[0]) }
32
+ end
data/README.md CHANGED
@@ -3,36 +3,21 @@ adamantium
3
3
 
4
4
  Create immutable objects
5
5
 
6
- [![Build Status](https://secure.travis-ci.org/dkubb/adamantium.png)](https://travis-ci.org/dkubb/adamantium)
7
- [![Dependency Status](https://gemnasium.com/dkubb/adamantium.png)](https://gemnasium.com/dkubb/adamantium)
8
- [![Code Climate](https://codeclimate.com/github/dkubb/adamantium.png)](https://codeclimate.com/github/dkubb/adamantium)
9
-
10
- This is a small standalone gem featuring a module ripped out from [veritas](https://github.com/dkubb/veritas).
6
+ [![Gem Version](https://badge.fury.io/rb/adamantium.png)][gem]
7
+ [![Build Status](https://secure.travis-ci.org/dkubb/adamantium.png?branch=master)][travis]
8
+ [![Dependency Status](https://gemnasium.com/dkubb/adamantium.png)][gemnasium]
9
+ [![Code Climate](https://codeclimate.com/github/dkubb/adamantium.png)][codeclimate]
10
+ [![Coverage Status](https://coveralls.io/repos/dkubb/adamantium/badge.png?branch=master)][coveralls]
11
+
12
+ [gem]: https://rubygems.org/gems/adamantium
13
+ [travis]: https://travis-ci.org/dkubb/adamantium
14
+ [gemnasium]: https://gemnasium.com/dkubb/adamantium
15
+ [codeclimate]: https://codeclimate.com/github/dkubb/adamantium
16
+ [coveralls]: https://coveralls.io/r/dkubb/adamantium
17
+
18
+ This is a small standalone gem featuring a module ripped out from [axiom](https://github.com/dkubb/axiom).
11
19
  It allows to make objects immutable in an unobtrusive way.
12
20
 
13
- Installation
14
- ------------
15
-
16
- With Rubygems:
17
-
18
- ```bash
19
- $ gem install adamantium
20
- $ irb -rubygems
21
- >> require 'adamantium'
22
- => true
23
- ```
24
-
25
- With git and local working copy:
26
-
27
- ```bash
28
- $ git clone git://github.com/dkubb/adamantium.git
29
- $ cd adamantium
30
- $ rake install
31
- $ irb -rubygems
32
- >> require 'adamantium'
33
- => true
34
- ```
35
-
36
21
  Examples
37
22
  --------
38
23
 
@@ -83,7 +68,7 @@ class Example
83
68
  def buffer
84
69
  StringIO.new
85
70
  end
86
- memoize :buffer, :freezer => :noop
71
+ memoize :buffer, freezer: :noop
87
72
 
88
73
  # Memoized method with nondeeply frozen value
89
74
  # Example:
@@ -97,7 +82,7 @@ class Example
97
82
  def random2
98
83
  [SecureRandom.hex(6)]
99
84
  end
100
- memoize :random2, :freezer => :flat
85
+ memoize :random2, freezer: :flat
101
86
  end
102
87
 
103
88
  class FlatExample
@@ -138,18 +123,11 @@ Credits
138
123
  * Markus Schirp ([mbj](https://github.com/mbj))
139
124
 
140
125
  Contributing
141
- -------------
126
+ ------------
142
127
 
143
- * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin.
144
- * Fork the project.
145
- * Make your feature addition or bug fix.
146
- * Follow this [style guide](https://github.com/dkubb/styleguide).
147
- * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
148
- * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
149
- * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
150
- * Send me a pull request. Bonus points for topic branches.
128
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
151
129
 
152
130
  Copyright
153
131
  ---------
154
132
 
155
- Copyright © 2012 Dan Kubb. See LICENSE for details.
133
+ Copyright © 2012-2013 Dan Kubb. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'devtools'
4
+
3
5
  Devtools.init_rake_tasks
@@ -10,13 +10,15 @@ Gem::Specification.new do |gem|
10
10
  gem.description = 'Immutable extensions to objects'
11
11
  gem.summary = gem.description
12
12
  gem.homepage = 'https://github.com/dkubb/adamantium'
13
+ gem.licenses = 'MIT'
13
14
 
14
15
  gem.require_paths = %w[lib]
15
- gem.files = `git ls-files`.split($/)
16
- gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
17
- gem.extra_rdoc_files = %w[LICENSE README.md TODO]
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- spec/{unit,integration}`.split("\n")
18
+ gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
18
19
 
19
- gem.add_runtime_dependency('ice_nine', '~> 0.8.0')
20
+ gem.add_runtime_dependency('ice_nine', '~> 0.9')
21
+ gem.add_runtime_dependency('thread_safe', '~> 0.1.2')
20
22
 
21
23
  gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
22
24
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ unit_test_timeout: 0.1
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 7
3
- total_score: 56
3
+ total_score: 54
@@ -1,92 +1,106 @@
1
1
  ---
2
- UncommunicativeParameterName:
3
- accept: []
4
- exclude: []
2
+ Attribute:
5
3
  enabled: true
6
- reject:
7
- - !ruby/regexp /^.$/
8
- - !ruby/regexp /[0-9]$/
9
- - !ruby/regexp /[A-Z]/
10
- TooManyMethods:
11
- max_methods: 10
12
4
  exclude: []
5
+ BooleanParameter:
13
6
  enabled: true
14
- max_instance_variables: 2
15
- UncommunicativeMethodName:
16
- accept: []
17
7
  exclude: []
8
+ ClassVariable:
18
9
  enabled: true
19
- reject:
20
- - !ruby/regexp /^[a-z]$/
21
- - !ruby/regexp /[0-9]$/
22
- - !ruby/regexp /[A-Z]/
23
- LongParameterList:
24
- max_params: 2 # TODO: decrease max_params to 2
25
10
  exclude: []
11
+ ControlParameter:
26
12
  enabled: true
27
- overrides: {}
28
- FeatureEnvy:
29
13
  exclude: []
14
+ DataClump:
30
15
  enabled: true
31
- ClassVariable:
32
16
  exclude: []
17
+ max_copies: 2
18
+ min_clump_size: 2
19
+ DuplicateMethodCall:
33
20
  enabled: true
34
- BooleanParameter:
35
21
  exclude: []
22
+ max_calls: 1
23
+ allow_calls: []
24
+ FeatureEnvy:
36
25
  enabled: true
26
+ exclude: []
37
27
  IrresponsibleModule:
28
+ enabled: true
38
29
  exclude: []
30
+ LongParameterList:
39
31
  enabled: true
40
- UncommunicativeModuleName:
41
- accept: []
42
32
  exclude: []
33
+ max_params: 2
34
+ overrides:
35
+ initialize:
36
+ max_params: 3
37
+ LongYieldList:
43
38
  enabled: true
44
- reject:
45
- - !ruby/regexp /^.$/
46
- - !ruby/regexp /[0-9]$/
39
+ exclude: []
40
+ max_params: 2
47
41
  NestedIterators:
48
- ignore_iterators: []
49
- exclude:
50
- - Adamantium::ModuleMethods#define_memoize_method # 2 levels
51
42
  enabled: true
43
+ exclude:
44
+ - Adamantium::ModuleMethods#define_memoize_method
52
45
  max_allowed_nesting: 1
53
- TooManyStatements:
54
- max_statements: 7 # TODO: decrease max_statements to 5 or less
46
+ ignore_iterators: []
47
+ NilCheck:
48
+ enabled: true
55
49
  exclude: []
50
+ RepeatedConditional:
56
51
  enabled: true
57
- DuplicateMethodCall:
58
- allow_calls: []
59
52
  exclude: []
53
+ max_ifs: 1
54
+ TooManyInstanceVariables:
60
55
  enabled: true
61
- max_calls: 1
62
- UtilityFunction:
63
- max_helper_calls: 1
64
56
  exclude: []
57
+ max_instance_variables: 3
58
+ TooManyMethods:
65
59
  enabled: true
66
- Attribute:
67
60
  exclude: []
68
- enabled: false
69
- UncommunicativeVariableName:
61
+ max_methods: 10
62
+ TooManyStatements:
63
+ enabled: true
64
+ exclude:
65
+ - Adamantium::ModuleMethods#define_memoize_method
66
+ - Adamantium::ModuleMethods#memoize_method
67
+ - each
68
+ max_statements: 5
69
+ UncommunicativeMethodName:
70
+ enabled: true
71
+ exclude: []
72
+ reject:
73
+ - !ruby/regexp /^[a-z]$/
74
+ - !ruby/regexp /[0-9]$/
75
+ - !ruby/regexp /[A-Z]/
70
76
  accept: []
77
+ UncommunicativeModuleName:
78
+ enabled: true
71
79
  exclude: []
80
+ reject:
81
+ - !ruby/regexp /^.$/
82
+ - !ruby/regexp /[0-9]$/
83
+ accept: []
84
+ UncommunicativeParameterName:
72
85
  enabled: true
86
+ exclude: []
73
87
  reject:
74
88
  - !ruby/regexp /^.$/
75
89
  - !ruby/regexp /[0-9]$/
76
90
  - !ruby/regexp /[A-Z]/
77
- RepeatedConditional:
78
- exclude: []
91
+ accept: []
92
+ UncommunicativeVariableName:
79
93
  enabled: true
80
- max_ifs: 1
81
- DataClump:
82
94
  exclude: []
95
+ reject:
96
+ - !ruby/regexp /^.$/
97
+ - !ruby/regexp /[0-9]$/
98
+ - !ruby/regexp /[A-Z]/
99
+ accept: []
100
+ UnusedParameters:
83
101
  enabled: true
84
- max_copies: 1
85
- min_clump_size: 3
86
- ControlParameter:
87
102
  exclude: []
103
+ UtilityFunction:
88
104
  enabled: true
89
- LongYieldList:
90
- max_params: 1
91
105
  exclude: []
92
- enabled: true
106
+ max_helper_calls: 0
@@ -0,0 +1,57 @@
1
+ AllCops:
2
+ Includes:
3
+ - '**/*.rake'
4
+ - 'Gemfile'
5
+ - 'Gemfile.devtools'
6
+ Excludes:
7
+ - '**/vendor/**'
8
+
9
+ # Avoid parameter lists longer than five parameters.
10
+ ParameterLists:
11
+ Max: 3
12
+ CountKeywordArgs: true
13
+
14
+ # Avoid more than `Max` levels of nesting.
15
+ BlockNesting:
16
+ Max: 3
17
+
18
+ # Align with the style guide.
19
+ CollectionMethods:
20
+ PreferredMethods:
21
+ collect: 'map'
22
+ inject: 'reduce'
23
+ find: 'detect'
24
+ find_all: 'select'
25
+
26
+ # Do not force public/protected/private keyword to be indented at the same
27
+ # level as the def keyword. My personal preference is to outdent these keywords
28
+ # because I think when scanning code it makes it easier to identify the
29
+ # sections of code and visually separate them. When the keyword is at the same
30
+ # level I think it sort of blends in with the def keywords and makes it harder
31
+ # to scan the code and see where the sections are.
32
+ AccessControl:
33
+ Enabled: false
34
+
35
+ # Limit line length
36
+ LineLength:
37
+ Max: 116 # TODO: lower to 79
38
+
39
+ # Disable documentation checking until a class needs to be documented once
40
+ Documentation:
41
+ Enabled: false
42
+
43
+ # Do not favor modifier if/unless usage when you have a single-line body
44
+ IfUnlessModifier:
45
+ Enabled: false
46
+
47
+ # Allow case equality operator (in limited use within the specs)
48
+ CaseEquality:
49
+ Enabled: false
50
+
51
+ # Constants do not always have to use SCREAMING_SNAKE_CASE
52
+ ConstantName:
53
+ Enabled: false
54
+
55
+ # Not all trivial readers/writers can be defined with attr_* methods
56
+ TrivialAccessors:
57
+ Enabled: false
@@ -1,12 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'ice_nine'
4
+ require 'thread_safe'
4
5
 
5
6
  # Allows objects to be made immutable
6
7
  module Adamantium
7
8
 
8
9
  # Storage for memoized methods
9
- Memory = Class.new(::Hash)
10
+ Memory = Class.new(ThreadSafe::Hash)
10
11
 
11
12
  # Defaults to less strict defaults
12
13
  module Flat
@@ -86,7 +86,7 @@ module Adamantium
86
86
  public_class_method :call
87
87
  end
88
88
 
89
- Noop = lambda { |object| object }.freeze
89
+ Noop = ->(object) { object }.freeze
90
90
 
91
91
  # Error raised when freezer cannot be found
92
92
  class UnknownFreezerError < RuntimeError; end
@@ -134,7 +134,7 @@ module Adamantium
134
134
  # @api private
135
135
  #
136
136
  def memoized_methods
137
- @memoized_methods ||= Hash.new do |_, name|
137
+ @memoized_methods ||= ThreadSafe::Hash.new do |_, name|
138
138
  raise ArgumentError, "No method #{name.inspect} was memoized"
139
139
  end
140
140
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Adamantium
2
4
 
3
5
  # Module fake frozen object
@@ -5,7 +7,7 @@ module Adamantium
5
7
  # This behavior sometimes is needed when a mutable
6
8
  # object needs to be referenced in an inmutable object tree.
7
9
  #
8
- # If you have to use `memoize :foo, :freezer => :noop` to often you might
10
+ # If you have to use `memoize :foo, freezer: :noop` to often you might
9
11
  # want to include this module into your class.
10
12
  #
11
13
  # Use wisely! A rule of thumb only a tiny fraction of your objects
@@ -3,6 +3,6 @@
3
3
  module Adamantium
4
4
 
5
5
  # Gem version
6
- VERSION = '0.0.11'.freeze
6
+ VERSION = '0.1.0'.freeze
7
7
 
8
8
  end # module Adamantium
@@ -38,12 +38,12 @@ describe Adamantium do
38
38
 
39
39
  it 'should deep freeze instance and attributes' do
40
40
  should be_frozen
41
- subject.attribute.should be_frozen
41
+ expect(subject.attribute).to be_frozen
42
42
  end
43
43
 
44
44
  it 'should deep freeze memoized values' do
45
- subject.memoized.should be_frozen
46
- subject.memoized[0].should be_frozen
45
+ expect(subject.memoized).to be_frozen
46
+ expect(subject.memoized[0]).to be_frozen
47
47
  end
48
48
  end
49
49
 
@@ -54,12 +54,12 @@ describe Adamantium do
54
54
 
55
55
  it 'should freeze only instance' do
56
56
  should be_frozen
57
- subject.attribute.should_not be_frozen
57
+ expect(subject.attribute).to_not be_frozen
58
58
  end
59
59
 
60
60
  it 'should flat freeze memoized values' do
61
- subject.memoized.should be_frozen
62
- subject.memoized[0].should_not be_frozen
61
+ expect(subject.memoized).to be_frozen
62
+ expect(subject.memoized[0]).to_not be_frozen
63
63
  end
64
64
  end
65
65
  end
@@ -1,15 +1,28 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'adamantium'
4
3
  require 'devtools/spec_helper'
5
4
 
6
- RSpec.configure do |config|
7
- end
8
-
9
- if RUBY_VERSION >= '1.9' and ENV['COVERAGE'] == 'true'
5
+ if ENV['COVERAGE'] == 'true'
10
6
  require 'simplecov'
7
+ require 'coveralls'
8
+
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ Coveralls::SimpleCov::Formatter
12
+ ]
13
+
11
14
  SimpleCov.start do
12
- command_name 'spec:unit'
13
- add_filter 'spec'
15
+ command_name 'spec:unit'
16
+ add_filter 'config'
17
+ add_filter 'spec'
18
+ minimum_coverage 100
19
+ end
20
+ end
21
+
22
+ require 'adamantium'
23
+
24
+ RSpec.configure do |config|
25
+ config.expect_with :rspec do |expect_with|
26
+ expect_with.syntax = :expect
14
27
  end
15
28
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium, '.included' do
@@ -17,11 +19,11 @@ describe Adamantium, '.included' do
17
19
  it_should_behave_like 'a command method'
18
20
 
19
21
  it 'includes Adamantium::ModuleMethods' do
20
- included_modules.should include(Adamantium::ModuleMethods)
22
+ expect(included_modules).to include(Adamantium::ModuleMethods)
21
23
  end
22
24
 
23
25
  it 'does not include Adamantium::ClassMethods' do
24
- included_modules.should_not include(Adamantium::ClassMethods)
26
+ expect(included_modules).to_not include(Adamantium::ClassMethods)
25
27
  end
26
28
  end
27
29
 
@@ -29,8 +31,8 @@ describe Adamantium, '.included' do
29
31
  let(:target) { Class.new }
30
32
 
31
33
  it 'includes Adamantium::{Class,Module}Methods' do
32
- included_modules.should include(Adamantium::ModuleMethods)
33
- included_modules.should include(Adamantium::ClassMethods)
34
+ expect(included_modules).to include(Adamantium::ModuleMethods)
35
+ expect(included_modules).to include(Adamantium::ClassMethods)
34
36
  end
35
37
 
36
38
  it_should_behave_like 'a command method'
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium::Flat, '.included' do
@@ -10,6 +12,6 @@ describe Adamantium::Flat, '.included' do
10
12
  its(:ancestors) { should include(Adamantium) }
11
13
 
12
14
  it 'extends class with Adamantium::Flat' do
13
- subject.singleton_class.included_modules.should include(described_class)
15
+ expect(subject.singleton_class.included_modules).to include(described_class)
14
16
  end
15
17
  end
@@ -18,15 +18,15 @@ describe Adamantium, '#freeze' do
18
18
  it_should_behave_like 'a command method'
19
19
 
20
20
  it 'freezes the object' do
21
- expect { subject }.to change(object, :frozen?).
22
- from(false).
23
- to(true)
21
+ expect { subject }.to change(object, :frozen?)
22
+ .from(false)
23
+ .to(true)
24
24
  end
25
25
 
26
26
  it 'sets a memoization instance variable' do
27
- object.should_not be_instance_variable_defined(:@__memory)
27
+ expect(object).to_not be_instance_variable_defined(:@__memory)
28
28
  subject
29
- object.instance_variable_get(:@__memory).should be_instance_of(Adamantium::Memory)
29
+ expect(object.instance_variable_get(:@__memory)).to be_instance_of(Adamantium::Memory)
30
30
  end
31
31
  end
32
32
 
@@ -44,7 +44,7 @@ describe Adamantium, '#freeze' do
44
44
  end
45
45
 
46
46
  it 'does not set an instance variable for memoization' do
47
- object.instance_variable_get(:@__memory).should be_instance_of(Adamantium::Memory)
47
+ expect(object.instance_variable_get(:@__memory)).to be_instance_of(Adamantium::Memory)
48
48
  subject
49
49
  end
50
50
  end
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  describe Adamantium::Freezer, '.parse' do
6
6
  subject { object.parse(options) }
7
7
 
8
- let(:object) { described_class }
9
- let(:freezer) { mock('Freezer') }
8
+ let(:object) { described_class }
9
+ let(:freezer) { double('Freezer') }
10
10
 
11
11
  context 'with empty options' do
12
12
  let(:options) { {} }
@@ -15,8 +15,8 @@ describe Adamantium::Freezer, '.parse' do
15
15
  end
16
16
 
17
17
  context 'with :freezer key' do
18
- let(:options) { { :freezer => name } }
19
- let(:name) { mock('Name') }
18
+ let(:options) { { freezer: name } }
19
+ let(:name) { double('Name') }
20
20
 
21
21
  it 'should get freezer' do
22
22
  described_class.should_receive(:get).with(name).and_return(freezer)
@@ -25,7 +25,7 @@ describe Adamantium::Freezer, '.parse' do
25
25
  end
26
26
 
27
27
  context 'with any other key' do
28
- let(:options) { { :other => :key } }
28
+ let(:options) { { other: :key } }
29
29
 
30
30
  it 'should raise error' do
31
31
  expect { subject }.to raise_error(described_class::OptionError, 'Unknown option key(s) for memoizer [:other]')
@@ -82,7 +82,7 @@ describe Adamantium::Freezer::Deep, '.call' do
82
82
 
83
83
  it { should be_instance_of(String) }
84
84
 
85
- it { should == value }
85
+ it { should eql(value) }
86
86
 
87
87
  it { should be_frozen }
88
88
  end
@@ -91,7 +91,7 @@ describe Adamantium::Freezer::Deep, '.call' do
91
91
  let(:value) { [String.new] }
92
92
 
93
93
  it 'does freeze inner values' do
94
- subject.first.should be_frozen
94
+ expect(subject.first).to be_frozen
95
95
  end
96
96
  end
97
97
  end
@@ -6,8 +6,7 @@ describe Adamantium::Freezer::Deep, '.freeze' do
6
6
  subject { object.freeze(value) }
7
7
 
8
8
  let(:object) { described_class }
9
-
10
- let(:value) { mock('Value') }
9
+ let(:value) { double('Value') }
11
10
 
12
11
  it 'should deep freeze value' do
13
12
  IceNine.should_receive(:deep_freeze).with(value).and_return(value)
@@ -50,7 +50,7 @@ describe Adamantium::Freezer::Flat, '.call' do
50
50
 
51
51
  it { should be_instance_of(String) }
52
52
 
53
- it { should == value }
53
+ it { should eql(value) }
54
54
 
55
55
  it { should be_frozen }
56
56
  end
@@ -59,7 +59,7 @@ describe Adamantium::Freezer::Flat, '.call' do
59
59
  let(:value) { [String.new] }
60
60
 
61
61
  it 'does NOT freeze inner values' do
62
- subject.first.should_not be_frozen
62
+ expect(subject.first).to_not be_frozen
63
63
  end
64
64
  end
65
65
  end
@@ -7,7 +7,7 @@ describe Adamantium::Freezer::Flat, '.freeze' do
7
7
 
8
8
  let(:object) { described_class }
9
9
 
10
- let(:value) { mock('Value') }
10
+ let(:value) { double('Value') }
11
11
 
12
12
  it 'should freeze value' do
13
13
  value.should_receive(:freeze).and_return(value)
@@ -19,12 +19,12 @@ describe Adamantium, '#memoize' do
19
19
 
20
20
  it 'sets the memoized value for the method to the value' do
21
21
  subject
22
- object.send(method).should equal(value)
22
+ expect(object.send(method)).to be(value)
23
23
  end
24
24
 
25
25
  it 'creates a method that returns a frozen value' do
26
26
  subject
27
- object.send(method).should be_frozen
27
+ expect(object.send(method)).to be_frozen
28
28
  end
29
29
 
30
30
  it_should_behave_like 'a command method'
@@ -35,20 +35,20 @@ describe Adamantium, '#memoize' do
35
35
 
36
36
  it 'sets the memoized value for the method to the value' do
37
37
  subject
38
- object.send(method).should eql(value)
38
+ expect(object.send(method)).to eql(value)
39
39
  end
40
40
 
41
41
  it 'creates a method that returns a frozen value' do
42
42
  subject
43
- object.send(method).should be_frozen
43
+ expect(object.send(method)).to be_frozen
44
44
  end
45
45
 
46
46
  it_should_behave_like 'a command method'
47
47
  end
48
48
 
49
49
  context 'when the method is already memoized' do
50
- let(:value) { stub }
51
- let(:original) { nil }
50
+ let(:value) { double }
51
+ let(:original) { nil }
52
52
 
53
53
  before do
54
54
  object.memoize(method, original)
@@ -7,18 +7,18 @@ shared_examples_for 'memoizes method' do
7
7
  it 'memoizes the instance method' do
8
8
  subject
9
9
  instance = object.new
10
- instance.send(method).should equal(instance.send(method))
10
+ expect(instance.send(method)).to be(instance.send(method))
11
11
  end
12
12
 
13
13
  it 'creates a method that returns a same value' do
14
14
  subject
15
15
  instance = object.new
16
- instance.send(method).should be(instance.send(method))
16
+ expect(instance.send(method)).to be(instance.send(method))
17
17
  end
18
18
 
19
19
  it 'creates a method with an arity of 0' do
20
20
  subject
21
- object.new.method(method).arity.should be_zero
21
+ expect(object.new.method(method).arity).to be_zero
22
22
  end
23
23
 
24
24
  context 'when the initializer calls the memoized method' do
@@ -29,12 +29,12 @@ shared_examples_for 'memoizes method' do
29
29
 
30
30
  it 'allows the memoized method to be called within the initializer' do
31
31
  subject
32
- expect { object.new }.to_not raise_error(NoMethodError)
32
+ expect { object.new }.to_not raise_error
33
33
  end
34
34
 
35
35
  it 'memoizes the methdod inside the initializer' do
36
36
  subject
37
- object.new.memoized(method).should_not be_nil
37
+ expect(object.new.memoized(method)).to_not be_nil
38
38
  end
39
39
  end
40
40
  end
@@ -61,8 +61,8 @@ describe Adamantium::ModuleMethods, '#memoize' do
61
61
  end
62
62
 
63
63
  context 'with :noop freezer option' do
64
- let(:method) { :some_state }
65
- let(:options) { { :freezer => :noop } }
64
+ let(:method) { :some_state }
65
+ let(:options) { { freezer: :noop } }
66
66
 
67
67
  it_should_behave_like 'a command method'
68
68
  it_should_behave_like 'memoizes method'
@@ -73,7 +73,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
73
73
 
74
74
  it 'creates a method that returns a non frozen value' do
75
75
  subject
76
- object.new.send(method).should_not be_frozen
76
+ expect(object.new.send(method)).to_not be_frozen
77
77
  end
78
78
  end
79
79
 
@@ -85,7 +85,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
85
85
 
86
86
  it 'creates a method that returns a frozen value' do
87
87
  subject
88
- object.new.send(method).should be_frozen
88
+ expect(object.new.send(method)).to be_frozen
89
89
  end
90
90
  end
91
91
 
@@ -101,7 +101,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
101
101
 
102
102
  it 'creates a method that returns a frozen value' do
103
103
  subject
104
- object.new.send(method).should be_frozen
104
+ expect(object.new.send(method)).to be_frozen
105
105
  end
106
106
  end
107
107
 
@@ -117,7 +117,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
117
117
 
118
118
  it 'creates a method that returns a frozen value' do
119
119
  subject
120
- object.new.send(method).should be_frozen
120
+ expect(object.new.send(method)).to be_frozen
121
121
  end
122
122
  end
123
123
 
@@ -133,7 +133,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
133
133
 
134
134
  it 'creates a method that returns a frozen value' do
135
135
  subject
136
- object.new.send(method).should be_frozen
136
+ expect(object.new.send(method)).to be_frozen
137
137
  end
138
138
  end
139
139
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium::ModuleMethods, '#memoized?' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium::ModuleMethods, '#original_instance_method' do
@@ -27,8 +29,8 @@ describe Adamantium::ModuleMethods, '#original_instance_method' do
27
29
  let(:name) { :bar }
28
30
 
29
31
  it 'raises an exception' do
30
- expect { subject }.
31
- to raise_error(ArgumentError, 'No method :bar was memoized')
32
+ expect { subject }
33
+ .to raise_error(ArgumentError, 'No method :bar was memoized')
32
34
  end
33
35
  end
34
36
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium::Mutable, '#freeze' do
@@ -18,4 +20,3 @@ describe Adamantium::Mutable, '#freeze' do
18
20
  object.instance_variable_set(:@foo, :bar)
19
21
  end
20
22
  end
21
-
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Adamantium::Mutable, '#frozen?' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamantium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kubb
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-21 00:00:00.000000000 Z
12
+ date: 2013-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ice_nine
@@ -17,14 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 0.8.0
20
+ version: '0.9'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 0.8.0
27
+ version: '0.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: thread_safe
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.2
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.1.2
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -32,7 +46,7 @@ dependencies:
32
46
  - - ~>
33
47
  - !ruby/object:Gem::Version
34
48
  version: '1.3'
35
- - - '>='
49
+ - - ! '>='
36
50
  - !ruby/object:Gem::Version
37
51
  version: 1.3.5
38
52
  type: :development
@@ -42,7 +56,7 @@ dependencies:
42
56
  - - ~>
43
57
  - !ruby/object:Gem::Version
44
58
  version: '1.3'
45
- - - '>='
59
+ - - ! '>='
46
60
  - !ruby/object:Gem::Version
47
61
  version: 1.3.5
48
62
  description: Immutable extensions to objects
@@ -54,12 +68,14 @@ extensions: []
54
68
  extra_rdoc_files:
55
69
  - LICENSE
56
70
  - README.md
71
+ - CONTRIBUTING.md
57
72
  - TODO
58
73
  files:
59
74
  - .gitignore
60
75
  - .rspec
61
76
  - .ruby-gemset
62
77
  - .travis.yml
78
+ - CONTRIBUTING.md
63
79
  - Gemfile
64
80
  - Gemfile.devtools
65
81
  - Guardfile
@@ -68,12 +84,14 @@ files:
68
84
  - Rakefile
69
85
  - TODO
70
86
  - adamantium.gemspec
87
+ - config/devtools.yml
71
88
  - config/flay.yml
72
89
  - config/flog.yml
73
90
  - config/heckle.yml
74
91
  - config/mutant.yml
75
92
  - config/reek.yml
76
93
  - config/roodi.yml
94
+ - config/rubocop.yml
77
95
  - config/yardstick.yml
78
96
  - lib/adamantium.rb
79
97
  - lib/adamantium/class_methods.rb
@@ -108,7 +126,8 @@ files:
108
126
  - spec/unit/adamantium/mutable/freeze_spec.rb
109
127
  - spec/unit/adamantium/mutable/frozen_predicate_spec.rb
110
128
  homepage: https://github.com/dkubb/adamantium
111
- licenses: []
129
+ licenses:
130
+ - MIT
112
131
  metadata: {}
113
132
  post_install_message:
114
133
  rdoc_options: []
@@ -116,17 +135,17 @@ require_paths:
116
135
  - lib
117
136
  required_ruby_version: !ruby/object:Gem::Requirement
118
137
  requirements:
119
- - - '>='
138
+ - - ! '>='
120
139
  - !ruby/object:Gem::Version
121
140
  version: '0'
122
141
  required_rubygems_version: !ruby/object:Gem::Requirement
123
142
  requirements:
124
- - - '>='
143
+ - - ! '>='
125
144
  - !ruby/object:Gem::Version
126
145
  version: '0'
127
146
  requirements: []
128
147
  rubyforge_project:
129
- rubygems_version: 2.0.2
148
+ rubygems_version: 2.0.6
130
149
  signing_key:
131
150
  specification_version: 4
132
151
  summary: Immutable extensions to objects