slimtimercli 0.1.1 → 0.1.2

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/History.txt CHANGED
@@ -1,4 +1,10 @@
1
+ == 0.1.2 2008-04-06
2
+ * time recording can only be stopped if a task was started
3
+ * time recording can only be started if no other task was started
4
+
1
5
  == 0.1.1 2008-04-03
2
6
 
3
7
  * Initial Release of the gem
4
8
  * started adding tests
9
+
10
+
@@ -2,7 +2,7 @@ module Slimtimercli #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/slimtimercli.rb CHANGED
@@ -176,12 +176,23 @@ To show all your tasks available.
176
176
  HELP
177
177
  end
178
178
 
179
- def self.start
179
+ def self.start
180
+ if ARGV.empty?
181
+ puts "Need to specify a task as argument"
182
+ return false
183
+ end
184
+
185
+ if File.exists?(Helper::current_file)
186
+ puts "Need to stop the other task first"
187
+ return false
188
+ end
189
+
180
190
  info = {"task" => ARGV[1],
181
191
  "start_time" => Time.now}
182
192
 
183
193
  # dum curent task to file
184
194
  Helper::dump_to_file(info, "current.yml")
195
+ return true
185
196
  end
186
197
 
187
198
  def self.end
@@ -189,7 +200,7 @@ HELP
189
200
  info = Helper::load_file("current.yml")
190
201
  rescue
191
202
  puts "You must start a task before you finish it"
192
- return
203
+ return false
193
204
  end
194
205
 
195
206
 
@@ -209,7 +220,7 @@ HELP
209
220
 
210
221
  # Output
211
222
  puts "Wrote new Entry for #{t.name}, duration #{result["duration_in_seconds"] / 60}m"
212
-
223
+ return true
213
224
  end
214
225
 
215
226
  end
@@ -5,18 +5,18 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
5
5
  describe "SlimTimer" do
6
6
 
7
7
  describe "Helper" do
8
-
8
+
9
9
  it "should return the path to the config files" do
10
10
  Slimtimercli::Helper::config_file.should =~ /.slimtimer\/config.yml/
11
11
  Slimtimercli::Helper::tasks_file.should =~ /.slimtimer\/tasks.yml/
12
- end
13
-
12
+ end
13
+
14
14
  end
15
-
15
+
16
16
  describe "Entities" do
17
-
17
+
18
18
  describe "User" do
19
-
19
+
20
20
  it "should initialize correctly" do
21
21
  u = User.new("a", "b")
22
22
  u.email.should == "a"
@@ -29,22 +29,66 @@ describe "SlimTimer" do
29
29
  u.user_id.should == "b"
30
30
  u.name.should == "c"
31
31
  end
32
-
32
+
33
33
  it "should serialize correctly" do
34
34
  u = User.new("a", "b")
35
35
  u.user_id = 10
36
36
  r = u._serialize
37
-
37
+
38
38
  r.has_key?("user").should be_true
39
39
  r["user"]["email"].should == "a"
40
40
  r["user"]["password"].should == "b"
41
41
  r["user"].has_key?("user_id").should be_false
42
-
43
- end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ describe "command line interface" do
50
+
51
+ before do
52
+ Slimtimercli::Helper.stub!(:root).and_return(File.dirname(__FILE__))
53
+
54
+ @c = File.join(File.dirname(__FILE__), "current.yml")
55
+ FileUtils.rm(@c) if File.exists?(@c)
56
+
57
+ @d = File.join(File.dirname(__FILE__), "config.yml")
58
+ FileUtils.rm(@d) if File.exists?(@d)
59
+ end
60
+
61
+ it "should start a task" do
62
+
63
+ # Manipulate ARGV
64
+ Slimtimercli.start
65
+ File.exists?(@c).should be_false
66
+
67
+ # Set a task
68
+ ARGV[1] = "test"
69
+ Slimtimercli.start
70
+ File.exists?(@c).should be_true
71
+
72
+ # no double start
73
+ Slimtimercli.start.should be_false
44
74
 
75
+
76
+ end
77
+
78
+ it "should stop a task" do
79
+ Slimtimercli.stub!(:tasks).and_return(stub("task", :find => stub("task", :name => "test")))
80
+ Slimtimercli::Helper.stub!(:login).
81
+ and_return(stub("slimtimer", :create_time_entry => {"duration_in_seconds" => 10}))
82
+
83
+ ARGV[1] = "test"
84
+ Slimtimercli.start.should be_true
85
+ Slimtimercli.end.should be_true
86
+ end
87
+
88
+ it "should not stop a task if none is running" do
89
+ Slimtimercli.end.should be_false
45
90
  end
46
91
 
47
92
  end
48
-
49
-
93
+
50
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimtimercli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Grund
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-03 00:00:00 +02:00
12
+ date: 2008-04-06 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15