gorillib 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitignore +49 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.textile +49 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +36 -0
  6. data/README.textile +6 -1
  7. data/Rakefile +42 -9
  8. data/VERSION +1 -1
  9. data/gorillib.gemspec +110 -73
  10. data/lib/gorillib/array/deep_compact.rb +3 -12
  11. data/lib/gorillib/datetime/#flat.rb# +30 -0
  12. data/lib/gorillib/datetime/flat.rb +2 -10
  13. data/lib/gorillib/datetime/parse.rb +3 -1
  14. data/lib/gorillib/enumerable/sum.rb +37 -35
  15. data/lib/gorillib/hash/deep_compact.rb +3 -13
  16. data/lib/gorillib/logger/log.rb +1 -1
  17. data/lib/gorillib/numeric/clamp.rb +9 -0
  18. data/lib/gorillib/object/try.rb +10 -0
  19. data/lib/gorillib/object/try_dup.rb +44 -0
  20. data/lib/gorillib/string/human.rb +1 -3
  21. data/lib/gorillib/string/truncate.rb +2 -2
  22. data/spec/array/compact_blank_spec.rb +37 -0
  23. data/spec/array/extract_options_spec.rb +47 -0
  24. data/spec/datetime/flat_spec.rb +38 -0
  25. data/spec/datetime/parse_spec.rb +48 -0
  26. data/spec/enumerable/sum_spec.rb +56 -0
  27. data/spec/hash/compact_spec.rb +70 -0
  28. data/spec/hash/deep_compact_spec.rb +37 -0
  29. data/spec/hash/deep_merge_spec.rb +117 -0
  30. data/spec/hash/keys_spec.rb +111 -0
  31. data/spec/hash/reverse_merge_spec.rb +25 -0
  32. data/spec/hash/slice_spec.rb +43 -0
  33. data/spec/hash/zip_spec.rb +31 -0
  34. data/spec/logger/log_spec.rb +31 -0
  35. data/spec/metaprogramming/aliasing_spec.rb +177 -0
  36. data/spec/metaprogramming/cattr_accessor_spec.rb +41 -0
  37. data/spec/metaprogramming/class_attribute_spec.rb +75 -0
  38. data/spec/metaprogramming/delegation_spec.rb +166 -0
  39. data/spec/metaprogramming/mattr_accessor_spec.rb +44 -0
  40. data/spec/metaprogramming/singleton_class_spec.rb +9 -0
  41. data/spec/{numeric_spec.rb → numeric/clamp_spec.rb} +2 -2
  42. data/spec/object/blank_spec.rb +93 -0
  43. data/spec/object/try_dup_spec.rb +47 -0
  44. data/spec/object/try_spec.rb +20 -0
  45. data/spec/spec_helper.rb +13 -8
  46. data/spec/string/constantize_spec.rb +56 -0
  47. data/spec/string/human_spec.rb +66 -0
  48. data/spec/string/inflections_spec.rb +74 -0
  49. data/{test → spec}/string/inflector_test_cases.rb +0 -0
  50. data/spec/string/truncate_spec.rb +42 -0
  51. data/spec/support/kcode_test_helper.rb +16 -0
  52. metadata +209 -96
  53. data/.document +0 -5
  54. data/fiddle/hubahuba.rb +0 -62
  55. data/spec/blank_spec.rb +0 -86
  56. data/spec/deep_compact_spec.rb +0 -36
  57. data/spec/gorillib_spec.rb +0 -7
  58. data/spec/rcov.opts +0 -6
  59. data/spec/spec.opts +0 -4
  60. data/spec/spec_tasks.rake +0 -15
  61. data/test/abstract_unit.rb +0 -25
  62. data/test/array/compact_blank_test.rb +0 -33
  63. data/test/array/extract_options_test.rb +0 -39
  64. data/test/datetime/flat_test.rb +0 -0
  65. data/test/datetime/parse_test.rb +0 -0
  66. data/test/enumerable/sum_test.rb +0 -50
  67. data/test/hash/compact_test.rb +0 -38
  68. data/test/hash/deep_merge_test.rb +0 -30
  69. data/test/hash/keys_test.rb +0 -110
  70. data/test/hash/reverse_merge_test.rb +0 -20
  71. data/test/hash/slice_test.rb +0 -47
  72. data/test/hash/zip_test.rb +0 -0
  73. data/test/logger/log_test.rb +0 -0
  74. data/test/metaprogramming/aliasing_test.rb +0 -188
  75. data/test/metaprogramming/cattr_accessor_test.rb +0 -38
  76. data/test/metaprogramming/class_attribute_test.rb +0 -73
  77. data/test/metaprogramming/delegation_test.rb +0 -166
  78. data/test/metaprogramming/mattr_accessor_test.rb +0 -40
  79. data/test/metaprogramming/singleton_class_test.rb +0 -9
  80. data/test/object/blank_test.rb +0 -22
  81. data/test/string/constantize_test.rb +0 -30
  82. data/test/string/human_test.rb +0 -65
  83. data/test/string/inflections_test.rb +0 -57
  84. data/test/string/truncate_test.rb +0 -37
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ ## OS
2
+ .DS_Store
3
+ Icon?
4
+ nohup.out
5
+ .bak
6
+
7
+ ## EDITORS
8
+ \#*
9
+ .\#*
10
+ \#*\#
11
+ *~
12
+ *.swp
13
+ REVISION
14
+ TAGS*
15
+ tmtags
16
+ *_flymake.*
17
+ *_flymake
18
+ *.tmproj
19
+ .project
20
+ .settings
21
+
22
+ ## COMPILED
23
+ a.out
24
+ *.o
25
+ *.pyc
26
+ *.so
27
+
28
+ ## OTHER SCM
29
+ .bzr
30
+ .hg
31
+ .svn
32
+
33
+ ## PROJECT::GENERAL
34
+ coverage
35
+ rdoc
36
+ doc
37
+ pkg
38
+ .rake_test_cache
39
+ .bundle
40
+ .yardoc
41
+ *_private.*
42
+ *.pem
43
+
44
+ log/*
45
+ tmp/*
46
+ pkg/*
47
+
48
+ ## PROJECT::SPECIFIC
49
+ *.rdb
data/.rspec CHANGED
@@ -1 +1,3 @@
1
1
  --color
2
+ --format documentation
3
+ --drb
data/CHANGELOG.textile ADDED
@@ -0,0 +1,49 @@
1
+
2
+ h3. Version 0.0.7: full test coverage!
3
+
4
+ <pre>
5
+ lib/
6
+ |-- gorillib.rb
7
+ `-- gorillib
8
+ |-- array
9
+ | |-- compact_blank.rb
10
+ | |-- deep_compact.rb
11
+ | `-- extract_options.rb
12
+ |-- base.rb
13
+ |-- datetime
14
+ | |-- #flat.rb#
15
+ | |-- flat.rb
16
+ | `-- parse.rb
17
+ |-- enumerable
18
+ | `-- sum.rb
19
+ |-- hash
20
+ | |-- compact.rb
21
+ | |-- deep_compact.rb
22
+ | |-- deep_merge.rb
23
+ | |-- keys.rb
24
+ | |-- reverse_merge.rb
25
+ | |-- slice.rb
26
+ | `-- zip.rb
27
+ |-- logger
28
+ | `-- log.rb
29
+ |-- metaprogramming
30
+ | |-- aliasing.rb
31
+ | |-- cattr_accessor.rb
32
+ | |-- class_attribute.rb
33
+ | |-- delegation.rb
34
+ | |-- mattr_accessor.rb
35
+ | |-- remove_method.rb
36
+ | `-- singleton_class.rb
37
+ |-- numeric
38
+ | `-- clamp.rb
39
+ |-- object
40
+ | |-- blank.rb
41
+ | |-- try.rb
42
+ | `-- try_dup.rb
43
+ |-- some.rb
44
+ `-- string
45
+ |-- constantize.rb
46
+ |-- human.rb
47
+ |-- inflections.rb
48
+ `-- truncate.rb
49
+ </pre>
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Add dependencies to develop your gem here.
4
+ # Include everything needed to run rake, tests, features, etc.
5
+ group :development do
6
+ gem 'bundler', "~> 1.0.12"
7
+ gem 'yard', "~> 0.6.7"
8
+ gem 'jeweler', "~> 1.5.2"
9
+ gem 'rspec', "~> 2.5.0"
10
+ gem 'spork', "~> 0.9.0.rc5"
11
+ gem 'RedCloth' # for yard
12
+ # only interesting for coverage testing
13
+ gem 'rcov', ">= 0.9.9"
14
+ gem 'watchr'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ RedCloth (4.2.7)
5
+ diff-lcs (1.1.2)
6
+ git (1.2.5)
7
+ jeweler (1.5.2)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.8.7)
12
+ rcov (0.9.9)
13
+ rspec (2.5.0)
14
+ rspec-core (~> 2.5.0)
15
+ rspec-expectations (~> 2.5.0)
16
+ rspec-mocks (~> 2.5.0)
17
+ rspec-core (2.5.2)
18
+ rspec-expectations (2.5.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.5.0)
21
+ spork (0.9.0.rc7)
22
+ watchr (0.7)
23
+ yard (0.6.8)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ RedCloth
30
+ bundler (~> 1.0.12)
31
+ jeweler (~> 1.5.2)
32
+ rcov (>= 0.9.9)
33
+ rspec (~> 2.5.0)
34
+ spork (~> 0.9.0.rc5)
35
+ watchr
36
+ yard (~> 0.6.7)
data/README.textile CHANGED
@@ -3,7 +3,12 @@ h2. Gorillib: infochimps' lightweight subset of ruby convenience methods
3
3
  * No creep: include only what you need
4
4
  * No dependencies unless audaciously advertised.
5
5
  * Compatibile with active_record and extlib
6
- * NO COMMITS UNLESS JACOB SAYS OK
6
+
7
+
8
+ h3. TODO:
9
+
10
+ * Gorillib.demands(:cattr_accessor) -- raises if not included and recommends what to include
11
+
7
12
 
8
13
  h3. require 'gorillib'
9
14
 
data/Rakefile CHANGED
@@ -1,5 +1,12 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'rubygems' unless defined?(Gem)
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
3
10
 
4
11
  require 'jeweler'
5
12
  Jeweler::Tasks.new do |gem|
@@ -12,15 +19,41 @@ Jeweler::Tasks.new do |gem|
12
19
  gem.email = "coders@infochimps.org"
13
20
  gem.authors = ["Infochimps"]
14
21
 
15
- # Include your dependencies below. Runtime dependencies are required when using your gem,
16
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
17
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
18
- # gem.add_development_dependency 'rspec', '> 1.2.3'
19
- gem.add_development_dependency "yard", "~> 0.6.0"
20
- gem.add_development_dependency "jeweler", "~> 1.5.2"
21
- gem.add_development_dependency "rcov", ">= 0"
22
+ gem.add_development_dependency 'bundler', "~> 1.0.12"
23
+ gem.add_development_dependency 'yard', "~> 0.6.7"
24
+ gem.add_development_dependency 'jeweler', "~> 1.5.2"
25
+ gem.add_development_dependency 'rspec', "~> 2.5.0"
26
+ gem.add_development_dependency 'rcov', ">= 0.9.9"
27
+ gem.add_development_dependency 'spork', "~> 0.9.0.rc5"
28
+ gem.add_development_dependency 'watchr'
29
+
30
+ ignores = File.readlines(".gitignore").grep(/^[^#]\S+/).map{|s| s.chomp }
31
+ dotfiles = [".gemtest", ".gitignore", ".rspec", ".yardopts"]
32
+ gem.files = dotfiles + Dir["**/*"].
33
+ reject{|f| f =~ %r{^(vendor|coverage)/} }.
34
+ reject{|f| File.directory?(f) }.
35
+ reject{|f| ignores.any?{|i| File.fnmatch(i, f) || File.fnmatch(i+'/**/*', f) } }
36
+ gem.test_files = gem.files.grep(/^spec\//)
37
+ gem.require_paths = ['lib']
22
38
  end
23
39
  Jeweler::RubygemsDotOrgTasks.new
24
40
 
41
+ require 'rspec/core'
42
+ require 'rspec/core/rake_task'
43
+ RSpec::Core::RakeTask.new(:spec) do |spec|
44
+ spec.pattern = FileList['spec/**/*_spec.rb']
45
+ end
46
+
47
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
48
+ spec.pattern = 'spec/**/*_spec.rb'
49
+ spec.rcov = true
50
+ spec.rcov_opts = %w[ --exclude .rvm --no-comments --text-summary]
51
+ end
52
+
53
+ task :default => :spec
54
+
25
55
  require 'yard'
26
56
  YARD::Rake::YardocTask.new
57
+
58
+ # App-specific tasks
59
+ Dir[File.dirname(__FILE__)+'/lib/tasks/**/*.rake'].sort.each{|f| load f }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
data/gorillib.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gorillib}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
12
- s.date = %q{2011-05-05}
12
+ s.date = %q{2011-05-20}
13
13
  s.description = %q{Gorillib: infochimps lightweight subset of ruby convenience methods}
