deep_clonable 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ /pkg
2
+ *~
3
+ Gemfile.lock
@@ -0,0 +1 @@
1
+ deep_clonable
@@ -0,0 +1 @@
1
+ ree-1.8.7-2012.02
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://www.rubygems.org"
2
+
3
+ gemspec
data/Rakefile CHANGED
@@ -1,44 +1,10 @@
1
- require 'rake'
2
1
  require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |s|
8
- s.name = "deep_clonable"
9
- s.summary = %Q{Add support for deep cloning to objects}
10
- s.email = "code@justinbalthrop.com"
11
- s.homepage = "http://github.com/ninjudd/deep_clonable"
12
- s.description = " Add support for deep cloning to objects"
13
- s.authors = ["Justin Balthrop"]
14
- end
15
- Jeweler::GemcutterTasks.new
16
- rescue LoadError
17
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
- end
2
+ require 'bundler/gem_tasks'
19
3
 
20
4
  Rake::TestTask.new do |t|
21
- t.libs << 'lib'
5
+ t.libs = ['lib']
22
6
  t.pattern = 'test/**/*_test.rb'
23
7
  t.verbose = false
24
8
  end
25
9
 
26
- Rake::RDocTask.new do |rdoc|
27
- rdoc.rdoc_dir = 'rdoc'
28
- rdoc.title = 'deep_clonable'
29
- rdoc.options << '--line-numbers' << '--inline-source'
30
- rdoc.rdoc_files.include('README*')
31
- rdoc.rdoc_files.include('lib/**/*.rb')
32
- end
33
-
34
- begin
35
- require 'rcov/rcovtask'
36
- Rcov::RcovTask.new do |t|
37
- t.libs << 'test'
38
- t.test_files = FileList['test/**/*_test.rb']
39
- t.verbose = true
40
- end
41
- rescue LoadError
42
- end
43
-
44
10
  task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -1,44 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{deep_clonable}
8
- s.version = "1.1.0"
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "deep_clonable"
6
+ gem.version = IO.read('VERSION')
7
+ gem.authors = ["Justin Balthrop"]
8
+ gem.email = ["git@justinbalthrop.com"]
9
+ gem.description = %q{Add support for deep cloning to objects}
10
+ gem.summary = gem.description
11
+ gem.homepage = "https://github.com/ninjudd/deep_clonable"
9
12
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Justin Balthrop"]
12
- s.date = %q{2011-06-02}
13
- s.description = %q{ Add support for deep cloning to objects}
14
- s.email = %q{code@justinbalthrop.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- "LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "deep_clonable.gemspec",
25
- "lib/deep_clonable.rb",
26
- "test/deep_clonable_test.rb",
27
- "test/test_helper.rb"
28
- ]
29
- s.homepage = %q{http://github.com/ninjudd/deep_clonable}
30
- s.require_paths = ["lib"]
31
- s.rubygems_version = %q{1.3.7}
32
- s.summary = %q{Add support for deep cloning to objects}
13
+ gem.add_development_dependency 'shoulda', '3.0.1'
14
+ gem.add_development_dependency 'mocha'
15
+ gem.add_development_dependency 'rake'
33
16
 
34
- if s.respond_to? :specification_version then
35
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
36
- s.specification_version = 3
37
-
38
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
- else
40
- end
41
- else
42
- end
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
43
21
  end
44
-
@@ -8,22 +8,22 @@ end
8
8
  module DeepClonable
9
9
  module InstanceMethods
10
10
  def clone
11
- was_frozen = frozen?
12
- cloned_object = super.dup
13
- cloned_object = yield(cloned_object) if block_given?
14
- was_frozen ? cloned_object.freeze : cloned_object
11
+ cloned_object = dup
12
+ yield(cloned_object) if block_given?
13
+ frozen? ? cloned_object.freeze : cloned_object
15
14
  end
16
15
 
17
- def dup(method = :dup)
16
+ def dup
18
17
  cloned_object = super()
19
- cloned_object.update_vars(deep_vars, method)
18
+ cloned_object.update_vars(deep_vars, :dup)
20
19
  cloned_object
21
20
  end
22
21
 
23
22
  alias old_freeze freeze
24
23
 
25
24
  def freeze
26
- dup(:freeze).old_freeze
25
+ update_vars(deep_vars, :freeze)
26
+ old_freeze
27
27
  end
28
28
 
29
29
  # You can override deep_vars in your class to specify which instance_variables should be deep cloned.
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class TestClass
4
4
  deep_clonable
@@ -27,7 +27,7 @@ class TestClass
27
27
  end
28
28
 
29
29
  class DeepClonableTest < Test::Unit::TestCase
30
- should "clone method" do
30
+ should 'clone method' do
31
31
  a = TestClass.new(10, {:a => 1}, [1,2,3])
32
32
  b = a.invert
33
33
 
@@ -58,7 +58,7 @@ class DeepClonableTest < Test::Unit::TestCase
58
58
  assert_equal([1,2,3], c.array)
59
59
  end
60
60
 
61
- should "return a frozen object when cloning a frozen object" do
61
+ should 'return a frozen object when cloning a frozen object' do
62
62
  a = TestClass.new(10, {:a => 1}, [1,2,3]).freeze
63
63
 
64
64
  assert_raises(TypeError) do
@@ -80,7 +80,7 @@ class DeepClonableTest < Test::Unit::TestCase
80
80
  assert a.clone.frozen?
81
81
  end
82
82
 
83
- should "unfreeze an object when duping" do
83
+ should 'unfreeze an object when duping' do
84
84
  a = TestClass.new(10, {:a => 1}, [1,2,3]).freeze
85
85
  b = a.dup
86
86
 
@@ -1,9 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
- require 'mocha'
4
+ require 'mocha/setup'
5
5
 
6
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
7
6
  require 'deep_clonable'
8
7
 
9
8
  class Test::Unit::TestCase
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_clonable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Balthrop
@@ -15,20 +15,67 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-02 00:00:00 -07:00
18
+ date: 2013-06-03 00:00:00 -07:00
19
19
  default_executable:
20
- dependencies: []
21
-
22
- description: "\tAdd support for deep cloning to objects"
23
- email: code@justinbalthrop.com
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 1
34
+ version: 3.0.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rake
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ description: Add support for deep cloning to objects
66
+ email:
67
+ - git@justinbalthrop.com
24
68
  executables: []
25
69
 
26
70
  extensions: []
27
71
 
28
- extra_rdoc_files:
29
- - LICENSE
30
- - README.rdoc
72
+ extra_rdoc_files: []
73
+
31
74
  files:
75
+ - .gitignore
76
+ - .rbenv-gemsets
77
+ - .rbenv-version
78
+ - Gemfile
32
79
  - LICENSE
33
80
  - README.rdoc
34
81
  - Rakefile
@@ -38,7 +85,7 @@ files:
38
85
  - test/deep_clonable_test.rb
39
86
  - test/test_helper.rb
40
87
  has_rdoc: true
41
- homepage: http://github.com/ninjudd/deep_clonable
88
+ homepage: https://github.com/ninjudd/deep_clonable
42
89
  licenses: []
43
90
 
44
91
  post_install_message:
@@ -67,9 +114,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
114
  requirements: []
68
115
 
69
116
  rubyforge_project:
70
- rubygems_version: 1.3.7
117
+ rubygems_version: 1.5.2
71
118
  signing_key:
72
119
  specification_version: 3
73
120
  summary: Add support for deep cloning to objects
74
- test_files: []
75
-
121
+ test_files:
122
+ - test/deep_clonable_test.rb
123
+ - test/test_helper.rb