guerrilla_patch 2.8.1 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ *.un~
12
+
13
+ # bundler
14
+ .bundle
15
+
16
+ # jeweler generated
17
+ pkg
18
+
19
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
+ #
21
+ # * Create a file at ~/.gitignore
22
+ # * Include files you want ignored
23
+ # * Run: git config --global core.excludesfile ~/.gitignore
24
+ #
25
+ # After doing this, these files will be ignored in all your git projects,
26
+ # saving you from having to 'pollute' every project you touch with them
27
+ #
28
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
29
+ #
30
+ # For MacOS:
31
+ #
32
+ #.DS_Store
33
+
34
+ # For TextMate
35
+ #*.tmproj
36
+ #tmtags
37
+
38
+ # For emacs:
39
+ #*~
40
+ #\#*
41
+ #.\#*
42
+
43
+ # For vim:
44
+ #*.swp
45
+
46
+ # For redcar:
47
+ #.redcar
48
+
49
+ # For rubinius:
50
+ #*.rbc
51
+ guerrilla_patch.sublime-workspace
data/Gemfile CHANGED
@@ -1,13 +1,8 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
3
+ gemspec
4
+
5
+ group :development, :test do
9
6
  gem "rspec", "~> 2.8.0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.6.4"
12
- gem "rcov", ">= 0"
7
+ gem "bundler", ">= 1.0.0"
13
8
  end
data/Gemfile.lock CHANGED
@@ -1,14 +1,12 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guerrilla_patch (2.8.2)
5
+
1
6
  GEM
2
7
  remote: http://rubygems.org/
3
8
  specs:
4
9
  diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.6.4)
7
- bundler (~> 1.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.9.2.2)
11
- rcov (0.9.11)
12
10
  rspec (2.8.0)
13
11
  rspec-core (~> 2.8.0)
14
12
  rspec-expectations (~> 2.8.0)
@@ -22,7 +20,6 @@ PLATFORMS
22
20
  ruby
23
21
 
24
22
  DEPENDENCIES
25
- bundler (~> 1.0.0)
26
- jeweler (~> 1.6.4)
27
- rcov
23
+ bundler (>= 1.0.0)
24
+ guerrilla_patch!
28
25
  rspec (~> 2.8.0)
data/README.md CHANGED
@@ -37,7 +37,7 @@ You can divide a number by types. It uses allocate to prevent ±0.01 off errors.
37
37
  50.divide({ '1A' => 50, '1B' => 30, '1C' => 20 }) #=> { '1A' => 25, '1B' => 15, '1C' => 10 }
38
38
  ```
39
39
 
40
- This might look trivial but it gets messy soon enough because number are not, well even.
40
+ This might look trivial but it gets messy soon enough because numbers are not, well even.
41
41
 
42
42
  ```
43
43
  33.11.divide({ '1A' => 50, '1B' => 50}) #=> {"1A"=> 16.56, "1B"=> 16.55 }
data/Rakefile CHANGED
@@ -2,49 +2,34 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
+
6
+ $:.push File.expand_path("../lib", __FILE__)
7
+ require "guerrilla_patch/version"
8
+
5
9
  begin
6
- Bundler.setup(:default, :development)
10
+ Bundler::GemHelper.install_tasks
7
11
  rescue Bundler::BundlerError => e
8
12
  $stderr.puts e.message
9
13
  $stderr.puts "Run `bundle install` to install missing gems"
10
14
  exit e.status_code
11
15
  end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "guerrilla_patch"
