beggar 0.0.2.alpha → 0.0.3.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -3
- data/README.md +3 -0
- data/beggar.gemspec +0 -1
- data/lib/beggar/current_month.rb +4 -4
- data/lib/beggar/hours.rb +5 -5
- data/lib/beggar/salary.rb +6 -6
- data/lib/beggar/version.rb +1 -1
- data/spec/current_month_spec.rb +7 -5
- data/spec/hours_spec.rb +2 -2
- data/spec/salary_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +6 -18
- data/CHANGELOG.md +0 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
beggar (0.0.
|
4
|
+
beggar (0.0.2.alpha)
|
5
5
|
basecamp
|
6
6
|
|
7
7
|
GEM
|
@@ -42,7 +42,6 @@ GEM
|
|
42
42
|
rspec-expectations (2.7.0)
|
43
43
|
diff-lcs (~> 1.1.2)
|
44
44
|
rspec-mocks (2.7.0)
|
45
|
-
timecop (0.3.5)
|
46
45
|
xml-simple (1.1.1)
|
47
46
|
|
48
47
|
PLATFORMS
|
@@ -51,4 +50,3 @@ PLATFORMS
|
|
51
50
|
DEPENDENCIES
|
52
51
|
beggar!
|
53
52
|
rspec
|
54
|
-
timecop
|
data/README.md
CHANGED
data/beggar.gemspec
CHANGED
data/lib/beggar/current_month.rb
CHANGED
@@ -9,16 +9,16 @@ module Beggar
|
|
9
9
|
first_day.next_month - 1
|
10
10
|
end
|
11
11
|
|
12
|
-
def working_days(
|
13
|
-
|
12
|
+
def working_days(range)
|
13
|
+
range.reject { |d| [0,6].include? d.wday }.size
|
14
14
|
end
|
15
15
|
|
16
16
|
def working_days_up_today
|
17
|
-
working_days(Date.today)
|
17
|
+
working_days(first_day..Date.today)
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s
|
21
|
-
%[#{(working_days_up_today.to_f / working_days * 100).round}%]
|
21
|
+
%[#{(working_days_up_today.to_f / working_days(first_day..last_day) * 100).round}%]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/beggar/hours.rb
CHANGED
@@ -5,20 +5,20 @@ module Beggar
|
|
5
5
|
class << self
|
6
6
|
attr_accessor :project_id
|
7
7
|
|
8
|
-
def
|
9
|
-
@@
|
8
|
+
def worked
|
9
|
+
@@worked ||= Basecamp::TimeEntry.report(project_id: project_id, from: CurrentMonth.first_day, to: Date.today).map(&:hours).inject(&:+)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def max_up_today
|
13
13
|
CurrentMonth.working_days_up_today * 8
|
14
14
|
end
|
15
15
|
|
16
16
|
def difference
|
17
|
-
|
17
|
+
max_up_today - worked
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s
|
21
|
-
%[#{
|
21
|
+
%[#{worked}h ± #{difference}h]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/beggar/salary.rb
CHANGED
@@ -5,20 +5,20 @@ module Beggar
|
|
5
5
|
class << self
|
6
6
|
attr_accessor :rate
|
7
7
|
|
8
|
-
def
|
9
|
-
Hours.
|
8
|
+
def today
|
9
|
+
Hours.worked * rate
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
Hours.
|
12
|
+
def max_up_today
|
13
|
+
Hours.max_up_today * rate
|
14
14
|
end
|
15
15
|
|
16
16
|
def difference
|
17
|
-
|
17
|
+
max_up_today - today
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s
|
21
|
-
%[#{
|
21
|
+
%[#{today} PLN ± #{difference} PLN]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/beggar/version.rb
CHANGED
data/spec/current_month_spec.rb
CHANGED
@@ -2,14 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Beggar::CurrentMonth do
|
4
4
|
context 'today is the 24th December 2011' do
|
5
|
-
before
|
6
|
-
|
5
|
+
before { Date.stub(today: Date.new(2011, 12, 24)) }
|
6
|
+
|
7
|
+
let(:first_day) { Date.new(2011, 12, 1) }
|
8
|
+
let(:last_day) { Date.new(2011, 12, 31) }
|
7
9
|
|
8
10
|
subject { Beggar::CurrentMonth }
|
9
11
|
|
10
|
-
its(:first_day) { should ==
|
11
|
-
its(:last_day) { should ==
|
12
|
-
|
12
|
+
its(:first_day) { should == first_day }
|
13
|
+
its(:last_day) { should == last_day }
|
14
|
+
it { subject.working_days(first_day..last_day).should == 22 }
|
13
15
|
its(:working_days_up_today) { should == 17 }
|
14
16
|
its(:to_s) { should == '77%' }
|
15
17
|
end
|
data/spec/hours_spec.rb
CHANGED
@@ -12,8 +12,8 @@ describe 'Beggar::Hours' do
|
|
12
12
|
|
13
13
|
subject { Beggar::Hours }
|
14
14
|
|
15
|
-
its(:
|
16
|
-
its(:
|
15
|
+
its(:worked) { should == 14.0 }
|
16
|
+
its(:max_up_today) { should == 16.0 }
|
17
17
|
its(:difference) { should == 2.0 }
|
18
18
|
its(:to_s) { should == '14.0h ± 2.0h' }
|
19
19
|
end
|
data/spec/salary_spec.rb
CHANGED
@@ -5,14 +5,14 @@ require 'spec_helper'
|
|
5
5
|
describe 'Beggar::Salary' do
|
6
6
|
context 'user was working 10h (max: 40h) in current month and his rate per h amount 100.0 PLN' do
|
7
7
|
before do
|
8
|
-
Beggar::Hours.stub(
|
8
|
+
Beggar::Hours.stub(worked: 10, max_up_today: 40)
|
9
9
|
Beggar::Salary.stub(rate: 100.0)
|
10
10
|
end
|
11
11
|
|
12
12
|
subject { Beggar::Salary }
|
13
13
|
|
14
|
-
its(:
|
15
|
-
its(:
|
14
|
+
its(:today) { should == 1000.0 }
|
15
|
+
its(:max_up_today) { should == 4000.0 }
|
16
16
|
its(:difference) { should == 3000.0 }
|
17
17
|
its(:to_s) { should == '1000.0 PLN ± 3000.0 PLN' }
|
18
18
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beggar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.alpha
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70210180152260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: timecop
|
27
|
-
requirement: &70164495032040 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70164495032040
|
24
|
+
version_requirements: *70210180152260
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: basecamp
|
38
|
-
requirement: &
|
27
|
+
requirement: &70210180151220 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ! '>='
|
@@ -43,7 +32,7 @@ dependencies:
|
|
43
32
|
version: '0'
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *70210180151220
|
47
36
|
description: Tool for generating time reports from Basecamp. You can specify rate
|
48
37
|
for each project and get value of your month salary.
|
49
38
|
email:
|
@@ -56,7 +45,6 @@ files:
|
|
56
45
|
- .gitignore
|
57
46
|
- .rspec
|
58
47
|
- .travis.yml
|
59
|
-
- CHANGELOG.md
|
60
48
|
- Gemfile
|
61
49
|
- Gemfile.lock
|
62
50
|
- LICENSE
|
data/CHANGELOG.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
TODO
|