14
14
  s.email = %q{coders@infochimps.org}
15
15
  s.extra_rdoc_files = [
@@ -17,19 +17,22 @@ Gem::Specification.new do |s|
17
17
  "README.textile"
18
18
  ]
19
19
  s.files = [
20
- ".document",
20
+ ".gitignore",
21
21
  ".rspec",
22
+ "CHANGELOG.textile",
23
+ "Gemfile",
24
+ "Gemfile.lock",
22
25
  "LICENSE.textile",
23
26
  "README.textile",
24
27
  "Rakefile",
25
28
  "VERSION",
26
- "fiddle/hubahuba.rb",
27
29
  "gorillib.gemspec",
28
30
  "lib/gorillib.rb",
29
31
  "lib/gorillib/array/compact_blank.rb",
30
32
  "lib/gorillib/array/deep_compact.rb",
31
33
  "lib/gorillib/array/extract_options.rb",
32
34
  "lib/gorillib/base.rb",
35
+ "lib/gorillib/datetime/#flat.rb#",
33
36
  "lib/gorillib/datetime/flat.rb",
34
37
  "lib/gorillib/datetime/parse.rb",
35
38
  "lib/gorillib/enumerable/sum.rb",
@@ -50,100 +53,134 @@ Gem::Specification.new do |s|
50
53
  "lib/gorillib/metaprogramming/singleton_class.rb",
51
54
  "lib/gorillib/numeric/clamp.rb",
52
55
  "lib/gorillib/object/blank.rb",
56
+ "lib/gorillib/object/try.rb",
57
+ "lib/gorillib/object/try_dup.rb",
53
58
  "lib/gorillib/some.rb",
54
59
  "lib/gorillib/string/constantize.rb",
55
60
  "lib/gorillib/string/human.rb",
56
61
  "lib/gorillib/string/inflections.rb",
57
62
  "lib/gorillib/string/truncate.rb",
58
- "spec/blank_spec.rb",
59
- "spec/deep_compact_spec.rb",
60
- "spec/gorillib_spec.rb",
61
- "spec/numeric_spec.rb",
62
- "spec/rcov.opts",
63
- "spec/spec.opts",
63
+ "spec/array/compact_blank_spec.rb",
64
+ "spec/array/extract_options_spec.rb",
65
+ "spec/datetime/flat_spec.rb",
66
+ "spec/datetime/parse_spec.rb",
67
+ "spec/enumerable/sum_spec.rb",
68
+ "spec/hash/compact_spec.rb",
69
+ "spec/hash/deep_compact_spec.rb",
70
+ "spec/hash/deep_merge_spec.rb",
71
+ "spec/hash/keys_spec.rb",
72
+ "spec/hash/reverse_merge_spec.rb",
73
+ "spec/hash/slice_spec.rb",
74
+ "spec/hash/zip_spec.rb",
75
+ "spec/logger/log_spec.rb",
76
+ "spec/metaprogramming/aliasing_spec.rb",
77
+ "spec/metaprogramming/cattr_accessor_spec.rb",
78
+ "spec/metaprogramming/class_attribute_spec.rb",
79
+ "spec/metaprogramming/delegation_spec.rb",
80
+ "spec/metaprogramming/mattr_accessor_spec.rb",
81
+ "spec/metaprogramming/singleton_class_spec.rb",
82
+ "spec/numeric/clamp_spec.rb",
83
+ "spec/object/blank_spec.rb",
84
+ "spec/object/try_dup_spec.rb",
85
+ "spec/object/try_spec.rb",
64
86
  "spec/spec_helper.rb",
65
- "spec/spec_tasks.rake",
66
- "test/abstract_unit.rb",
67
- "test/array/compact_blank_test.rb",
68
- "test/array/extract_options_test.rb",
69
- "test/datetime/flat_test.rb",
70
- "test/datetime/parse_test.rb",
71
- "test/enumerable/sum_test.rb",
72
- "test/hash/compact_test.rb",
73
- "test/hash/deep_merge_test.rb",
74
- "test/hash/keys_test.rb",
75
- "test/hash/reverse_merge_test.rb",
76
- "test/hash/slice_test.rb",
77
- "test/hash/zip_test.rb",
78
- "test/logger/log_test.rb",
79
- "test/metaprogramming/aliasing_test.rb",
80
- "test/metaprogramming/cattr_accessor_test.rb",
81
- "test/metaprogramming/class_attribute_test.rb",
82
- "test/metaprogramming/delegation_test.rb",
83
- "test/metaprogramming/mattr_accessor_test.rb",
84
- "test/metaprogramming/singleton_class_test.rb",
85
- "test/object/blank_test.rb",
86
- "test/string/constantize_test.rb",
87
- "test/string/human_test.rb",
88
- "test/string/inflections_test.rb",
89
- "test/string/inflector_test_cases.rb",
90
- "test/string/truncate_test.rb"
87
+ "spec/string/constantize_spec.rb",
88
+ "spec/string/human_spec.rb",
89
+ "spec/string/inflections_spec.rb",
90
+ "spec/string/inflector_test_cases.rb",
91
+ "spec/string/truncate_spec.rb",
92
+ "spec/support/kcode_test_helper.rb"
91
93
  ]
