duck_puncher 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd7bb9b78276814a980391bcd2aaa484842651c
4
- data.tar.gz: 0a9daa1a7e6938ca3ea25fa7326779bb9771142a
3
+ metadata.gz: 82d81798a5571df6798f22fb5992e6661bfaed33
4
+ data.tar.gz: 4149ee3e005d014077302a4cdb58e66919a5dace
5
5
  SHA512:
6
- metadata.gz: da795cdef2c5829430ec572287444c7a05edb6e60c1fd46627f68c701131d9ae911c4a5bff539d178e6ae335d0a9993259a392c57db7b1812f98a45be4cb8c0d
7
- data.tar.gz: db4675a9f8804cc8e4465d1cf38ac7995a7e4a38370c66502dbb0d61fdac9883cc0d22d21b8d856d281f04ab5bcb444d426e8a1b5eef911cffe5ba756ad778f3
6
+ metadata.gz: be39db7e9786c8e26ffb380da1d104692699b2d15521acb3ff149284ee13aabdb6b3e4de55a98528a681ee6d67cedd828de148da6f4932f3e192e7252301d65b
7
+ data.tar.gz: abd91da05a36d4679d99d0710e0749b122159613dbb110366f3a26f3e83d9155fcfc03f7e78bfe27d8a4c3d7f73801fcc4aa4280dc2c9147d0ff1f7411465fb0
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
4
 
@@ -0,0 +1,9 @@
1
+ module DuckPuncher
2
+ module Object
3
+ def clone!
4
+ Marshal.load Marshal.dump self
5
+ end unless defined? clone!
6
+ end
7
+ end
8
+
9
+ Object.send(:include, DuckPuncher::Object)
@@ -1,3 +1,3 @@
1
1
  module DuckPuncher
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/lib/duck_puncher.rb CHANGED
@@ -1,10 +1,21 @@
1
1
  require 'duck_puncher/version'
2
- require 'duck_puncher/array'
3
- require 'duck_puncher/numeric'
4
- require 'duck_puncher/hash'
5
- require 'duck_puncher/string'
6
2
 
7
3
  module DuckPuncher
8
- end
4
+ autoload :Array, 'duck_puncher/array'
5
+ autoload :Numeric, 'duck_puncher/numeric'
6
+ autoload :Hash, 'duck_puncher/hash'
7
+ autoload :String, 'duck_puncher/string'
8
+ autoload :Object, 'duck_puncher/object'
9
+
10
+ if defined? ActiveRecord
11
+ autoload :ActiveRecordExtensions, 'duck_puncher/active_record_extensions'
12
+ end
9
13
 
10
- require 'duck_puncher/active_record_extensions' if defined? ActiveRecord
14
+ def self.load!(*names)
15
+ names.each &method(:const_get)
16
+ end
17
+
18
+ def self.load_all!
19
+ constants.each &method(:const_get)
20
+ end
21
+ end
@@ -1,7 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'duck_puncher'
1
+ require_relative '../test_helper'
3
2
 
4
- class ArrayTest < MiniTest::Unit::TestCase
3
+ class ArrayTest < MiniTest::Test
5
4
  def test_m
6
5
  samples = ('a'..'m').to_a
7
6
  assert_equal samples.map(&:upcase), samples.m(:upcase)
@@ -11,4 +10,4 @@ class ArrayTest < MiniTest::Unit::TestCase
11
10
  assert_equal [].methods.get(/ty\?/), [:empty?]
12
11
  assert_equal [].methods.get('ty?'), [:empty?]
13
12
  end
14
- end
13
+ end
@@ -1,7 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'duck_puncher'
1
+ require_relative '../test_helper'
3
2
 
4
- class HashTest < MiniTest::Unit::TestCase
3
+ class HashTest < MiniTest::Test
5
4
  def test_seek
6
5
  my_hash = { a: 1, b: { c: 2 } }
7
6
  assert_equal my_hash.seek(:a), 1
@@ -9,4 +8,4 @@ class HashTest < MiniTest::Unit::TestCase
9
8
  assert_equal my_hash.seek(:b, :c), 2
10
9
  assert_equal my_hash.seek(:b), { c: 2 }
11
10
  end
12
- end
11
+ end
@@ -1,7 +1,7 @@
1
- require 'minitest/autorun'
2
- require 'duck_puncher'
1
+ require_relative '../test_helper'
2
+
3
+ class NumericTest < MiniTest::Test
3
4
 
4
- class NumericTest < MiniTest::Unit::TestCase
5
5
  def test_to_currency
6
6
  assert_equal '0.00', 0.to_currency
7
7
  assert_equal '25.00', 25.to_currency
@@ -44,4 +44,4 @@ class NumericTest < MiniTest::Unit::TestCase
44
44
  assert_equal '1 day ago', 100_000.to_time_ago
45
45
  assert_equal '2 days ago', 180_000.to_time_ago
46
46
  end
47
- end
47
+ end
@@ -0,0 +1,10 @@
1
+ require_relative '../test_helper'
2
+
3
+ class ObjectTest < MiniTest::Test
4
+ def test_clone!
5
+ obj = Object.new
6
+ cloned = obj.clone!
7
+ assert_equal cloned.class, obj.class
8
+ refute_equal cloned, obj
9
+ end
10
+ end
@@ -1,10 +1,9 @@
1
- require 'minitest/autorun'
2
- require 'duck_puncher'
1
+ require_relative '../test_helper'
3
2
 
4
- class HashTest < MiniTest::Unit::TestCase
3
+ class StringTest < MiniTest::Test
5
4
  def test_pluralize
6
5
  assert_equal 'hour'.pluralize(1), 'hour'
7
6
  assert_equal 'hour'.pluralize(0), 'hours'
8
7
  assert_equal 'hour'.pluralize(2), 'hours'
9
8
  end
10
- end
9
+ end
@@ -0,0 +1,4 @@
1
+ require 'minitest/autorun'
2
+ require 'duck_puncher'
3
+
4
+ DuckPuncher.load_all!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_puncher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,12 +56,15 @@ files:
56
56
  - lib/duck_puncher/array.rb
57
57
  - lib/duck_puncher/hash.rb
58
58
  - lib/duck_puncher/numeric.rb
59
+ - lib/duck_puncher/object.rb
59
60
  - lib/duck_puncher/string.rb
60
61
  - lib/duck_puncher/version.rb
61
62
  - test/duck_puncher/array_test.rb
62
63
  - test/duck_puncher/hash_test.rb
63
64
  - test/duck_puncher/numeric_test.rb
65
+ - test/duck_puncher/object_test.rb
64
66
  - test/duck_puncher/string_test.rb
67
+ - test/test_helper.rb
65
68
  homepage: ''
66
69
  licenses:
67
70
  - MIT
@@ -90,4 +93,6 @@ test_files:
90
93
  - test/duck_puncher/array_test.rb
91
94
  - test/duck_puncher/hash_test.rb
92
95
  - test/duck_puncher/numeric_test.rb
96
+ - test/duck_puncher/object_test.rb
93
97
  - test/duck_puncher/string_test.rb
98
+ - test/test_helper.rb