corrency 0.3.0 → 0.3.1

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.
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "rake"
23
23
  s.add_development_dependency "cucumber"
24
- s.add_development_dependency "shoulda-context"
25
24
  end
@@ -0,0 +1,17 @@
1
+ Feature: Calculate Profit Margin From Price
2
+ In order to make the correct amount of profit on an item
3
+ As a user of the Corrency Library
4
+ I should be able to work out how much margin has been applied.
5
+
6
+ Scenario Outline: Profit Margin from Price
7
+ Given there is a price of <price>
8
+ And I know the cost is <cost>
9
+ Then I should get the margin <margin>
10
+
11
+ Examples:
12
+ | cost | margin | price |
13
+ | 61.33 | 28% | 85.18 |
14
+ | 90.00 | 10% | 100.00 |
15
+ | 100.00 | 20% | 125.00 |
16
+ | 3.43 | 12.28% | 3.91 |
17
+
@@ -0,0 +1,11 @@
1
+ Given /^there is a price of (.+)$/ do |price|
2
+ @meh = BigDecimal.new(price)
3
+ end
4
+
5
+ And /^I know the cost is (.+)$/ do |cost|
6
+ @margin = @meh.margin(cost)
7
+ end
8
+
9
+ Then /^I should get the margin (.+)$/ do |margin|
10
+ assert_equal(BigDecimal.new(margin).to_s, @margin.to_s)
11
+ end
@@ -18,6 +18,10 @@ class BigDecimal
18
18
  def add_margin(margin)
19
19
  ((self / (100 - margin)) * 100).to_d.round(2)
20
20
  end
21
+
22
+ def margin(cost)
23
+ ((self - BigDecimal.new(cost)) / self) * 100
24
+ end
21
25
 
22
26
  old_to_s = instance_method :to_s
23
27
 
@@ -1,3 +1,3 @@
1
1
  module Corrency
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corrency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2012-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: shoulda-context
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  description: Adds Ecommerce Extensions to Various Core Libraries it really does
63
47
  email:
64
48
  - rob@r-williams.com
@@ -73,10 +57,12 @@ files:
73
57
  - README.md
74
58
  - Rakefile
75
59
  - corrency.gemspec
60
+ - features/adding_profit_margin.feature
76
61
  - features/nice_rounding.feature
77
- - features/profit_margin_calculations.feature
62
+ - features/profit_margin_from_price.feature
63
+ - features/step_definitions/adding_profit_margin_steps.rb
64
+ - features/step_definitions/calculate_profit_margin_from_price_steps.rb
78
65
  - features/step_definitions/nice_rounding_steps.rb
79
- - features/step_definitions/profit_margin_calculations_steps.rb
80
66
  - features/step_definitions/vat_calculations_steps.rb
81
67
  - features/support/env.rb
82
68
  - features/vat_calculations.feature
@@ -101,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
87
  version: '0'
102
88
  segments:
103
89
  - 0
104
- hash: 1810353474154341246
90
+ hash: 4409098266158462653
105
91
  required_rubygems_version: !ruby/object:Gem::Requirement
106
92
  none: false
107
93
  requirements:
@@ -110,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
96
  version: '0'
111
97
  segments:
112
98
  - 0
113
- hash: 1810353474154341246
99
+ hash: 4409098266158462653
114
100
  requirements: []
115
101
  rubyforge_project: corrency
116
102
  rubygems_version: 1.8.24
@@ -118,10 +104,12 @@ signing_key:
118
104
  specification_version: 3
119
105
  summary: Adds Ecommerce Extensions to Various Core Libraries
120
106
  test_files:
107
+ - features/adding_profit_margin.feature
121
108
  - features/nice_rounding.feature
122
- - features/profit_margin_calculations.feature
109
+ - features/profit_margin_from_price.feature
110
+ - features/step_definitions/adding_profit_margin_steps.rb
111
+ - features/step_definitions/calculate_profit_margin_from_price_steps.rb
123
112
  - features/step_definitions/nice_rounding_steps.rb
124
- - features/step_definitions/profit_margin_calculations_steps.rb
125
113
  - features/step_definitions/vat_calculations_steps.rb
126
114
  - features/support/env.rb
127
115
  - features/vat_calculations.feature