anima 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  /.rspec
2
2
  /Gemfile.lock
3
3
  /.rbx
4
+ /.bundle
5
+ /vendor
@@ -1,3 +1,8 @@
1
+ # v0.0.6 2013-02-18
2
+
3
+ * [add] Support for updates via Anima::Update mixin
4
+ * [change] Update dependencies
5
+
1
6
  # v0.0.5 2013-02-17
2
7
 
3
8
  * [changed] Update dependencies
@@ -2,26 +2,25 @@
2
2
 
3
3
  group :development do
4
4
  gem 'rake', '~> 10.0.3'
5
- gem 'rspec', '~> 2.12.0'
6
- gem 'yard', '~> 0.8.4.1'
5
+ gem 'rspec', '~> 2.13.0'
6
+ gem 'yard', '~> 0.8.5'
7
7
  end
8
8
 
9
9
  group :yard do
10
- gem 'redcarpet', '~> 2.2.2', :platforms => [ :mri, :rbx ]
10
+ gem 'kramdown', '~> 0.14.2'
11
11
  end
12
12
 
13
13
  group :guard do
14
14
  gem 'guard', '~> 1.6.2'
15
15
  gem 'guard-bundler', '~> 1.0.0'
16
- gem 'guard-rspec', '~> 2.3.3'
16
+ gem 'guard-rspec', '~> 2.4.1'
17
17
 
18
18
  # file system change event handling
19
19
  gem 'rb-fchange', '~> 0.0.6', :require => false
20
20
  gem 'rb-fsevent', '~> 0.9.3', :require => false
21
21
  gem 'rb-inotify', '~> 0.9.0', :require => false
22
22
 
23
- # Remove this one https://github.com/guard/listen/pull/78 is released
24
- gem 'listen', '~> 0.7.2', :git => 'https://github.com/guard/listen.git'
23
+ gem 'listen', '~> 0.7.3'
25
24
 
26
25
  # notification handling
27
26
  gem 'libnotify', '~> 0.8.0', :require => false
@@ -30,11 +29,11 @@ group :guard do
30
29
  end
31
30
 
32
31
  group :metrics do
33
- gem 'flay', '~> 1.4.3'
34
- gem 'flog', '~> 2.5.3'
35
- gem 'reek', '~> 1.2.13', :git => 'https://github.com/troessner/reek.git', :ref => 'ef77fcecaa21c9ebcbe4d9a79d41b0e70196bf18'
36
- gem 'roodi', '~> 2.2.0'
37
- gem 'yardstick', '~> 0.9.2'
32
+ gem 'flay', '~> 2.1.0'
33
+ gem 'flog', '~> 3.2.2'
34
+ gem 'reek', '~> 1.3.1'
35
+ gem 'metric_fu-roodi', '~> 2.2.1'
36
+ gem 'yardstick', '~> 0.9.3'
38
37
 
39
38
  platforms :ruby_18, :ruby_19 do
40
39
  # this indirectly depends on ffi which does not build on ruby-head
@@ -42,7 +41,7 @@ group :metrics do
42
41
  end
43
42
 
44
43
  platforms :mri_19, :rbx do
45
- gem 'mutant', '~> 0.2.17'
44
+ gem 'mutant', '~> 0.2.20'
46
45
  end
47
46
 
48
47
  platforms :mri_19 do
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'anima'
5
- s.version = '0.0.5'
5
+ s.version = '0.0.6'
6
6
 
7
7
  s.authors = ['Markus Schirp']
8
8
  s.email = 'mbj@seonic.net'
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.require_paths = %w(lib)
15
15
  s.extra_rdoc_files = %w(README.md)
16
16
 
17
- s.add_dependency('backports', '~> 2.8.2')
17
+ s.add_dependency('backports', [ '~> 3.0', '>= 3.0.3' ])
18
18
  s.add_dependency('adamantium', '~> 0.0.6')
19
19
  s.add_dependency('equalizer', '~> 0.0.4')
20
- s.add_dependency('abstract_type', '~> 0.0.3')
20
+ s.add_dependency('abstract_type', '~> 0.0.4')
21
21
  end
@@ -1,3 +1,3 @@
1
1
  ---
2
- threshold: 10
3
- total_score: 53
2
+ threshold: 7
3
+ total_score: 29
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 15.1
2
+ threshold: 12.8
@@ -165,3 +165,4 @@ end
165
165
 
166
166
  require 'anima/error'
167
167
  require 'anima/attribute'
168
+ require 'anima/update'
@@ -0,0 +1,29 @@
1
+ class Anima
2
+ # Module for mixin in update functionallity to anima infected clases
3
+ module Update
4
+
5
+ # Return updated instance
6
+ #
7
+ # @example
8
+ # klass = Class.new do
9
+ # include Anima.new(:foo, :bar), Anima::Update
10
+ # end
11
+ #
12
+ # instance = klass.new(:foo => 1, :bar => 2)
13
+ # updated = instance.update(:foo => 3)
14
+ # updated.foo # => 3
15
+ # updated.bar # => 2
16
+ #
17
+ # @param [Hash] attributes
18
+ #
19
+ # @return [Anima]
20
+ #
21
+ # @api private
22
+ #
23
+ def update(attributes)
24
+ klass = self.class
25
+ klass.new(klass.attributes_hash(self).merge(attributes))
26
+ end
27
+
28
+ end
29
+ end
@@ -1,14 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'anima'
4
- require 'rspec'
5
-
6
- # require spec support files and shared behavior
7
- Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each { |f| require(f) }
8
-
9
- if RUBY_VERSION < '1.9'
10
- require 'rspec/autorun'
11
- end
4
+ require 'devtools'
5
+ Devtools.init_spec_helper
12
6
 
