lesstrack 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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2009-04-19
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Rob Kaufman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ lesstrack
2
+ by Rob Kaufman
3
+ notch8.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ lesstrack is simpler clone of freshtrack. Basically it allows you to
8
+ upload your punch record to LessTimeSpent.com
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Currently uploads the whole punch.yml file no matter what
13
+ * Should take command line arguments in the future
14
+ * Should map project names instead of their ids
15
+
16
+ == SYNOPSIS:
17
+
18
+ === Config File
19
+ You need a to create a yaml file called .lesstrack.yml like so:
20
+
21
+ username: <username for lesstimespent>
22
+ password: <password for lesstimespent>
23
+ project_mapping:
24
+ <punch project name>: <lesstimespent id number>
25
+ <punch project name>: <lesstimespent id number>
26
+ ...
27
+
28
+ === Running
29
+
30
+ lesstrack
31
+
32
+ == REQUIREMENTS:
33
+
34
+ * restclient
35
+
36
+ == INSTALL:
37
+
38
+ * sudo gem install lesstrack
39
+
40
+ == LICENSE:
41
+
42
+ (The MIT License)
43
+
44
+ Copyright (c) 2009
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining
47
+ a copy of this software and associated documentation files (the
48
+ 'Software'), to deal in the Software without restriction, including
49
+ without limitation the rights to use, copy, modify, merge, publish,
50
+ distribute, sublicense, and/or sell copies of the Software, and to
51
+ permit persons to whom the Software is furnished to do so, subject to
52
+ the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be
55
+ included in all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
58
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
60
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
61
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
62
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
63
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "lesstrack"
8
+ gem.summary = %Q{upload punch to LessTimeSpent}
9
+ gem.description = %Q{this gem provides a link between the yaml based punch format and the lesstimespent.com}
10
+ gem.email = "rob@notch8.com"
11
+ gem.homepage = "http://github.com/notch8/lesstrack"
12
+ gem.authors = ["Rob Kaufman"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "activeresource"
15
+ gem.add_dependency "rest-client"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "lesstrack #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib lesstrack]))
5
+
6
+ # Put your code here
7
+ less = Lesstrack.new
8
+ less.run
9
+ # EOF
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{lesstrack}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rob Kaufman"]
12
+ s.date = %q{2010-06-28}
13
+ s.default_executable = %q{lesstrack}
14
+ s.description = %q{this gem provides a link between the yaml based punch format and the lesstimespent.com}
15
+ s.email = %q{rob@notch8.com}
16
+ s.executables = ["lesstrack"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "History.txt",
25
+ "LICENSE",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/lesstrack",
30
+ "lesstrack.gemspec",
31
+ "lib/lesstrack.rb",
32
+ "lib/lesstrack/clock_punch.rb",
33
+ "spec/clock_punch_spec.rb",
34
+ "spec/fixtures/clock_punches.xml",
35
+ "spec/lesstrack_spec.rb",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/notch8/lesstrack}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.6}
43
+ s.summary = %q{upload punch to LessTimeSpent}
44
+ s.test_files = [
45
+ "spec/clock_punch_spec.rb",
46
+ "spec/lesstrack_spec.rb",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
56
+ s.add_runtime_dependency(%q<activeresource>, [">= 0"])
57
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
60
+ s.add_dependency(%q<activeresource>, [">= 0"])
61
+ s.add_dependency(%q<rest-client>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
65
+ s.add_dependency(%q<activeresource>, [">= 0"])
66
+ s.add_dependency(%q<rest-client>, [">= 0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,110 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ require 'restclient'
4
+
5
+ class Lesstrack
6
+
7
+ def initialize
8
+ @punch = nil
9
+ @config = nil
10
+ end
11
+
12
+ def self.username
13
+ @@username ||= nil
14
+ end
15
+
16
+ def self.password
17
+ @@password ||= nil
18
+ end
19
+
20
+ # load the punch.yml file
21
+ def punch(reload = false)
22
+ if reload || @punch.nil?
23
+ return @punch = YAML.load_file(File.join(ENV['HOME'], '.punch.yml'))
24
+ else
25
+ return @punch
26
+ end
27
+ end
28
+
29
+ def config(reload = false)
30
+ if reload || @config.nil?
31
+ @config = YAML.load_file(File.join(ENV['HOME'], '.lesstrack.yml'))
32
+ @@username = config['username']
33
+ @@password = config['password']
34
+ end
35
+
36
+ return @config
37
+ end
38
+
39
+ def run
40
+ config['project_mapping'].each do |key, project_id|
41
+ clock_punches = ClockPunch.find(:all, :params => {:project_id => project_id})
42
+ punch[key].each do |punch_item|
43
+ next if repeat?(punch_item, clock_punches)
44
+ check_repeat(punch_item, clock_punches)
45
+ notes = punch_item["log"].clone
46
+ notes.delete_if do |value| value.match(/^punch (in|out)/) end
47
+ r = RestClient.post("https://#{config['username']}:#{config['password']}@lesstimespent.com/projects/#{project_id}/clock_punches.xml",
48
+ :clock_punch => {:starts_at => punch_item["in"],
49
+ :ends_at => punch_item["out"],
50
+ :note => notes.join('\n')} )
51
+ end
52
+ end
53
+ end
54
+
55
+ def repeat?(punch_item, clock_punches)
56
+ clock_punches.detect do |clock_punch|
57
+ punch_item["out"] == clock_punch.ends_at && punch_item["in"] == clock_punch.starts_at
58
+ end
59
+ end
60
+
61
+ # load the config for project mapping
62
+ # upload each time entry
63
+ # offer to clear punch.yml (TBD)
64
+
65
+ # :stopdoc:
66
+ VERSION = '1.0.0'
67
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
68
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
69
+ # :startdoc:
70
+
71
+ # Returns the version string for the library.
72
+ #
73
+ def self.version
74
+ VERSION
75
+ end
76
+
77
+ # Returns the library path for the module. If any arguments are given,
78
+ # they will be joined to the end of the libray path using
79
+ # <tt>File.join</tt>.
80
+ #
81
+ def self.libpath( *args )
82
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
83
+ end
84
+
85
+ # Returns the lpath for the module. If any arguments are given,
86
+ # they will be joined to the end of the path using
87
+ # <tt>File.join</tt>.
88
+ #
89
+ def self.path( *args )
90
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
91
+ end
92
+
93
+ # Utility method used to require all files ending in .rb that lie in the
94
+ # directory below this file that has the same name as the filename passed
95
+ # in. Optionally, a specific _directory_ name can be passed in such that
96
+ # the _filename_ does not have to be equivalent to the directory.
97
+ #
98
+ def self.require_all_libs_relative_to( fname, dir = nil )
99
+ dir ||= ::File.basename(fname, '.*')
100
+ search_me = ::File.expand_path(
101
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
102
+
103
+ Dir.glob(search_me).sort.each {|rb| require rb}
104
+ end
105
+
106
+ end # module Lesstrack
107
+
108
+ Lesstrack.require_all_libs_relative_to(__FILE__)
109
+
110
+ # EOF
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'activeresource'
3
+
4
+ unless defined?(USERNAME)
5
+ config = YAML.load_file(File.join(ENV['HOME'], '.lesstrack.yml'))
6
+ USERNAME = config['username']
7
+ end
8
+
9
+ unless defined?(PASSWORD)
10
+ config = YAML.load_file(File.join(ENV['HOME'], '.lesstrack.yml'))
11
+ PASSWORD = config['password']
12
+ end
13
+
14
+ class ClockPunch < ActiveResource::Base
15
+ self.site = "https://lesstimespent.com"
16
+ self.user = USERNAME
17
+ self.password = PASSWORD
18
+
19
+ end
@@ -0,0 +1,11 @@
1
+ require 'pp'
2
+ __DIR__ = File.dirname(__FILE__)
3
+ require File.join(__DIR__, %w[spec_helper])
4
+
5
+ describe ClockPunch do
6
+ it "should read the clock_punches" do
7
+ cp = ClockPunch.find(:first, :params => {:project_id => "2001"})
8
+ cp.should_not be_nil
9
+ end
10
+
11
+ end
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <clock-punches type="array">
3
+ <clock-punch>
4
+ <created-at type="datetime">2009-05-06T11:53:17-07:00</created-at>
5
+ <ends-at type="datetime">2009-05-06T11:53:00-07:00</ends-at>
6
+ <id type="integer">13787</id>
7
+ <membership-id type="integer">1959</membership-id>
8
+ <note/>
9
+ <project-id type="integer">2001</project-id>
10
+ <starts-at type="datetime">2009-05-06T09:00:00-07:00</starts-at>
11
+ <time type="integer">10380</time>
12
+ <updated-at type="datetime">2009-05-06T11:53:17-07:00</updated-at>
13
+ </clock-punch>
14
+ </clock-punches>
@@ -0,0 +1,42 @@
1
+ require 'pp'
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+
4
+ describe Lesstrack do
5
+
6
+ it "should have a method to load the punch.yml file" do
7
+ lesstrack = Lesstrack.new
8
+ lesstrack.punch.should_not be_nil
9
+ lesstrack.punch.should be_instance_of Hash
10
+ end
11
+
12
+ it "should have a method for loading the lesstrack.yml file" do
13
+ lesstrack = Lesstrack.new
14
+ lesstrack.config.should_not be_nil
15
+ lesstrack.config.should be_instance_of Hash
16
+ lesstrack.config.keys.should include 'username'
17
+ lesstrack.config.keys.should include 'password'
18
+ lesstrack.config.keys.should include 'project_mapping'
19
+ end
20
+
21
+ it "should allow checking for repeats" do
22
+ lesstrack = Lesstrack.new
23
+ clock_punches = ClockPunch.find(:all, :params => {:project_id => "2001"})
24
+ depot_punch = {"out"=>Time.parse("Fri May 01 12:00:00 -0700 2009"),
25
+ "total"=>"03:00:00",
26
+ "log"=>["punch in @ 2009-05-01T09:00:00-07:00",
27
+ "punch out @ 2009-05-01T12:00:00-07:00"],
28
+ "in"=>Time.parse("Fri May 01 09:00:00 -0700 2009")}
29
+ lesstrack.repeat?(depot_punch, clock_punches).should_not be_true
30
+ test_punch = {"out"=>Time.parse("2009-05-06T11:53:00-07:00"),
31
+ "total"=>"02:53:17",
32
+ "log"=>["punch in @ 2009-05-01T09:00:00-07:00",
33
+ "punch out @ 2009-05-06T11:53:00-07:00"],
34
+ "in"=>Time.parse("2009-05-06T09:00:00-07:00")}
35
+ lesstrack.repeat?(test_punch, clock_punches).should be_true
36
+
37
+ end
38
+
39
+
40
+ end
41
+
42
+ # EOF
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'lesstrack'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lesstrack
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 1
9
+ version: 1.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Rob Kaufman
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-28 00:00:00 -07:00
18
+ default_executable: lesstrack
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: activeresource
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rest-client
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :runtime
57
+ version_requirements: *id003
58
+ description: this gem provides a link between the yaml based punch format and the lesstimespent.com
59
+ email: rob@notch8.com
60
+ executables:
61
+ - lesstrack
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - LICENSE
66
+ - README.rdoc
67
+ files:
68
+ - .document
69
+ - .gitignore
70
+ - History.txt
71
+ - LICENSE
72
+ - README.rdoc
73
+ - Rakefile
74
+ - VERSION
75
+ - bin/lesstrack
76
+ - lesstrack.gemspec
77
+ - lib/lesstrack.rb
78
+ - lib/lesstrack/clock_punch.rb
79
+ - spec/clock_punch_spec.rb
80
+ - spec/fixtures/clock_punches.xml
81
+ - spec/lesstrack_spec.rb
82
+ - spec/spec.opts
83
+ - spec/spec_helper.rb
84
+ has_rdoc: true
85
+ homepage: http://github.com/notch8/lesstrack
86
+ licenses: []
87
+
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --charset=UTF-8
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ requirements: []
108
+
109
+ rubyforge_project:
110
+ rubygems_version: 1.3.6
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: upload punch to LessTimeSpent
114
+ test_files:
115
+ - spec/clock_punch_spec.rb
116
+ - spec/lesstrack_spec.rb
117
+ - spec/spec_helper.rb