timetrap 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -103,7 +103,7 @@ Commands
103
103
  usage: ``t backend``
104
104
 
105
105
  **configure**
106
- Creates a config file at ~/.timetrap.yml or ENV['TIMETRAP_CONFIG_FILE'] if
106
+ Creates a config file at ``~/.timetrap.yml`` or ``ENV['TIMETRAP_CONFIG_FILE']`` if
107
107
  one doesn't exist. Prints path to config file. Currently allows configuration
108
108
  of path to database file.
109
109
 
@@ -190,6 +190,15 @@ Global Options
190
190
  display commands (e.g. display, list, week, etc.) and is non-destructive.
191
191
  The actual start and end time stored by Timetrap are unaffected.
192
192
 
193
+ Configuration
194
+ --------
195
+
196
+ Configuration of TimeTrap's behavior can be done through a YAML config file.
197
+ See ``t configure`` for details. Currently supported options are:
198
+
199
+ round_in_seconds: The duration of time to use for rounding with the -r flag
200
+ database_file: The file path of the sqlite databese
201
+
193
202
  Bugs and Feature Requests
194
203
  --------
195
204
  Submit to http://github.com/samg/timetrap/issues
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 0
4
+ :patch: 1
@@ -3,9 +3,18 @@ module Timetrap
3
3
  extend self
4
4
  PATH = ENV['TIMETRAP_CONFIG_FILE'] || File.join(ENV['HOME'], '.timetrap.yml')
5
5
 
6
+ # Application defaults.
7
+ #
8
+ # These are written to a config file by invoking:
9
+ # <code>
10
+ # t configure
11
+ # </code>
6
12
  def defaults
7
13
  {
8
- 'database_file' => "#{ENV['HOME']}/.timetrap.db"
14
+ # Path to the sqlite db
15
+ 'database_file' => "#{ENV['HOME']}/.timetrap.db",
16
+ # Unit of time for rounding (-r) in seconds
17
+ 'round_in_seconds' => 900
9
18
  }
10
19
  end
11
20
 
@@ -44,10 +44,10 @@ module Timetrap
44
44
  def round time
45
45
  return nil unless time
46
46
  Time.at(
47
- if (r = time.to_i % 900) < 450
47
+ if (r = time.to_i % Timetrap::Config['round_in_seconds']) < 450
48
48
  time.to_i - r
49
49
  else
50
- time.to_i + (900 - r)
50
+ time.to_i + (Timetrap::Config['round_in_seconds'] - r)
51
51
  end
52
52
  )
53
53
  end
@@ -3,6 +3,14 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'timetrap')
3
3
  require 'spec'
4
4
  require 'fakefs/safe'
5
5
 
6
+ module Timetrap::StubConfig
7
+ def with_stubbed_config options
8
+ options.each do |k, v|
9
+ Timetrap::Config.stub(:[]).with(k).and_return v
10
+ end
11
+ end
12
+ end
13
+
6
14
  describe Timetrap do
7
15
  def create_entry atts = {}
8
16
  Timetrap::Entry.create({
@@ -12,6 +20,7 @@ describe Timetrap do
12
20
  :note => 'note'}.merge(atts))
13
21
  end
14
22
 
23
+
15
24
  before :each do
16
25
  Timetrap::Entry.create_table!
17
26
  Timetrap::Meta.create_table!
@@ -548,6 +557,8 @@ current sheet: 0:01:00 (a timesheet that is running)
548
557
  end
549
558
 
550
559
  describe Timetrap::Entry do
560
+
561
+ include Timetrap::StubConfig
551
562
  describe "with an instance" do
552
563
  before do
553
564
  @time = Time.now
@@ -575,10 +586,10 @@ describe Timetrap::Entry do
575
586
  @entry.sheet.should == 'name'
576
587
  end
577
588
 
578
- def with_global_round_set_to val
589
+ def with_rounding_on
579
590
  old_val = Timetrap::Entry.round
580
591
  begin
581
- Timetrap::Entry.round = val
592
+ Timetrap::Entry.round = true
582
593
  block_return_value = yield
583
594
  ensure
584
595
  Timetrap::Entry.round = old_val
@@ -586,25 +597,31 @@ describe Timetrap::Entry do
586
597
  end
587
598
 
588
599
  it "should use round start if the global round attribute is set" do
589
- with_global_round_set_to true do
590
- @time = Chronic.parse("12:55am")
591
- @entry.start = @time
592
- @entry.start.should == Chronic.parse("1am")
600
+ with_rounding_on do
601
+ with_stubbed_config('round_in_seconds' => 900) do
602
+ @time = Chronic.parse("12:55am")
603
+ @entry.start = @time
604
+ @entry.start.should == Chronic.parse("1am")
605
+ end
593
606
  end
594
607
  end
595
608
 
596
609
  it "should use round start if the global round attribute is set" do
597
- with_global_round_set_to true do
598
- @time = Chronic.parse("12:50am")
599
- @entry.start = @time
600
- @entry.start.should == Chronic.parse("12:45am")
610
+ with_rounding_on do
611
+ with_stubbed_config('round_in_seconds' => 900) do
612
+ @time = Chronic.parse("12:50am")
613
+ @entry.start = @time
614
+ @entry.start.should == Chronic.parse("12:45am")
615
+ end
601
616
  end
602
617
  end
603
618
 
604
619
  it "should have a rounded start" do
605
- @time = Chronic.parse("12:50am")
606
- @entry.start = @time
607
- @entry.rounded_start.should == Chronic.parse("12:45am")
620
+ with_stubbed_config('round_in_seconds' => 900) do
621
+ @time = Chronic.parse("12:50am")
622
+ @entry.start = @time
623
+ @entry.rounded_start.should == Chronic.parse("12:45am")
624
+ end
608
625
  end
609
626
 
610
627
  it "should not round nil times" do
data/timetrap.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{timetrap}
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Goldstein"]
12
- s.date = %q{2009-12-06}
12
+ s.date = %q{2009-12-20}
13
13
  s.default_executable = %q{t}
14
14
  s.description = %q{Command line time tracker}
15
15
  s.email = %q{sgrock@gmail.com}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Goldstein
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-06 00:00:00 -08:00
12
+ date: 2009-12-20 00:00:00 -08:00
13
13
  default_executable: t
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency