one_inch_punch 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-08-18
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Yossef Mendelssohn
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.
data/Manifest.txt ADDED
@@ -0,0 +1,20 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/punch.rb
9
+ lib/punch/version.rb
10
+ script/console
11
+ script/destroy
12
+ script/generate
13
+ setup.rb
14
+ spec/punch_spec.rb
15
+ spec/spec.opts
16
+ spec/spec_helper.rb
17
+ tasks/deployment.rake
18
+ tasks/environment.rake
19
+ tasks/rspec.rake
20
+ tasks/website.rake
data/README.txt ADDED
@@ -0,0 +1,48 @@
1
+ = one_inch_punch
2
+
3
+ == DESCRIPTION:
4
+
5
+ one_inch_punch is meant as a generally data- and interface-compatible alternative
6
+ to Ara T. Howard's punch gem. The main benefits will be greater understandability,
7
+ test coverage, and usage outside of merely command-line situations.
8
+
9
+ Punch: Good enough
10
+ One-inch punch: Smaller, more effective
11
+
12
+ == FEATURES/PROBLEMS:
13
+
14
+ * Can load and write .punch.yml data compatibly with Ara's punch gem
15
+ * Can punch in and out of projects
16
+ * Can query project status
17
+
18
+ * Cannot give a total time (yet)
19
+ * Cannot list time entries (yet)
20
+ * Cannot be used command-line (yet)
21
+ * More, since this is unfinished
22
+
23
+ == SYNOPSIS:
24
+
25
+ require 'punch'
26
+
27
+ Punch.load
28
+ Punch.status('my project') # => 'out'
29
+ Punch.in('my project')
30
+ Punch.status('my project') # => 'in'
31
+ # do some work
32
+ Punch.out('my project')
33
+ Punch.out?('my project') # => true
34
+
35
+ == REQUIREMENTS:
36
+
37
+ * A reason to track time
38
+ * Ruby
39
+
40
+ == INSTALL:
41
+
42
+ * gem install one_inch_punch
43
+
44
+ == THANKS:
45
+
46
+ * Ara T. Howard, for making punch in the first place
47
+ * Kevin Barnes, for the name suggestion
48
+ * The Kool-Aid Man, for busting through my wall. Oh yeah!
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'punch/version'
2
+
3
+ AUTHOR = 'Yossef Mendelssohn' # can also be an array of Authors
4
+ EMAIL = 'ymendel@pobox.com'
5
+ DESCRIPTION = 'a simple time-tracking tool'
6
+ GEM_NAME = 'one_inch_punch' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'yomendel' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Punch::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'one_inch_punch documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,9 @@
1
+ module Punch
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/punch.rb ADDED
@@ -0,0 +1,68 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'yaml'
5
+
6
+ module Punch
7
+ class << self
8
+ private
9
+ attr_accessor :data
10
+
11
+ public
12
+
13
+ def load
14
+ begin
15
+ raw = File.read(File.expand_path('~/.punch.yml'))
16
+ @data = YAML.load(raw)
17
+ rescue Errno::ENOENT
18
+ return false
19
+ end
20
+
21
+ true
22
+ end
23
+
24
+ def reset
25
+ @data = nil
26
+ end
27
+
28
+ def write
29
+ File.open(File.expand_path('~/.punch.yml'), 'w') do |file|
30
+ file.puts @data.to_yaml
31
+ end
32
+ end
33
+
34
+ def status(project)
35
+ project_data = data[project]
36
+ return nil if !project_data or project_data.empty?
37
+
38
+ time_data = project_data.last
39
+ if time_data['out']
40
+ 'out'
41
+ else
42
+ 'in'
43
+ end
44
+ end
45
+
46
+ def out?(project)
47
+ status(project) != 'in'
48
+ end
49
+
50
+ def in?(project)
51
+ status(project) == 'in'
52
+ end
53
+
54
+ def in(project)
55
+ return false if in?(project)
56
+ data[project].push({'in' => Time.now})
57
+ write
58
+ true
59
+ end
60
+
61
+ def out(project)
62
+ return false if out?(project)
63
+ data[project].last['out'] = Time.now
64
+ write
65
+ true
66
+ end
67
+ end
68
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/one_inch_punch.rb'}"
9
+ puts "Loading one_inch_punch gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)