beggar 0.0.1.alpha → 0.0.2.alpha
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 +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile.lock +31 -1
- data/README.md +3 -1
- data/beggar.gemspec +5 -3
- data/bin/beggar +2 -0
- data/lib/beggar/base.rb +16 -0
- data/lib/beggar/cli.rb +17 -0
- data/lib/beggar/current_month.rb +25 -0
- data/lib/beggar/hours.rb +25 -0
- data/lib/beggar/salary.rb +25 -0
- data/lib/beggar/version.rb +1 -1
- data/lib/beggar.rb +8 -5
- data/spec/base_spec.rb +17 -0
- data/spec/current_month_spec.rb +16 -0
- data/spec/hours_spec.rb +20 -0
- data/spec/salary_spec.rb +19 -0
- data/spec/spec_helper.rb +1 -0
- metadata +43 -7
- data/spec/beggar_spec.rb +0 -5
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
TODO
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
beggar (0.0.1)
|
4
|
+
beggar (0.0.1.alpha)
|
5
|
+
basecamp
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
10
|
+
activemodel (3.1.3)
|
11
|
+
activesupport (= 3.1.3)
|
12
|
+
builder (~> 3.0.0)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
activeresource (3.1.3)
|
15
|
+
activemodel (= 3.1.3)
|
16
|
+
activesupport (= 3.1.3)
|
17
|
+
activesupport (3.1.3)
|
18
|
+
multi_json (~> 1.0)
|
19
|
+
addressable (2.2.6)
|
20
|
+
basecamp (0.0.7)
|
21
|
+
activeresource (>= 2.3.0)
|
22
|
+
oauth2
|
23
|
+
xml-simple
|
24
|
+
builder (3.0.0)
|
9
25
|
diff-lcs (1.1.3)
|
26
|
+
faraday (0.7.5)
|
27
|
+
addressable (~> 2.2.6)
|
28
|
+
multipart-post (~> 1.1.3)
|
29
|
+
rack (>= 1.1.0, < 2)
|
30
|
+
i18n (0.6.0)
|
31
|
+
multi_json (1.0.4)
|
32
|
+
multipart-post (1.1.4)
|
33
|
+
oauth2 (0.5.1)
|
34
|
+
faraday (~> 0.7.4)
|
35
|
+
multi_json (~> 1.0.3)
|
36
|
+
rack (1.3.5)
|
10
37
|
rspec (2.7.0)
|
11
38
|
rspec-core (~> 2.7.0)
|
12
39
|
rspec-expectations (~> 2.7.0)
|
@@ -15,6 +42,8 @@ GEM
|
|
15
42
|
rspec-expectations (2.7.0)
|
16
43
|
diff-lcs (~> 1.1.2)
|
17
44
|
rspec-mocks (2.7.0)
|
45
|
+
timecop (0.3.5)
|
46
|
+
xml-simple (1.1.1)
|
18
47
|
|
19
48
|
PLATFORMS
|
20
49
|
ruby
|
@@ -22,3 +51,4 @@ PLATFORMS
|
|
22
51
|
DEPENDENCIES
|
23
52
|
beggar!
|
24
53
|
rspec
|
54
|
+
timecop
|
data/README.md
CHANGED
data/beggar.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
|
+
|
2
3
|
$:.push File.expand_path("../lib", __FILE__)
|
3
4
|
require "beggar/version"
|
4
5
|
|
@@ -7,7 +8,7 @@ Gem::Specification.new do |s|
|
|
7
8
|
s.version = Beggar::VERSION
|
8
9
|
s.authors = ["Bartlomiej Kozal"]
|
9
10
|
s.email = ["bkzl@me.com"]
|
10
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/bkzl/beggar"
|
11
12
|
s.summary = %q{Tool for generating time reports from Basecamp}
|
12
13
|
s.description = %q{Tool for generating time reports from Basecamp. You can specify rate for each project and get value of your month salary.}
|
13
14
|
|
@@ -20,5 +21,6 @@ Gem::Specification.new do |s|
|
|
20
21
|
|
21
22
|
# specify any dependencies here; for example:
|
22
23
|
s.add_development_dependency "rspec"
|
23
|
-
|
24
|
+
s.add_development_dependency "timecop"
|
25
|
+
s.add_runtime_dependency "basecamp"
|
24
26
|
end
|
data/bin/beggar
CHANGED
data/lib/beggar/base.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Beggar
|
4
|
+
class Base
|
5
|
+
def initialize(config)
|
6
|
+
Basecamp.establish_connection!("#{config['company']}.basecamphq.com", config['token'], 'X', true)
|
7
|
+
|
8
|
+
Hours.project_id = config['project']['id']
|
9
|
+
Salary.rate = config['project']['rate']
|
10
|
+
end
|
11
|
+
|
12
|
+
def summary
|
13
|
+
[CurrentMonth, Hours, Salary].join(' || ') + "\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/beggar/cli.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Beggar
|
2
|
+
class CLI
|
3
|
+
def initialize(args = nil)
|
4
|
+
@config = load_config
|
5
|
+
end
|
6
|
+
|
7
|
+
def start
|
8
|
+
$stdout << Beggar::Base.new(@config).summary
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def load_config
|
14
|
+
YAML.load_file(File.join(ENV['HOME'], '.beggar'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Beggar
|
2
|
+
class CurrentMonth
|
3
|
+
class << self
|
4
|
+
def first_day
|
5
|
+
Date.new(Date.today.year, Date.today.month, 1)
|
6
|
+
end
|
7
|
+
|
8
|
+
def last_day
|
9
|
+
first_day.next_month - 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def working_days(last_day = last_day)
|
13
|
+
(first_day..last_day).reject { |d| [0,6].include? d.wday }.size
|
14
|
+
end
|
15
|
+
|
16
|
+
def working_days_up_today
|
17
|
+
working_days(Date.today)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
%[#{(working_days_up_today.to_f / working_days * 100).round}%]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/beggar/hours.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Beggar
|
4
|
+
class Hours
|
5
|
+
class << self
|
6
|
+
attr_accessor :project_id
|
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(&:+)
|
10
|
+
end
|
11
|
+
|
12
|
+
def up_today
|
13
|
+
CurrentMonth.working_days_up_today * 8
|
14
|
+
end
|
15
|
+
|
16
|
+
def difference
|
17
|
+
up_today - from_basecamp
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
%[#{from_basecamp}h ± #{difference}h]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Beggar
|
4
|
+
class Salary
|
5
|
+
class << self
|
6
|
+
attr_accessor :rate
|
7
|
+
|
8
|
+
def from_basecamp
|
9
|
+
Hours.from_basecamp * rate
|
10
|
+
end
|
11
|
+
|
12
|
+
def up_today
|
13
|
+
Hours.up_today * rate
|
14
|
+
end
|
15
|
+
|
16
|
+
def difference
|
17
|
+
up_today - from_basecamp
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
%[#{from_basecamp} PLN ± #{difference} PLN]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/beggar/version.rb
CHANGED
data/lib/beggar.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require 'basecamp'
|
2
|
+
require 'yaml'
|
3
|
+
require 'beggar/version'
|
4
|
+
require 'beggar/cli'
|
5
|
+
require 'beggar/base'
|
6
|
+
require 'beggar/current_month'
|
7
|
+
require 'beggar/hours'
|
8
|
+
require 'beggar/salary'
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Beggar::Base do
|
4
|
+
before do
|
5
|
+
Basecamp.stub(:establish_connection!)
|
6
|
+
Beggar::CurrentMonth.stub(to_s: 'a')
|
7
|
+
Beggar::Hours.stub(to_s: 'b')
|
8
|
+
Beggar::Salary.stub(to_s: 'c')
|
9
|
+
end
|
10
|
+
|
11
|
+
subject do
|
12
|
+
config = double(:[] => { company: 'abc', token: 'xyz', project: { id: 1, rate: 1.0 }})
|
13
|
+
Beggar::Base.new(config)
|
14
|
+
end
|
15
|
+
|
16
|
+
its(:summary) { should == %(a || b || c\n) }
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Beggar::CurrentMonth do
|
4
|
+
context 'today is the 24th December 2011' do
|
5
|
+
before(:all) { Timecop.travel(Date.new(2011, 12, 24)) }
|
6
|
+
after(:all) { Timecop.return }
|
7
|
+
|
8
|
+
subject { Beggar::CurrentMonth }
|
9
|
+
|
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 }
|
13
|
+
its(:working_days_up_today) { should == 17 }
|
14
|
+
its(:to_s) { should == '77%' }
|
15
|
+
end
|
16
|
+
end
|
data/spec/hours_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Beggar::Hours' do
|
6
|
+
context 'user was working in current month 2 days (8h and 6h)' do
|
7
|
+
before do
|
8
|
+
api_response = double(map: [8.0, 6.0])
|
9
|
+
Basecamp::TimeEntry.stub(report: api_response)
|
10
|
+
Beggar::CurrentMonth.stub(working_days_up_today: 2)
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { Beggar::Hours }
|
14
|
+
|
15
|
+
its(:from_basecamp) { should == 14.0 }
|
16
|
+
its(:up_today) { should == 16.0 }
|
17
|
+
its(:difference) { should == 2.0 }
|
18
|
+
its(:to_s) { should == '14.0h ± 2.0h' }
|
19
|
+
end
|
20
|
+
end
|
data/spec/salary_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Beggar::Salary' do
|
6
|
+
context 'user was working 10h (max: 40h) in current month and his rate per h amount 100.0 PLN' do
|
7
|
+
before do
|
8
|
+
Beggar::Hours.stub(from_basecamp: 10, up_today: 40)
|
9
|
+
Beggar::Salary.stub(rate: 100.0)
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { Beggar::Salary }
|
13
|
+
|
14
|
+
its(:from_basecamp) { should == 1000.0 }
|
15
|
+
its(:up_today) { should == 4000.0 }
|
16
|
+
its(:difference) { should == 3000.0 }
|
17
|
+
its(:to_s) { should == '1000.0 PLN ± 3000.0 PLN' }
|
18
|
+
end
|
19
|
+
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.2.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-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70164495032580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,29 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
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
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: basecamp
|
38
|
+
requirement: &70164495031520 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70164495031520
|
25
47
|
description: Tool for generating time reports from Basecamp. You can specify rate
|
26
48
|
for each project and get value of your month salary.
|
27
49
|
email:
|
@@ -31,7 +53,10 @@ executables:
|
|
31
53
|
extensions: []
|
32
54
|
extra_rdoc_files: []
|
33
55
|
files:
|
56
|
+
- .gitignore
|
34
57
|
- .rspec
|
58
|
+
- .travis.yml
|
59
|
+
- CHANGELOG.md
|
35
60
|
- Gemfile
|
36
61
|
- Gemfile.lock
|
37
62
|
- LICENSE
|
@@ -40,10 +65,18 @@ files:
|
|
40
65
|
- beggar.gemspec
|
41
66
|
- bin/beggar
|
42
67
|
- lib/beggar.rb
|
68
|
+
- lib/beggar/base.rb
|
69
|
+
- lib/beggar/cli.rb
|
70
|
+
- lib/beggar/current_month.rb
|
71
|
+
- lib/beggar/hours.rb
|
72
|
+
- lib/beggar/salary.rb
|
43
73
|
- lib/beggar/version.rb
|
44
|
-
- spec/
|
74
|
+
- spec/base_spec.rb
|
75
|
+
- spec/current_month_spec.rb
|
76
|
+
- spec/hours_spec.rb
|
77
|
+
- spec/salary_spec.rb
|
45
78
|
- spec/spec_helper.rb
|
46
|
-
homepage:
|
79
|
+
homepage: https://github.com/bkzl/beggar
|
47
80
|
licenses: []
|
48
81
|
post_install_message:
|
49
82
|
rdoc_options: []
|
@@ -68,5 +101,8 @@ signing_key:
|
|
68
101
|
specification_version: 3
|
69
102
|
summary: Tool for generating time reports from Basecamp
|
70
103
|
test_files:
|
71
|
-
- spec/
|
104
|
+
- spec/base_spec.rb
|
105
|
+
- spec/current_month_spec.rb
|
106
|
+
- spec/hours_spec.rb
|
107
|
+
- spec/salary_spec.rb
|
72
108
|
- spec/spec_helper.rb
|