adamantium 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,17 +3,19 @@ before_install: gem install bundler
3
3
  bundler_args: --without yard guard metrics benchmarks
4
4
  script: "bundle exec rake spec"
5
5
  rvm:
6
+ - ree
6
7
  - 1.8.7
7
8
  - 1.9.2
8
9
  - 1.9.3
10
+ - 2.0.0
11
+ - ruby-head
9
12
  - jruby-18mode
10
13
  - jruby-19mode
14
+ - jruby-head
11
15
  - rbx-18mode
12
16
  - rbx-19mode
13
- - ree
14
- - ruby-head
15
- - jruby-head
16
17
  notifications:
18
+ irc: "irc.freenode.org#datamapper"
17
19
  email:
18
20
  - dan.kubb@gmail.com
19
21
  - mbj@seonic.net
data/Gemfile CHANGED
@@ -9,26 +9,26 @@ group :yard do
9
9
  end
10
10
 
11
11
  group :guard do
12
- gem 'guard', '~> 1.5.4'
12
+ gem 'guard', '~> 1.6.2'
13
13
  gem 'guard-bundler', '~> 1.0.0'
14
14
  gem 'guard-rspec', '~> 1.2.1'
15
- end
16
15
 
17
- group :benchmarks do
18
- gem 'rbench', '~> 0.2.3'
19
- end
16
+ # file system change event handling
17
+ gem 'rb-fchange', '~> 0.0.6', :require => false
18
+ gem 'rb-fsevent', '~> 0.9.3', :require => false
19
+ gem 'rb-inotify', '~> 0.9.0', :require => false
20
20
 
21
- platform :jruby do
22
- group :jruby do
23
- gem 'jruby-openssl', '~> 0.8.2'
24
- end
21
+ # notification handling
22
+ gem 'libnotify', '~> 0.8.0', :require => false
23
+ gem 'rb-notifu', '~> 0.0.4', :require => false
24
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
25
25
  end
26
26
 
27
27
  group :metrics do
28
28
  gem 'flay', '~> 1.4.3'
29
29
  gem 'flog', '~> 2.5.3'
30
- gem 'roodi', '~> 2.1.0'
31
- gem 'yardstick', '~> 0.8.0', :git => 'https://github.com/dkubb/yardstick.git'
30
+ gem 'roodi', '~> 2.2.0'
31
+ gem 'yardstick', '~> 0.9.2'
32
32
 
33
33
  platforms :ruby_18, :ruby_19 do
34
34
  # this indirectly depends on ffi which does not build on ruby-head
@@ -36,18 +36,19 @@ group :metrics do
36
36
  end
37
37
 
38
38
  platforms :mri_18 do
39
- gem 'arrayfields', '~> 4.7.4' # for metric_fu
40
- gem 'fattr', '~> 2.2.0' # for metric_fu
41
- gem 'heckle', '~> 1.4.3'
42
- gem 'json', '~> 1.7.3' # for metric_fu rake task
43
- gem 'map', '~> 6.2.0' # for metric_fu
44
- gem 'metric_fu', '~> 2.1.1'
45
- gem 'mspec', '~> 1.5.17'
46
- gem 'rcov', '~> 1.0.0'
47
- gem 'ruby2ruby', '= 1.2.2' # for heckle
39
+ gem 'arrayfields', '~> 4.7.4' # for metric_fu
40
+ gem 'fattr', '~> 2.2.0' # for metric_fu
41
+ gem 'heckle', '~> 1.4.3'
42
+ gem 'json', '~> 1.7.7' # for metric_fu rake task
43
+ gem 'map', '~> 6.3.0' # for metric_fu
44
+ gem 'metric_fu', '~> 2.1.1'
45
+ gem 'mspec', '~> 1.5.17'
46
+ gem 'rails_best_practices', '= 1.13.3' # for metric_fu
47
+ gem 'rcov', '~> 1.0.0'
48
+ gem 'ruby2ruby', '= 1.2.2' # for heckle
48
49
  end
49
50
 
50
- platforms :ruby_19 do
51
+ platforms :mri_19 do
51
52
  gem 'simplecov', '~> 0.7.1'
52
53
  end
53
54
 
@@ -55,3 +56,13 @@ group :metrics do
55
56
  gem 'pelusa', '~> 0.2.2'
56
57
  end