13
7
  RSpec.configure do |config|
14
8
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Anima::Update, '#update' do
4
+ subject { object.update(attributes) }
5
+
6
+ let(:object) { class_under_test.new(:foo => 1, :bar => 2) }
7
+
8
+ let(:class_under_test) do
9
+ Class.new do
10
+ include Anima.new(:foo, :bar), Anima::Update
11
+ end
12
+ end
13
+
14
+ context 'with empty attributes' do
15
+ let(:attributes) { {} }
16
+
17
+ it { should eql(object) }
18
+ end
19
+
20
+ context 'with updated attribute' do
21
+ let(:attributes) { {:foo => 3} }
22
+
23
+ it { should eql(class_under_test.new(:foo => 3, :bar => 2)) }
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anima
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-17 00:00:00.000000000 Z
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: backports
@@ -18,7 +18,10 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.8.2
21
+ version: '3.0'
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 3.0.3
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +29,10 @@ dependencies:
26
29
  requirements:
27
30
  - - ~>
28
31
  - !ruby/object:Gem::Version
29
- version: 2.8.2
32
+ version: '3.0'
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 3.0.3
30
36
  - !ruby/object:Gem::Dependency
31
37
  name: adamantium
32
38
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +72,7 @@ dependencies:
66
72
  requirements:
67
73
  - - ~>
68
74
  - !ruby/object:Gem::Version
69
- version: 0.0.3
75
+ version: 0.0.4
70
76
  type: :runtime
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +80,7 @@ dependencies:
74
80
  requirements:
75
81
  - - ~>
76
82
  - !ruby/object:Gem::Version
77
- version: 0.0.3
83
+ version: 0.0.4
78
84
  description:
79
85
  email: mbj@seonic.net
80
86
  executables: []
@@ -102,12 +108,8 @@ files:
102
108
  - lib/anima.rb
103
109
  - lib/anima/attribute.rb
104
110
  - lib/anima/error.rb
111
+ - lib/anima/update.rb
105
112
  - spec/integration/simple_spec.rb
106
- - spec/shared/command_method_behavior.rb
107
- - spec/shared/each_method_behaviour.rb
108
- - spec/shared/hash_method_behavior.rb
109
- - spec/shared/idempotent_method_behavior.rb
110
- - spec/shared/invertible_method_behaviour.rb
111
113
  - spec/spec_helper.rb
112
114
  - spec/unit/anima/attribute/define_reader_spec.rb
113
115
  - spec/unit/anima/attribute/get_spec.rb
@@ -119,6 +121,7 @@ files:
119
121
  - spec/unit/anima/error/message_spec.rb
120
122
  - spec/unit/anima/included_spec.rb
121
123
  - spec/unit/anima/initialize_instance_spec.rb
124
+ - spec/unit/anima/update/update_spec.rb
122
125
  homepage: http://github.com/mbj/anima
123
126
  licenses: []
124
127
  post_install_message:
@@ -145,11 +148,6 @@ specification_version: 3
145
148
  summary: Attributes for Plain Old Ruby Objects Experiment
146
149
  test_files:
147
150
  - spec/integration/simple_spec.rb
148
- - spec/shared/command_method_behavior.rb
149
- - spec/shared/each_method_behaviour.rb
150
- - spec/shared/hash_method_behavior.rb
151
- - spec/shared/idempotent_method_behavior.rb
152
- - spec/shared/invertible_method_behaviour.rb
153
151
  - spec/spec_helper.rb
154
152
  - spec/unit/anima/attribute/define_reader_spec.rb
155
153
  - spec/unit/anima/attribute/get_spec.rb
@@ -161,4 +159,5 @@ test_files:
161
159
  - spec/unit/anima/error/message_spec.rb
162
160
  - spec/unit/anima/included_spec.rb
163
161
  - spec/unit/anima/initialize_instance_spec.rb
162
+ - spec/unit/anima/update/update_spec.rb
164
163
  has_rdoc:
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- shared_examples_for 'a command method' do
4
- it 'returns self' do
5
- should equal(object)
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- shared_examples_for 'an #each method' do
4
- it_should_behave_like 'a command method'
5
-
6
- context 'with no block' do
7
- subject { object.each }
8
-
9
- it { should be_instance_of(to_enum.class) }
10
-
11
- it 'yields the expected values' do
12
- subject.to_a.should eql(object.to_a)
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
-
3
- shared_examples_for 'a hash method' do
4
- it_should_behave_like 'an idempotent method'
5
-
6
- specification = proc do
7
- should be_instance_of(Fixnum)
8
- end
9
-
10
- it 'is a fixnum' do
11
- instance_eval(&specification)
12
- end
13
-
14
- it 'memoizes the hash code' do
15
- subject.should eql(object.memoized(:hash))
16
- end
17
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- shared_examples_for 'an idempotent method' do
4
- it 'is idempotent' do
5
- should equal(instance_eval(&self.class.subject))
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- shared_examples_for 'an invertible method' do
4
- it_should_behave_like 'an idempotent method'
5
-
6
- it 'is invertible' do
7
- subject.inverse.should equal(object)
8
- end
9
- end