92
94
  s.homepage = %q{http://infochimps.com/labs}
93
95
  s.licenses = ["MIT"]
94
96
  s.require_paths = ["lib"]
95
- s.rubygems_version = %q{1.3.7}
97
+ s.rubygems_version = %q{1.5.0}
96
98
  s.summary = %q{include only what you need. No dependencies, no creep}
97
99
  s.test_files = [
98
- "spec/blank_spec.rb",
99
- "spec/deep_compact_spec.rb",
100
- "spec/gorillib_spec.rb",
101
- "spec/numeric_spec.rb",
100
+ "spec/array/compact_blank_spec.rb",
101
+ "spec/array/extract_options_spec.rb",
102
+ "spec/datetime/flat_spec.rb",
103
+ "spec/datetime/parse_spec.rb",
104
+ "spec/enumerable/sum_spec.rb",
105
+ "spec/hash/compact_spec.rb",
106
+ "spec/hash/deep_compact_spec.rb",
107
+ "spec/hash/deep_merge_spec.rb",
108
+ "spec/hash/keys_spec.rb",
109
+ "spec/hash/reverse_merge_spec.rb",
110
+ "spec/hash/slice_spec.rb",
111
+ "spec/hash/zip_spec.rb",
112
+ "spec/logger/log_spec.rb",
113
+ "spec/metaprogramming/aliasing_spec.rb",
114
+ "spec/metaprogramming/cattr_accessor_spec.rb",
115
+ "spec/metaprogramming/class_attribute_spec.rb",
116
+ "spec/metaprogramming/delegation_spec.rb",
117
+ "spec/metaprogramming/mattr_accessor_spec.rb",
118
+ "spec/metaprogramming/singleton_class_spec.rb",
119
+ "spec/numeric/clamp_spec.rb",
120
+ "spec/object/blank_spec.rb",
121
+ "spec/object/try_dup_spec.rb",
122
+ "spec/object/try_spec.rb",
102
123
  "spec/spec_helper.rb",
103
- "test/abstract_unit.rb",
104
- "test/array/compact_blank_test.rb",
105
- "test/array/extract_options_test.rb",
106
- "test/datetime/flat_test.rb",
107
- "test/datetime/parse_test.rb",
108
- "test/enumerable/sum_test.rb",
109
- "test/hash/compact_test.rb",
110
- "test/hash/deep_merge_test.rb",
111
- "test/hash/keys_test.rb",
112
- "test/hash/reverse_merge_test.rb",
113
- "test/hash/slice_test.rb",
114
- "test/hash/zip_test.rb",
115
- "test/logger/log_test.rb",
116
- "test/metaprogramming/aliasing_test.rb",
117
- "test/metaprogramming/cattr_accessor_test.rb",
118
- "test/metaprogramming/class_attribute_test.rb",
119
- "test/metaprogramming/delegation_test.rb",
120
- "test/metaprogramming/mattr_accessor_test.rb",
121
- "test/metaprogramming/singleton_class_test.rb",
122
- "test/object/blank_test.rb",
123
- "test/string/constantize_test.rb",
124
- "test/string/human_test.rb",
125
- "test/string/inflections_test.rb",
126
- "test/string/inflector_test_cases.rb",
127
- "test/string/truncate_test.rb"
124
+ "spec/string/constantize_spec.rb",
125
+ "spec/string/human_spec.rb",
126
+ "spec/string/inflections_spec.rb",
127
+ "spec/string/inflector_test_cases.rb",
128
+ "spec/string/truncate_spec.rb",
129
+ "spec/support/kcode_test_helper.rb"
128
130
  ]
129
131
 
130
132
  if s.respond_to? :specification_version then
131
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
132
133
  s.specification_version = 3
133
134
 
134
135
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
135
- s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
136
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.12"])
137
+ s.add_development_dependency(%q<yard>, ["~> 0.6.7"])
136
138
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
137
- s.add_development_dependency(%q<rcov>, [">= 0"])
139
+ s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
140
+ s.add_development_dependency(%q<spork>, ["~> 0.9.0.rc5"])
141
+ s.add_development_dependency(%q<RedCloth>, [">= 0"])
142
+ s.add_development_dependency(%q<rcov>, [">= 0.9.9"])
143
+ s.add_development_dependency(%q<watchr>, [">= 0"])
144
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.12"])
145
+ s.add_development_dependency(%q<yard>, ["~> 0.6.7"])
146
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
147
+ s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
148
+ s.add_development_dependency(%q<rcov>, [">= 0.9.9"])
149
+ s.add_development_dependency(%q<spork>, ["~> 0.9.0.rc5"])
150
+ s.add_development_dependency(%q<watchr>, [">= 0"])
138
151
  else
139
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
152
+ s.add_dependency(%q<bundler>, ["~> 1.0.12"])
153
+ s.add_dependency(%q<yard>, ["~> 0.6.7"])
154
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
155
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
156
+ s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
157
+ s.add_dependency(%q<RedCloth>, [">= 0"])
158
+ s.add_dependency(%q<rcov>, [">= 0.9.9"])
159
+ s.add_dependency(%q<watchr>, [">= 0"])
160
+ s.add_dependency(%q<bundler>, ["~> 1.0.12"])
161
+ s.add_dependency(%q<yard>, ["~> 0.6.7"])
140
162
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
141
- s.add_dependency(%q<rcov>, [">= 0"])
163
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
164
+ s.add_dependency(%q<rcov>, [">= 0.9.9"])
165
+ s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
166
+ s.add_dependency(%q<watchr>, [">= 0"])
142
167
  end
143
168
  else
144
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
169
+ s.add_dependency(%q<bundler>, ["~> 1.0.12"])
170
+ s.add_dependency(%q<yard>, ["~> 0.6.7"])
171
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
172
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
173
+ s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
174
+ s.add_dependency(%q<RedCloth>, [">= 0"])
175
+ s.add_dependency(%q<rcov>, [">= 0.9.9"])
176
+ s.add_dependency(%q<watchr>, [">= 0"])
177
+ s.add_dependency(%q<bundler>, ["~> 1.0.12"])
178
+ s.add_dependency(%q<yard>, ["~> 0.6.7"])
145
179
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
146
- s.add_dependency(%q<rcov>, [">= 0"])
180
+ s.add_dependency(%q<rspec>, ["~> 2.5.0"])
181
+ s.add_dependency(%q<rcov>, [">= 0.9.9"])
182
+ s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
183
+ s.add_dependency(%q<watchr>, [">= 0"])
147
184
  end
148
185
  end
149
186
 
@@ -6,17 +6,8 @@ require 'gorillib/object/blank'
6
6
  class Array
7
7
  def deep_compact!
8
8
  self.map! do |val|
9
- case val
10
- when Hash
11
- val = val.deep_compact!
12
- when Array
13
- val = val.deep_compact!
14
- when String
15
- val = nil if val.blank?
16
- end
17
- val
18
- end
19
- self.compact!
20
- self.blank? ? nil : self
9
+ val.deep_compact! if val.respond_to?(:deep_compact!)
10
+ val unless val.blank?
11
+ end.compact!
21
12
  end
22
13
  end
@@ -0,0 +1,30 @@
1
+ require 'time'
2
+ class Time
3
+ # strftime() format to flatten a date
4
+ FLAT_FORMAT = "%Y%m%d%H%M%S" unless defined?(FLAT_FORMAT)
5
+
6
+ # Flatten
7
+ def to_flat
8
+ utc.strftime(FLAT_FORMAT)
9
+ end unless method_defined?(:to_flat)
10
+ end
11
+
12
+ class DateTime < Date
13
+ # strftime() format to flatten a date
14
+ FLAT_FORMAT = "%Y%m%d%H%M%S" unless defined?(FLAT_FORMAT)
15
+
16
+ # Flatten
17
+ def to_flat
18
+ strftime(FLAT_FORMAT)
19
+ end unless method_defined?(:to_flat)
20
+ end
21
+
22
+ class Date
23
+ # strftime() format to flatten a date
24
+ FLAT_FORMAT = "%Y%m%d" unless defined?(FLAT_FORMAT)
25
+
26
+ # Flatten
27
+ def to_flat
28
+ strftime(FLAT_FORMAT)
29
+ end unless method_defined?(:to_flat)
30
+ end
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+ require 'date'
1
3
  class Time
2
4
  # strftime() format to flatten a date
3
5
  FLAT_FORMAT = "%Y%m%d%H%M%S" unless defined?(FLAT_FORMAT)
@@ -8,16 +10,6 @@ class Time
8
10
  end unless method_defined?(:to_flat)
9
11
  end
10
12
 
11
- class DateTime < Date
12
- # strftime() format to flatten a date
13
- FLAT_FORMAT = "%Y%m%d%H%M%S" unless defined?(FLAT_FORMAT)
14
-
15
- # Flatten
16
- def to_flat
17
- strftime(FLAT_FORMAT)
18
- end unless method_defined?(:to_flat)
19
- end
20
-
21
13
  class Date
22
14
  # strftime() format to flatten a date
23
15
  FLAT_FORMAT = "%Y%m%d" unless defined?(FLAT_FORMAT)
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+ require 'date'
1
3
  class Time
2
4
  #
3
5
  # Parses the time but never fails.
@@ -7,7 +9,7 @@ class Time
7
9
  # time zone by parsing it as YYYYmmddHHMMMSSZ <- 'Z' at end
8
10
  #
9
11
  def self.parse_safely dt
10
- return nil if dt.blank?
12
+ return nil if dt.nil? || (dt.respond_to?(:empty) && dt.empty?)
11
13
  begin
12
14
  case
13
15
  when dt.is_a?(Time) then dt.utc
@@ -1,38 +1,40 @@
1
- module Enumerable
2
- # Calculates a sum from the elements. Examples:
3
- #
4
- # payments.sum { |p| p.price * p.tax_rate }
5
- # payments.sum(&:price)
6
- #
7
- # The latter is a shortcut for:
8
- #
9
- # payments.inject(0) { |sum, p| sum + p.price }
10
- #
11
- # It can also calculate the sum without the use of a block.
12
- #
13
- # [5, 15, 10].sum # => 30
14
- # ["foo", "bar"].sum # => "foobar"
15
- # [[1, 2], [3, 1, 5]].sum => [1, 2, 3, 1, 5]
16
- #
17
- # The default sum of an empty list is zero. You can override this default:
18
- #
19
- # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
20
- #
21
- def sum(identity = 0, &block)
22
- if block_given?
23
- map(&block).sum(identity)
24
- else
25
- inject { |sum, element| sum + element } || identity
1
+ unless Enumerable.method_defined?(:sum)
2
+ module Enumerable
3
+ # Calculates a sum from the elements. Examples:
4
+ #
5
+ # payments.sum { |p| p.price * p.tax_rate }
6
+ # payments.sum(&:price)
7
+ #
8
+ # The latter is a shortcut for:
9
+ #
10
+ # payments.inject(0) { |sum, p| sum + p.price }
11
+ #
12
+ # It can also calculate the sum without the use of a block.
13
+ #
14
+ # [5, 15, 10].sum # => 30
15
+ # ["foo", "bar"].sum # => "foobar"
16
+ # [[1, 2], [3, 1, 5]].sum => [1, 2, 3, 1, 5]
17
+ #
18
+ # The default sum of an empty list is zero. You can override this default:
19
+ #
20
+ # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
21
+ #
22
+ def sum(identity = 0, &block)
23
+ if block_given?
24
+ map(&block).sum(identity)
25
+ else
26
+ inject { |sum, element| sum + element } || identity
27
+ end
26
28
  end
27
- end unless method_defined?(:sum)
28
- end
29
+ end
29
30
 
30
- class Range #:nodoc:
31
- # Optimize range sum to use arithmetic progression if a block is not given and
32
- # we have a range of numeric values.
33
- def sum(identity = 0)
34
- return super if block_given? || !(first.instance_of?(Integer) && last.instance_of?(Integer))
35
- actual_last = exclude_end? ? (last - 1) : last
36
- (actual_last - first + 1) * (actual_last + first) / 2
37
- end unless method_defined?(:sum)
31
+ class Range #:nodoc:
32
+ # Optimize range sum to use arithmetic progression if a block is not given and
33
+ # we have a range of numeric values.
34
+ def sum(identity = 0)
35
+ return super if block_given? || !(first.instance_of?(Integer) && last.instance_of?(Integer))
36
+ actual_last = exclude_end? ? (last - 1) : last
37
+ (actual_last - first + 1) * (actual_last + first) / 2
38
+ end
39
+ end
38
40
  end