salary_calc 0.1.0 → 1.0.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.
- checksums.yaml +5 -13
- data/.travis.yml +3 -0
- data/README.md +2 -0
- data/lib/salary_calc.rb +4 -0
- data/lib/salary_calc/conversions/from_hourly.rb +12 -4
- data/lib/salary_calc/conversions/to_hourly.rb +4 -4
- data/lib/salary_calc/version.rb +1 -1
- data/salary_calc.gemspec +3 -1
- data/spec/salary_calc_spec.rb +21 -15
- data/spec/spec_helper.rb +3 -7
- metadata +44 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YTQ3YmRiYTgxZTNhODllNWY0ZmZjZDQ3ZDFjNGY0MWFlMTk5NjQzZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d1cb72657797ce3318b9e8ef7e21e29e22be6f36
|
4
|
+
data.tar.gz: 350f5e94cc80069e636919a0028a18c3fd1f83cb
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NjZiNDU2ZjhmYTcwZTNiMTljZGQwZTY3NDc2NDYxMmZjZjRiMzk3NTQyZThk
|
11
|
-
NjcxZTExNGNiZGQ5NGM3NTkyODI0YjliNDg5YmE5ZjRkZmE0OWU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTcwZWFlMmMxOTQ3MjQzNTFiYzBhZjVmMzgyMjBhZWM5Y2U4OTg2NjdhNWFk
|
14
|
-
N2FiYzMwNTg1ZTY2N2ZhZjc5NDgxZDFlMzE5OGVmYWMxZmFlMGRkYTA3YTRk
|
15
|
-
ZTIxNzQ0ZmYzZTYzN2EzMjQ5NTkzOWFkM2NhYWZkOTJlZDI1ZmE=
|
6
|
+
metadata.gz: 70a71932e0f8e7e0633fdbe036897329ab33ded9c683fb0e301fa465efe7055e5a07524130e0d95dbdb1fd6191230de29808b7c83bd18e26722d2a53f914b553
|
7
|
+
data.tar.gz: 5c36968b42e44074bb1e0cb4002e06a94a2da4bad9738a77382f70df496549fc2206dda491827d20890364410e6a1f212b987f22a75ae142a460f95c6cca1105
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# SalaryCalc
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/salary_calc) [](https://travis-ci.org/blackxored/salary-calc.rb) [](https://coveralls.io/r/blackxored/salary_calc.rb) [](https://gemnasium.com/blackxored/salary_calc.rb) [](https://codeclimate.com/github/blackxored/salary_calc.rb)
|
4
|
+
|
3
5
|
A very simple salary calculator.
|
4
6
|
|
5
7
|
## Installation
|
data/lib/salary_calc.rb
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
module SalaryCalc::Conversions
|
2
2
|
module FromHourly
|
3
3
|
def to_yearly
|
4
|
-
|
4
|
+
rounded(to_weekly * 52)
|
5
5
|
end
|
6
6
|
|
7
|
+
# Does not calculate monthly salary based on a 4 week month.
|
8
|
+
# Some people define a month as 4 weeks. Use {#to_monthly_alternate}
|
9
|
+
# for a version using this assumption.
|
10
|
+
# This might be removed in the future.
|
7
11
|
def to_monthly
|
8
|
-
|
12
|
+
rounded(amount.to_f * (billable_hours * 5) * 52 / 12)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_monthly_alternate
|
16
|
+
rounded(to_weekly * 4)
|
9
17
|
end
|
10
18
|
|
11
19
|
def to_weekly
|
12
|
-
to_daily * 5
|
20
|
+
rounded(to_daily * 5.0)
|
13
21
|
end
|
14
22
|
|
15
23
|
def to_daily
|
16
|
-
billable_hours * amount
|
24
|
+
rounded(billable_hours * amount.to_f)
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module SalaryCalc::Conversions
|
2
2
|
module ToHourly
|
3
3
|
def from_yearly(yearly)
|
4
|
-
|
4
|
+
rounded(yearly.to_f / 52 / (billable_hours * 5))
|
5
5
|
end
|
6
6
|
|
7
7
|
def from_monthly(monthly)
|
8
|
-
|
8
|
+
rounded(monthly.to_f * 12 / 52 / (billable_hours * 5))
|
9
9
|
end
|
10
10
|
|
11
11
|
def from_weekly(weekly)
|
12
|
-
|
12
|
+
rounded(weekly.to_f / (billable_hours * 5))
|
13
13
|
end
|
14
14
|
|
15
15
|
def from_daily(daily)
|
16
|
-
daily / billable_hours
|
16
|
+
rounded(daily.to_f / billable_hours)
|
17
17
|
end
|
18
18
|
|
19
19
|
[:yearly, :monthly, :weekly, :daily].each do |period|
|
data/lib/salary_calc/version.rb
CHANGED
data/salary_calc.gemspec
CHANGED
@@ -20,5 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec", "~> 2
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
spec.add_development_dependency "pry"
|
24
26
|
end
|
data/spec/salary_calc_spec.rb
CHANGED
@@ -16,68 +16,74 @@ module SalaryCalc
|
|
16
16
|
end
|
17
17
|
|
18
18
|
context "calculations" do
|
19
|
-
let(:amount) {
|
19
|
+
let(:amount) { 60 }
|
20
20
|
let(:calculator) { described_class.new(amount) }
|
21
21
|
|
22
22
|
describe "#to_yearly" do
|
23
23
|
it "calculates the yearly salary from an hourly rate" do
|
24
|
-
expect(calculator.to_yearly).to eq(
|
24
|
+
expect(calculator.to_yearly).to eq(124_800)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#to_monthly" do
|
29
29
|
it "calculates the monthly salary from an hourly rate" do
|
30
|
-
expect(calculator.to_monthly).to eq(
|
30
|
+
expect(calculator.to_monthly).to eq(10_400)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#to_monthly_alternate" do
|
35
|
+
it "calculates the monthly salary taking a month as 4 weeks (no overtime)" do
|
36
|
+
expect(calculator.to_monthly_alternate).to eq(9_600)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
34
40
|
describe "#to_weekly" do
|
35
|
-
it "calculates
|
36
|
-
expect(calculator.to_weekly).to eq(
|
41
|
+
it "calculates the weekly salary from an hourly rate" do
|
42
|
+
expect(calculator.to_weekly).to eq(2_400)
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
46
|
describe "#to_daily" do
|
41
47
|
it "calculates the daily salary for an hourly rate" do
|
42
|
-
expect(calculator.to_daily).to eq(
|
48
|
+
expect(calculator.to_daily).to eq(480)
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
46
52
|
describe "#from_yearly" do
|
47
53
|
it "returns the hourly rate from a yearly salary" do
|
48
|
-
expect(calculator.from_yearly(
|
54
|
+
expect(calculator.from_yearly(124_800)).to eq(60)
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
58
|
describe "#from_monthly" do
|
53
59
|
it "returns the hourly rate from a monthly salary" do
|
54
|
-
expect(calculator.from_monthly(
|
60
|
+
expect(calculator.from_monthly(10_400)).to eq(60)
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
58
64
|
describe "#from_weekly" do
|
59
65
|
it "returns the hourly rate from a weekly salary" do
|
60
|
-
expect(calculator.from_weekly(
|
66
|
+
expect(calculator.from_weekly(2_400)).to eq(60)
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
64
70
|
describe "#from_daily" do
|
65
71
|
it "returns the hourly rate from a daily salary" do
|
66
|
-
expect(calculator.from_daily(
|
72
|
+
expect(calculator.from_daily(480)).to eq(60)
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
70
76
|
describe "#from_*_!" do
|
71
77
|
it "modifies the calculator's amount to reflect hourly rate" do
|
72
|
-
expect(calculator.amount).to eq(
|
73
|
-
calculator.from_monthly!(
|
74
|
-
expect(calculator.amount).to eq(
|
78
|
+
expect(calculator.amount).to eq(60)
|
79
|
+
calculator.from_monthly!(6_000)
|
80
|
+
expect(calculator.amount).to eq(34.62)
|
75
81
|
end
|
76
82
|
|
77
83
|
it "uses the amount from the calculator if none specified" do
|
78
|
-
calculator.amount =
|
84
|
+
calculator.amount = 6000
|
79
85
|
calculator.from_monthly!
|
80
|
-
expect(calculator.amount).to eq(
|
86
|
+
expect(calculator.amount).to eq(34.62)
|
81
87
|
end
|
82
88
|
end
|
83
89
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
7
4
|
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
5
|
config.run_all_when_everything_filtered = true
|
10
6
|
#config.filter_run :focus
|
11
7
|
|
metadata
CHANGED
@@ -1,57 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salary_calc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Perez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2
|
47
|
+
version: '3.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: A very simple salary calculator
|
56
84
|
email:
|
57
85
|
- adrianperez.deb@gmail.com
|
@@ -59,8 +87,9 @@ executables: []
|
|
59
87
|
extensions: []
|
60
88
|
extra_rdoc_files: []
|
61
89
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
64
93
|
- Gemfile
|
65
94
|
- LICENSE.txt
|
66
95
|
- README.md
|
@@ -82,17 +111,17 @@ require_paths:
|
|
82
111
|
- lib
|
83
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
113
|
requirements:
|
85
|
-
- -
|
114
|
+
- - ">="
|
86
115
|
- !ruby/object:Gem::Version
|
87
116
|
version: '0'
|
88
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
118
|
requirements:
|
90
|
-
- -
|
119
|
+
- - ">="
|
91
120
|
- !ruby/object:Gem::Version
|
92
121
|
version: '0'
|
93
122
|
requirements: []
|
94
123
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.4.5
|
96
125
|
signing_key:
|
97
126
|
specification_version: 4
|
98
127
|
summary: A very simple salary calculator
|