57
58
  end
59
+
60
+ group :benchmarks do
61
+ gem 'rbench', '~> 0.2.3'
62
+ end
63
+
64
+ platform :jruby do
65
+ group :jruby do
66
+ gem 'jruby-openssl', '~> 0.8.2'
67
+ end
68
+ end
data/README.md CHANGED
@@ -5,7 +5,7 @@ Create immutable objects
5
5
 
6
6
  [![Build Status](https://secure.travis-ci.org/dkubb/adamantium.png)](https://travis-ci.org/dkubb/adamantium)
7
7
  [![Dependency Status](https://gemnasium.com/dkubb/adamantium.png)](https://gemnasium.com/dkubb/adamantium)
8
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/dkubb/adamantium)
8
+ [![Code Climate](https://codeclimate.com/github/dkubb/adamantium.png)](https://codeclimate.com/github/dkubb/adamantium)
9
9
 
10
10
  This is a small standalone gem featuring a module ripped out from [veritas](https://github.com/dkubb/veritas).
11
11
  It allows to make objects immutable in an unobtrusive way.
@@ -16,10 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
17
17
  gem.extra_rdoc_files = %w[LICENSE README.md TODO]
18
18
 
19
- gem.add_runtime_dependency('backports', '~> 2.7.0')
20
- gem.add_runtime_dependency('ice_nine', '~> 0.6.0')
19
+ gem.add_runtime_dependency('backports', '~> 2.8.2')
20
+ gem.add_runtime_dependency('ice_nine', '~> 0.7.0')
21
21
 
22
22
  gem.add_development_dependency('rake', '~> 10.0.3')
23
23
  gem.add_development_dependency('rspec', '~> 1.3.2')
24
- gem.add_development_dependency('yard', '~> 0.8.3')
24
+ gem.add_development_dependency('yard', '~> 0.8.4.1')
25
25
  end
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 21.3
2
+ threshold: 20.6
@@ -30,7 +30,6 @@ module Adamantium
30
30
  super
31
31
  descendant.send(:include, Adamantium)
32
32
  descendant.extend(self)
33
-
34
33
  self
35
34
  end
36
35
  end
@@ -94,7 +93,6 @@ module Adamantium
94
93
  unless memory.key?(name)
95
94
  store_memory(name, freeze_object(value))
96
95
  end
97
-
98
96
  self
99
97
  end
100
98
 
@@ -100,12 +100,9 @@ module Adamantium
100
100
  # @api private
101
101
  def self.get(name)
102
102
  case name
103
- when :noop
104
- Noop
105
- when :deep
106
- Deep
107
- when :flat
108
- Flat
103
+ when :noop then Noop
104
+ when :deep then Deep
105
+ when :flat then Flat
109
106
  else
110
107
  raise UnknownFreezerError, "Freezer with name #{name.inspect} is unknown"
111
108
  end
@@ -126,14 +123,10 @@ module Adamantium
126
123
  #
127
124
  def self.parse(options)
128
125
  keys = options.keys - [:freezer]
129
-
130
126
  unless keys.empty?
131
127
  raise OptionError, "Unknown option key(s) for memoizer #{keys.inspect}"
132
128
  end
133
-
134
- return unless options.key?(:freezer)
135
-
136
- get(options.fetch(:freezer))
129
+ get(options.fetch(:freezer)) if options.key?(:freezer)
137
130
  end
138
131
  end
139
132
  end
@@ -79,9 +79,9 @@ module Adamantium
79
79
  def define_memoize_method(method, freezer)
80
80
  method_name = method.name.to_sym
81
81
  undef_method(method_name)
82
- define_method(method_name) do |*args|
82
+ define_method(method_name) do ||
83
83
  memory.fetch(method_name) do
84
- value = method.bind(self).call(*args)
84
+ value = method.bind(self).call
85
85
  frozen = freezer.call(value)
86
86
  store_memory(method_name, frozen)
87
87
  end
@@ -1,3 +1,3 @@
1
1
  module Adamantium
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -13,31 +13,12 @@ shared_examples_for 'memoizes method' do
13
13
  it 'creates a method that returns a same value' do
14
14
  subject
15
15
  instance = object.new
16
- first = instance.send(method)
17
- second = instance.send(method)
18
- first.should be(second)
16
+ instance.send(method).should be(instance.send(method))
19
17
  end
20
18
 
21
- specification = proc do
19
+ it 'creates a method with an arity of 0' do
22
20
  subject
23
- if method != :some_state
24
- file, line = object.new.send(method).first.split(':')[0, 2]
25
- File.expand_path(file).should eql(File.expand_path('../../../../../lib/adamantium/module_methods.rb', __FILE__))
26
- line.to_i.should eql(84)
27
- end
28
- end
29
-
30
- it 'sets the file and line number properly' do
31
- # Exclude example for methot that does not return caller
32
- if method == :some_method
33
- return
34
- end
35
-
36
- if RUBY_PLATFORM.include?('java')
37
- pending('Kernel#caller returns the incorrect line number in JRuby', &specification)
38
- else
39
- instance_eval(&specification)
40
- end
21
+ object.new.method(method).arity.should be_zero
41
22
  end
42
23
 
43
24
  context 'when the initializer calls the memoized method' do
@@ -60,6 +41,7 @@ end
60
41
 
61
42
  describe Adamantium::ModuleMethods, '#memoize' do
62
43
  subject { object.memoize(method, options) }
44
+
63
45
  let(:options) { {} }
64
46
 
65
47
  let(:object) do
@@ -69,7 +51,7 @@ describe Adamantium::ModuleMethods, '#memoize' do
69
51
  end
70
52
  end
71
53
  end
72
-
54
+
73
55
  context 'on method with arguments' do
74
56
  let(:method) { :argumented }
75
57
 
@@ -5,5 +5,5 @@ task :ci => %w[ ci:metrics metrics:heckle ]
5
5
 
6
6
  namespace :ci do
7
7
  desc 'Run metrics (except heckle) and spec'
8
- task :metrics => %w[ spec metrics:verify_measurements metrics:flog metrics:flay metrics:reek metrics:roodi metrics:all ]
8
+ task :metrics => %w[ spec metrics:verify_measurements metrics:flog metrics:flay metrics:roodi metrics:all ]
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamantium
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Kubb
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-01-20 00:00:00 Z
19
+ date: 2013-02-16 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: backports
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 19
29
+ hash: 43
30
30
  segments:
31
31
  - 2
32
- - 7
33
- - 0
34
- version: 2.7.0
32
+ - 8
33
+ - 2
34
+ version: 2.8.2
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 7
45
+ hash: 3
46
46
  segments:
47
47
  - 0
48
- - 6
48
+ - 7
49
49
  - 0
50
- version: 0.6.0
50
+ version: 0.7.0
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -90,12 +90,13 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- hash: 57
93
+ hash: 29
94
94
  segments:
95
95
  - 0
96
96
  - 8
97
- - 3
98
- version: 0.8.3
97
+ - 4
98
+ - 1
99
+ version: 0.8.4.1
99
100
  type: :development
100
101
  version_requirements: *id005
101
102
  description: Immutable extensions to objects
@@ -162,7 +163,6 @@ files:
162
163
  - tasks/metrics/flog.rake
163
164
  - tasks/metrics/heckle.rake
164
165
  - tasks/metrics/metric_fu.rake
165
- - tasks/metrics/reek.rake
166
166
  - tasks/metrics/roodi.rake
167
167
  - tasks/metrics/yardstick.rake
168
168
  - tasks/spec.rake
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements: []
197
197
 
198
198
  rubyforge_project:
199
- rubygems_version: 1.8.24
199
+ rubygems_version: 1.8.25
200
200
  signing_key:
201
201
  specification_version: 3
202
202
  summary: Immutable extensions to objects
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require 'reek/rake/task'
5
-
6
- RBX_18_MODE = RUBY_VERSION < '1.9' && defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
-
8
- namespace :metrics do
9
- Reek::Rake::Task.new do |t|
10
- # reek has some problems under rbx in 1.8 mode that cause the underlying
11
- # script to raise an exception. Rather than halt the "rake ci" process due
12
- # to one bug, we choose to ignore it in this specific case until reek can be
13
- # fixed.
14
- t.fail_on_error = ! RBX_18_MODE # always true, except under rbx 18 mode
15
- end
16
- end
17
- rescue LoadError
18
- task :reek do
19
- $stderr.puts 'Reek is not available. In order to run reek, you must: gem install reek'
20
- end
21
- end