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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beggar (0.0.1.alpha)
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
@@ -7,3 +7,6 @@ Tool for generating time reports from Basecamp
7
7
 
8
8
  ## Usage
9
9
  TODO
10
+
11
+ ## Changelog
12
+ TODO
data/beggar.gemspec CHANGED
@@ -21,6 +21,5 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # specify any dependencies here; for example:
23
23
  s.add_development_dependency "rspec"
24
- s.add_development_dependency "timecop"
25
24
  s.add_runtime_dependency "basecamp"
26
25
  end
@@ -9,16 +9,16 @@ module Beggar
9
9
  first_day.next_month - 1
10
10
  end
11
11
 
12
- def working_days(last_day = last_day)
13
- (first_day..last_day).reject { |d| [0,6].include? d.wday }.size
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 from_basecamp
9
- @@from_basecamp ||= Basecamp::TimeEntry.report(project_id: project_id, from: CurrentMonth.first_day, to: Date.today).map(&:hours).inject(&:+)
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 up_today
12
+ def max_up_today
13
13
  CurrentMonth.working_days_up_today * 8
14
14
  end
15
15
 
16
16
  def difference
17
- up_today - from_basecamp
17
+ max_up_today - worked
18
18
  end
19
19
 
20
20
  def to_s
21
- %[#{from_basecamp}h ± #{difference}h]
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 from_basecamp
9
- Hours.from_basecamp * rate
8
+ def today
9
+ Hours.worked * rate
10
10
  end
11
11
 
12
- def up_today
13
- Hours.up_today * rate
12
+ def max_up_today
13
+ Hours.max_up_today * rate
14
14
  end
15
15
 
16
16
  def difference
17
- up_today - from_basecamp
17
+ max_up_today - today
18
18
  end
19
19
 
20
20
  def to_s
21
- %[#{from_basecamp} PLN ± #{difference} PLN]
21
+ %[#{today} PLN ± #{difference} PLN]
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Beggar
2
- VERSION = "0.0.2.alpha"
2
+ VERSION = "0.0.3.alpha"
3
3
  end
@@ -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(:all) { Timecop.travel(Date.new(2011, 12, 24)) }
6
- after(:all) { Timecop.return }
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 == Date.new(2011, 12, 1) }
11
- its(:last_day) { should == Date.new(2011, 12, 31) }
12
- its(:working_days) { should == 22 }
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(:from_basecamp) { should == 14.0 }
16
- its(:up_today) { should == 16.0 }
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(from_basecamp: 10, up_today: 40)
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(:from_basecamp) { should == 1000.0 }
15
- its(:up_today) { should == 4000.0 }
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
@@ -1,2 +1 @@
1
1
  require 'beggar'
2
- require 'timecop'
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.2.alpha
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-14 00:00:00.000000000 Z
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: &70164495032580 !ruby/object:Gem::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: *70164495032580
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: &70164495031520 !ruby/object:Gem::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: *70164495031520
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