18
- gem.homepage = "http://github.com/drkreso/guerrilla_patch"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Collection of monkey patches}
21
- gem.description = %Q{Since I am tired of hunting down monkey patches at large I am caging them inside this gem}
22
- gem.email = "kresimir.bojcic@gmail.com"
23
- gem.authors = ["drKreso"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
16
 
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
17
+ require 'rspec/core'
18
+ require 'rspec/core/rake_task'
19
+ RSpec::Core::RakeTask.new(:spec) do |spec|
20
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
21
  end
34
22
 
35
- require 'rcov/rcovtask'
36
- Rcov::RcovTask.new do |test|
37
- test.libs << 'test'
38
- test.pattern = 'test/**/test_*.rb'
39
- test.verbose = true
40
- test.rcov_opts << '--exclude "gems/*"'
23
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
24
+ spec.pattern = 'spec/**/*_spec.rb'
25
+ spec.rcov = true
41
26
  end
42
27
 
43
- task :default => :test
28
+ task :default => :spec
44
29
 
45
- require 'rdoc/task'
30
+ require 'rake/rdoctask'
46
31
  Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
32
+ version = GuerrillaPatch::VERSION
48
33
 
49
34
  rdoc.rdoc_dir = 'rdoc'
50
35
  rdoc.title = "guerrilla_patch #{version}"
@@ -1,69 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{guerrilla_patch}
8
- s.version = "2.8.1"
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "guerrilla_patch/version"
9
5
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["drKreso"]
12
- s.date = %q{2012-10-10}
13
- s.description = %q{Since I am tired of hunting down monkey patches at large I am caging them inside this gem}
14
- s.email = %q{kresimir.bojcic@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "guerrilla_patch.gemspec",
29
- "lib/guerrilla_patch.rb",
30
- "lib/guerrilla_patch/aggregate_by_type/aggregator.rb",
31
- "lib/guerrilla_patch/aggregate_by_type/amount.rb",
32
- "lib/guerrilla_patch/aggregate_by_type/divide_by_type.rb",
33
- "lib/guerrilla_patch/allocate.rb",
34
- "lib/guerrilla_patch/kernel.rb",
35
- "lib/guerrilla_patch/string.rb",
36
- "spec/guerrilla_patch/aggregate_by_type/aggregator_spec.rb",
37
- "spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb",
38
- "spec/guerrilla_patch/allocate_spec.rb",
39
- "spec/guerrilla_patch/kernel_spec.rb",
40
- "spec/guerrilla_patch/string_spec.rb"
41
- ]
42
- s.homepage = %q{http://github.com/drkreso/guerrilla_patch}
43
- s.licenses = ["MIT"]
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.6.2}
46
- s.summary = %q{Collection of monkey patches}
6
+ Gem::Specification.new do |gem|
7
+ gem.authors = ["drKreso"]
8
+ gem.email = ["kresimir.bojcic@gmail.com"]
9
+ gem.description = "Collection of monkey patches I like to use in my projects"
10
+ gem.summary = "Since I am tired of hunting down monkey patches at large I am caging them inside this gem"
11
+ gem.homepage = "http://github.com/drKreso/guerrilla_patch"
12
+ gem.date = "2012-11-04"
47
13
 
48
- if s.respond_to? :specification_version then
49
- s.specification_version = 3
50
14
 
51
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
53
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
55
- s.add_development_dependency(%q<rcov>, [">= 0"])
56
- else
57
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
58
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
61
- end
62
- else
63
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
- s.add_dependency(%q<rcov>, [">= 0"])
67
- end
15
+ gem.licenses = ["MIT"]
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.name = "guerrilla_patch"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = GuerrillaPatch::VERSION
22
+
68
23
  end
69
24
 
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "path": "/Users/kbojcic/dev/easy_insure/guerrilla_patch"
6
+ }
7
+ ]
8
+ }
@@ -8,14 +8,29 @@ class Aggregator
8
8
  return Amount.new(agregator.total,agregator.total_by_type)
9
9
  end
10
10
 
11
+ def self.aggregate_full_precistion(&block)
12
+ agregator = Aggregator.new
13
+ block.call(agregator)
14
+ return Amount.new(agregator.total,agregator.total_by_type)
15
+ end
16
+
11
17
  def add(amount)
12
18
  total_list << Aggregator.prepare(amount)
13
19
  end
14
20
 
21
+ def add_full_precision(amount)
22
+ raise "Full precision can be done only on amount class. Class sended was: #{amount.class} with value: #{amount.inspect}" if amount.class != Amount
23
+ total_list << amount.by_type
24
+ end
25
+
15
26
  def subtract(amount)
16
27
  add(amount.negative)
17
28
  end
18
29
 
30
+ def subtract_full_precision(amount)
31
+ add_full_precision(amount.negative)
32
+ end
33
+
19
34
  def total
20
35
  (by_type? ? total_by_type : total_list).sum_me
21
36
  end
@@ -17,7 +17,10 @@ class Amount
17
17
  end
18
18
 
19
19
  def negative
20
- Amount.new(-value, by_type)
20
+ result = {}
21
+ by_type.each_pair { |key, value| result[key] = -value }
22
+
23
+ Amount.new(-value, result)
21
24
  end
22
25
 
23
26
  def divide
@@ -0,0 +1,3 @@
1
+ module GuerrillaPatch
2
+ VERSION = "2.8.2"
3
+ end
@@ -31,6 +31,18 @@ describe Aggregator do
31
31
  amount.by_type.should == { :no_division => 3 }
32
32
  end
33
33
 
