whydoiwork 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5761ea4c7dd119cc20b655f1f5eb0d6d2f42059f
4
+ data.tar.gz: 4a610d70e76954c45490601407fe5fe970a1b65e
5
+ SHA512:
6
+ metadata.gz: b5334b4e0f819b4496a7cc0ababda14fc0df98a0dc0fa3af22470f78cc1fe5c33cd6ef6de9ad3447cfcf8b860525748819539118ef9f02e62f5970009627fa62
7
+ data.tar.gz: 6a8c9818a063214ced9b0f59c2448c426d5e8189e3331632fa8038a4a98b9d521f291887f164d04b7f42293abb51b81ef953b60ed2e17ae87e05c4c2c99dc0a7
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in whydoiwork.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jan Dudek
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Whydoiwork
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'whydoiwork'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install whydoiwork
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
+ require 'whydoiwork'
5
+
6
+ Whydoiwork.run
@@ -0,0 +1,69 @@
1
+ require "yaml"
2
+ require "harvested"
3
+ require "active_support/core_ext/date"
4
+ require "active_support/core_ext/time"
5
+
6
+ require "whydoiwork/version"
7
+
8
+ module Whydoiwork
9
+ def self.run
10
+ unless config_file_exists?
11
+ puts "Config file #{config_file_name} created."
12
+ File.write(config_file_name, config_sample)
13
+ exit 1
14
+ end
15
+
16
+ money = (total_time_from_harvest * config["rate"]).round
17
+
18
+ config["expenses"].each_pair do |name, cost|
19
+ if money > cost
20
+ puts "#{name} (#{cost})… done"
21
+ elsif money > 0
22
+ puts "#{name} (#{cost})… earning right now"
23
+ else
24
+ puts "#{name} (#{cost})"
25
+ end
26
+ money -= cost
27
+ end
28
+
29
+ if money > 0
30
+ puts "Free to spend: #{money}"
31
+ end
32
+ end
33
+
34
+ def self.config
35
+ @config ||= YAML.load_file(config_file_name)
36
+ end
37
+
38
+ def self.config_file_exists?
39
+ File.exists?(config_file_name)
40
+ end
41
+
42
+ def self.config_file_name
43
+ File.expand_path("~/.whydoiwork.yml")
44
+ end
45
+
46
+ def self.config_sample
47
+ <<-YAML
48
+ harvest:
49
+ subdomain:
50
+ username:
51
+ password:
52
+ rate:
53
+ expenses:
54
+ rent: 800
55
+ food: 1000
56
+ car: 250
57
+ YAML
58
+ end
59
+
60
+ def self.total_time_from_harvest
61
+ user_id = harvest.account.who_am_i.id
62
+ time_entries = harvest.reports.time_by_user(user_id, Date.today.beginning_of_month, Date.today.end_of_month)
63
+ time_entries.map(&:hours).inject(0, &:+)
64
+ end
65
+
66
+ def self.harvest
67
+ @harvest ||= Harvest.client(config["harvest"]["subdomain"], config["harvest"]["username"], config["harvest"]["password"])
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ module Whydoiwork
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'whydoiwork/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "whydoiwork"
8
+ spec.version = Whydoiwork::VERSION
9
+ spec.authors = ["Jan Dudek"]
10
+ spec.email = ["jd@jandudek.com"]
11
+ spec.description = %q{Why do I work?}
12
+ spec.summary = %q{Seriously? Why?}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "harvested", "~> 1.2.0"
22
+ spec.add_dependency "activesupport", "~> 4.1.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whydoiwork
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jan Dudek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: harvested
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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
+ description: Why do I work?
70
+ email:
71
+ - jd@jandudek.com
72
+ executables:
73
+ - whydoiwork
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/whydoiwork
83
+ - lib/whydoiwork.rb
84
+ - lib/whydoiwork/version.rb
85
+ - whydoiwork.gemspec
86
+ homepage: ''
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.14
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Seriously? Why?
110
+ test_files: []