34
+ it 'knows how to add amount with full precision' do
35
+ amount = Aggregator.aggregate do |result|
36
+ result.subtract_full_precision Amount.new("0.001".to_d, {'1B' => "0.001".to_d})
37
+ result.add_full_precision Amount.new("1.123".to_d, { "1A" => "1.123".to_d})
38
+ result.add_full_precision Amount.new("2.222".to_d, { "1B" => "2.222".to_d})
39
+ result.subtract_full_precision Amount.new("0.001".to_d, {'1C' => "0.001".to_d})
40
+ end
41
+
42
+ amount.value.should == 3.343
43
+ amount.by_type.should == { '1A' => "1.123".to_d, '1B' => "2.221".to_d, '1C' => "-0.001".to_d }
44
+ end
45
+
34
46
  it 'knows how to add amount of integer type' do
35
47
  amount = Aggregator.aggregate do |result|
36
48
  result.add Amount.new(1, {'1A' => 1})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guerrilla_patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,63 +9,17 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 +02:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rspec
17
- requirement: &70132140486620 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 2.8.0
23
- type: :development
24
- prerelease: false
25
- version_requirements: *70132140486620
26
- - !ruby/object:Gem::Dependency
27
- name: bundler
28
- requirement: &70132140485000 !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: *70132140485000
37
- - !ruby/object:Gem::Dependency
38
- name: jeweler
39
- requirement: &70132140483560 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- version: 1.6.4
45
- type: :development
46
- prerelease: false
47
- version_requirements: *70132140483560
48
- - !ruby/object:Gem::Dependency
49
- name: rcov
50
- requirement: &70132140482660 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ! '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- type: :development
57
- prerelease: false
58
- version_requirements: *70132140482660
59
- description: Since I am tired of hunting down monkey patches at large I am caging
60
- them inside this gem
61
- email: kresimir.bojcic@gmail.com
12
+ date: 2012-11-04 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Collection of monkey patches I like to use in my projects
15
+ email:
16
+ - kresimir.bojcic@gmail.com
62
17
  executables: []
63
18
  extensions: []
64
- extra_rdoc_files:
65
- - LICENSE.txt
66
- - README.md
19
+ extra_rdoc_files: []
67
20
  files:
68
21
  - .document
22
+ - .gitignore
69
23
  - .rspec
70
24
  - Gemfile
71
25
  - Gemfile.lock
@@ -74,6 +28,7 @@ files:
74
28
  - Rakefile
75
29
  - VERSION
76
30
  - guerrilla_patch.gemspec
31
+ - guerrilla_patch.sublime-project
77
32
  - lib/guerrilla_patch.rb
78
33
  - lib/guerrilla_patch/aggregate_by_type/aggregator.rb
79
34
  - lib/guerrilla_patch/aggregate_by_type/amount.rb
@@ -81,13 +36,13 @@ files:
81
36
  - lib/guerrilla_patch/allocate.rb
82
37
  - lib/guerrilla_patch/kernel.rb
83
38
  - lib/guerrilla_patch/string.rb
39
+ - lib/guerrilla_patch/version.rb
84
40
  - spec/guerrilla_patch/aggregate_by_type/aggregator_spec.rb
85
41
  - spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
86
42
  - spec/guerrilla_patch/allocate_spec.rb
87
43
  - spec/guerrilla_patch/kernel_spec.rb
88
44
  - spec/guerrilla_patch/string_spec.rb
89
- has_rdoc: true
90
- homepage: http://github.com/drkreso/guerrilla_patch
45
+ homepage: http://github.com/drKreso/guerrilla_patch
91
46
  licenses:
92
47
  - MIT
93
48
  post_install_message:
@@ -100,9 +55,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
55
  - - ! '>='
101
56
  - !ruby/object:Gem::Version
102
57
  version: '0'
103
- segments:
104
- - 0
105
- hash: 2606106807289666378
106
58
  required_rubygems_version: !ruby/object:Gem::Requirement
107
59
  none: false
108
60
  requirements:
@@ -111,8 +63,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
63
  version: '0'
112
64
  requirements: []
113
65
  rubyforge_project:
114
- rubygems_version: 1.6.2
66
+ rubygems_version: 1.8.24
115
67
  signing_key:
116
68
  specification_version: 3
117
- summary: Collection of monkey patches
118
- test_files: []
69
+ summary: Since I am tired of hunting down monkey patches at large I am caging them
70
+ inside this gem
71
+ test_files:
72
+ - spec/guerrilla_patch/aggregate_by_type/aggregator_spec.rb
73
+ - spec/guerrilla_patch/aggregate_by_type/divide_by_type_spec.rb
74
+ - spec/guerrilla_patch/allocate_spec.rb
75
+ - spec/guerrilla_patch/kernel_spec.rb
76
+ - spec/guerrilla_patch/string_spec.rb