achoo 0.4.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES +13 -0
  2. data/README.rdoc +26 -22
  3. data/lib/achoo/achievo/hour_administration_form.rb +2 -3
  4. data/lib/achoo/achievo/hour_registration_form.rb +12 -15
  5. data/lib/achoo/achievo/hour_registration_form_ranged.rb +5 -2
  6. data/lib/achoo/achievo/lock_month_form.rb +1 -5
  7. data/lib/achoo/achievo/login_form.rb +3 -3
  8. data/lib/achoo/app.rb +27 -28
  9. data/lib/achoo/awake.rb +1 -1
  10. data/lib/achoo/extensions.rb +4 -0
  11. data/lib/achoo/ical.rb +6 -2
  12. data/lib/achoo/plugin/awake.rb +23 -0
  13. data/lib/achoo/plugin/ical.rb +47 -0
  14. data/lib/achoo/plugin/vcs.rb +26 -0
  15. data/lib/achoo/plugin_base.rb +6 -0
  16. data/lib/achoo/rc_loader.rb +9 -0
  17. data/lib/achoo/temporal/timespan.rb +3 -3
  18. data/lib/achoo/term.rb +7 -3
  19. data/lib/achoo/term/table.rb +5 -6
  20. data/lib/achoo/ui/commands.rb +12 -12
  21. data/lib/achoo/ui/date_chooser.rb +1 -1
  22. data/lib/achoo/ui/exception_handling.rb +1 -1
  23. data/lib/achoo/ui/register_hours.rb +50 -50
  24. data/lib/achoo/vcs/git.rb +5 -3
  25. data/test/acceptance/test_flexi_time.rb +41 -0
  26. data/test/acceptance/test_lock_month.rb +39 -0
  27. data/test/acceptance/test_register_hours.rb +161 -0
  28. data/test/lib/achievo_mock.rb +76 -0
  29. data/test/lib/achoo_runner.rb +54 -0
  30. data/test/lib/test_helpers.rb +43 -0
  31. data/test/unit/test_achievo_date_field.rb +34 -0
  32. data/test/unit/test_awake.rb +98 -0
  33. data/test/unit/test_extensions_array.rb +25 -0
  34. data/test/unit/test_system_cstruct.rb +28 -0
  35. data/test/unit/test_system_log_entry.rb +31 -0
  36. data/test/unit/test_term_menu.rb +71 -0
  37. data/test/unit/test_term_table.rb +52 -0
  38. data/test/unit/test_timespan.rb +48 -0
  39. data/test/unit/test_ui_date_chooser.rb +36 -0
  40. metadata +101 -74
@@ -0,0 +1,25 @@
1
+ require 'achoo/extensions'
2
+ require 'test_helpers'
3
+
4
+ class TestExtensionsArray < Test::Unit::TestCase
5
+
6
+ context 'merge!' do
7
+ setup do
8
+ @expected = (1..8).to_a
9
+ end
10
+
11
+ should 'merge two sorted arrays with interleaving values' do
12
+ assert_equal @expected, [1,3,5,7].merge!([2,4,6,8])
13
+ end
14
+
15
+ should 'merge two sorted arrays where A > B' do
16
+ assert_equal @expected, (1..4).to_a.merge!((5..8).to_a)
17
+ end
18
+
19
+ should 'merge two sorted arrays where A < B' do
20
+ assert_equal @expected, (5..8).to_a.merge!((1..4).to_a)
21
+ end
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,28 @@
1
+ require 'achoo/system'
2
+ require 'test_helpers'
3
+
4
+ class TestSystemCStruct < Test::Unit::TestCase
5
+ # def setup
6
+ # end
7
+
8
+ # def teardown
9
+ # end
10
+
11
+ class TestStruct < Achoo::System::CStruct
12
+ long :a
13
+ string :b, 2
14
+ end
15
+
16
+ def test_cstruct
17
+ ts = TestStruct.new
18
+ ts.a = 1
19
+ ts.b = "hi"
20
+
21
+ ts2 = TestStruct.new(ts.pack)
22
+
23
+ assert_equal(ts.a, ts2.a)
24
+ assert_equal(ts.b, ts2.b)
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,31 @@
1
+ require 'achoo/system'
2
+ require 'test_helpers'
3
+
4
+ class TestSystemLogEntry < Test::Unit::TestCase
5
+
6
+ context 'Comparison' do
7
+
8
+ setup do
9
+ @a = Achoo::System::LogEntry.new(1, :foo)
10
+ @b = Achoo::System::LogEntry.new(1, :bar)
11
+ @c = Achoo::System::LogEntry.new(2, :baz)
12
+ end
13
+
14
+ should 'eq' do
15
+ assert(@a == @b)
16
+ assert(!(@a == @c))
17
+ end
18
+
19
+ should 'lt' do
20
+ assert(@a < @c)
21
+ assert(!(@c < @a))
22
+ end
23
+
24
+ should 'le' do
25
+ assert(@a <= @b)
26
+ assert(@a <= @c)
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,71 @@
1
+ require 'achoo'
2
+ require 'achoo/term/menu'
3
+ require 'test_helpers'
4
+
5
+ class Achoo::Term
6
+ def self.ask(x); return "1"; end
7
+ end
8
+
9
+ class TestTermMenu < Test::Unit::TestCase
10
+ # def setup
11
+ # end
12
+
13
+ # def teardown
14
+ # end
15
+
16
+ context '#print_ask_and_validate' do
17
+ should 'simple case' do
18
+ menu = Achoo::Term::Menu.new('', %w(a b c))
19
+ $stdout = StringIO.new
20
+ answer = menu.print_ask_and_validate
21
+ expected_menu = <<'EOT'
22
+ 1. a
23
+ 2. b
24
+ 3. c
25
+ EOT
26
+ res = $stdout.string
27
+ $stdout = STDOUT
28
+ assert_equal expected_menu, res
29
+ assert_equal "1", answer
30
+ end
31
+
32
+ should 'empty menu' do
33
+ menu = Achoo::Term::Menu.new('', %w())
34
+ $stdout = StringIO.new
35
+ answer = menu.print_ask_and_validate
36
+ expected_menu = ''
37
+ res = $stdout.string
38
+ $stdout = STDOUT
39
+ assert_equal expected_menu, res
40
+ assert answer.nil?
41
+ end
42
+
43
+ should 'lots of options right justified_enumeration' do
44
+ menu = Achoo::Term::Menu.new('', %w(a b c d e f g h i j k l), 'spec')
45
+ $stdout = StringIO.new
46
+ answer = menu.print_ask_and_validate
47
+ expected_menu = <<'EOT'
48
+ 1. a
49
+ 2. b
50
+ 3. c
51
+ 4. d
52
+ 5. e
53
+ 6. f
54
+ 7. g
55
+ 8. h
56
+ 9. i
57
+ 10. j
58
+ 11. k
59
+ 12. l
60
+ 0. spec
61
+ EOT
62
+ res = $stdout.string
63
+ $stdout = STDOUT
64
+ assert_equal expected_menu, res
65
+ assert_equal "1", answer
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
@@ -0,0 +1,52 @@
1
+ require 'achoo/term/table'
2
+ require 'test_helpers'
3
+
4
+ class TestTermTable < Test::Unit::TestCase
5
+ # def setup
6
+ # end
7
+
8
+ # def teardown
9
+ # end
10
+
11
+ def test_data_and_header
12
+ table = Achoo::Term::Table.new(%w(a b), [%w(1 2)])
13
+ io = StringIO.new
14
+ table.print(io)
15
+ expected = <<'EOT'
16
+ ┌───┬───┐
17
+ │ a │ b │
18
+ ├───┼───┤
19
+ │ 1 │ 2 │
20
+ └───┴───┘
21
+ EOT
22
+ assert_equal expected, io.string
23
+ end
24
+
25
+ def test_no_data
26
+ table = Achoo::Term::Table.new(%w(a b), [])
27
+ io = StringIO.new
28
+ table.print(io)
29
+ expected = <<'EOT'
30
+ ┌───┬───┐
31
+ │ a │ b │
32
+ ├───┼───┤
33
+ └───┴───┘
34
+ EOT
35
+ assert_equal expected, io.string
36
+ end
37
+
38
+ def test_empty
39
+ table = Achoo::Term::Table.new([], [])
40
+ io = StringIO.new
41
+ table.print(io)
42
+ expected = <<'EOT'
43
+ ┌┐
44
+ │ │
45
+ ├┤
46
+ └┘
47
+ EOT
48
+ assert_equal expected, io.string
49
+ end
50
+
51
+ end
52
+
@@ -0,0 +1,48 @@
1
+ require 'achoo/temporal'
2
+ require 'test_helpers'
3
+
4
+ class TestTimespan < Test::Unit::TestCase
5
+
6
+ context 'Contains with timeish argument' do
7
+ setup do
8
+ @ts = Achoo::Temporal::Timespan.new('1970-01-01', '1970-01-02')
9
+ end
10
+
11
+ should "contain it's start" do
12
+ assert(@ts.contains?('1970-01-01'))
13
+ end
14
+
15
+ should "contain it's end" do
16
+ assert(@ts.contains?('1970-01-02'))
17
+ end
18
+
19
+ should "contain an intervening time" do
20
+ assert(@ts.contains?('1970-01-01 23:30'))
21
+ end
22
+
23
+ should "not contain a time after end time" do
24
+ assert(!@ts.contains?('1970-01-03'))
25
+ end
26
+ end
27
+
28
+ context 'Contains with timespan argument' do
29
+ setup do
30
+ @ts = Achoo::Temporal::Timespan.new('1970-01-01', '1970-01-02')
31
+ end
32
+
33
+ should 'contain self' do
34
+ assert(@ts.contains?(@ts))
35
+ end
36
+
37
+ should 'contain intervening timespan' do
38
+ assert(@ts.contains?(Achoo::Temporal::Timespan.new('1970-01-01 06:00',
39
+ '1970-01-01 09:00 ')))
40
+ end
41
+
42
+ should 'not contain timespan with end after end time' do
43
+ assert(!@ts.contains?(Achoo::Temporal::Timespan.new('1970-01-01 06:00',
44
+ '1970-01-02 09:00 ')))
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,36 @@
1
+ require 'achoo/ui/date_chooser'
2
+ require 'date'
3
+ require 'test_helpers'
4
+
5
+ class TestUIDateChooser < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @x = Achoo::UI::DateChooser.new
9
+ @today = Date.today
10
+ end
11
+
12
+ # def teardown
13
+ # end
14
+
15
+ def test_relative_negative
16
+ assert_equal @today-1, @x.parse_date('-1')
17
+ end
18
+
19
+ def test_relative_positive
20
+ assert_equal @today+1, @x.parse_date('+1')
21
+ end
22
+
23
+ def test_absolute_notation
24
+ assert_equal @today, @x.parse_date(@today.day.to_s)
25
+ assert_equal @today, @x.parse_date("#{@today.month}-#{@today.day}")
26
+ assert_equal @today, @x.parse_date("#{@today.year}-#{@today.month}-#{@today.day}")
27
+ end
28
+
29
+ def test_simplified_absolute_notation
30
+ assert_equal Date.civil(2010, 1, 1), @x.parse_date('2010-1-1')
31
+ assert_equal Date.civil(2010, 1, 1), @x.parse_date('2010-01-01')
32
+ assert_equal Date.civil(2010, 1, 1), @x.parse_date('10-1-1')
33
+ end
34
+
35
+ end
36
+
metadata CHANGED
@@ -1,122 +1,149 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: achoo
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.2
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.5'
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
- - "Kjell-Magne \xC3\x98ierud"
7
+ authors:
8
+ - Kjell-Magne Øierud
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2010-05-11 00:00:00 +02:00
12
+ date: 2011-06-11 00:00:00.000000000 +02:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: mechanize
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
17
+ requirement: &82174030 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
23
22
  version: 1.0.0
24
- version:
25
- - !ruby/object:Gem::Dependency
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *82174030
26
+ - !ruby/object:Gem::Dependency
27
+ name: plugman
28
+ requirement: &82173670 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *82173670
37
+ - !ruby/object:Gem::Dependency
26
38
  name: ri_cal
39
+ requirement: &82173430 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
27
45
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
46
+ prerelease: false
47
+ version_requirements: *82173430
35
48
  description: Command line interface for Achievo (http://achievo.org)
36
49
  email: kjellm@acm.org
37
- executables:
50
+ executables:
38
51
  - achoo
39
52
  - awake
40
53
  - vcs_commits
41
54
  - ical
42
55
  extensions: []
43
-
44
56
  extra_rdoc_files: []
45
-
46
- files:
47
- - bin/awake
48
- - bin/ical
57
+ files:
49
58
  - bin/achoo
59
+ - bin/ical
60
+ - bin/awake
50
61
  - bin/vcs_commits
51
- - lib/achoo.rb
62
+ - lib/achoo/temporal/timespan.rb
63
+ - lib/achoo/temporal/open_timespan.rb
64
+ - lib/achoo/vcs/subversion.rb
65
+ - lib/achoo/vcs/git.rb
66
+ - lib/achoo/term.rb
67
+ - lib/achoo/system.rb
68
+ - lib/achoo/plugin_base.rb
52
69
  - lib/achoo/vcs.rb
53
- - lib/achoo/ui/month_chooser.rb
54
- - lib/achoo/ui/common.rb
70
+ - lib/achoo/ui/register_hours.rb
71
+ - lib/achoo/ui/optionally_ranged_date_chooser.rb
55
72
  - lib/achoo/ui/commands.rb
56
- - lib/achoo/ui/date_chooser.rb
73
+ - lib/achoo/ui/common.rb
74
+ - lib/achoo/ui/month_chooser.rb
57
75
  - lib/achoo/ui/exception_handling.rb
58
- - lib/achoo/ui/optionally_ranged_date_chooser.rb
76
+ - lib/achoo/ui/date_chooser.rb
59
77
  - lib/achoo/ui/date_choosers.rb
60
- - lib/achoo/ui/register_hours.rb
61
- - lib/achoo/achievo/lock_month_form.rb
62
- - lib/achoo/achievo/login_form.rb
63
- - lib/achoo/achievo/hour_registration_form.rb
78
+ - lib/achoo/achievo.rb
79
+ - lib/achoo/temporal.rb
64
80
  - lib/achoo/achievo/hour_administration_form.rb
65
81
  - lib/achoo/achievo/hour_registration_form_ranged.rb
66
82
  - lib/achoo/achievo/date_field.rb
83
+ - lib/achoo/achievo/hour_registration_form.rb
67
84
  - lib/achoo/achievo/table.rb
68
- - lib/achoo/system.rb
69
- - lib/achoo/system/log_entry.rb
85
+ - lib/achoo/achievo/lock_month_form.rb
86
+ - lib/achoo/achievo/login_form.rb
87
+ - lib/achoo/rc_loader.rb
88
+ - lib/achoo/awake.rb
89
+ - lib/achoo/ical.rb
90
+ - lib/achoo/plugin/vcs.rb
91
+ - lib/achoo/plugin/awake.rb
92
+ - lib/achoo/plugin/ical.rb
93
+ - lib/achoo/extensions.rb
94
+ - lib/achoo/app.rb
95
+ - lib/achoo/ui.rb
96
+ - lib/achoo/term/table.rb
97
+ - lib/achoo/term/menu.rb
70
98
  - lib/achoo/system/wtmp.rb
71
99
  - lib/achoo/system/utmp_record.rb
100
+ - lib/achoo/system/log_entry.rb
72
101
  - lib/achoo/system/pm_suspend.rb
73
102
  - lib/achoo/system/cstruct.rb
74
- - lib/achoo/vcs/subversion.rb
75
- - lib/achoo/vcs/git.rb
76
- - lib/achoo/awake.rb
77
- - lib/achoo/term.rb
78
- - lib/achoo/app.rb
79
- - lib/achoo/term/menu.rb
80
- - lib/achoo/term/table.rb
81
- - lib/achoo/extensions.rb
82
- - lib/achoo/temporal/open_timespan.rb
83
- - lib/achoo/temporal/timespan.rb
84
- - lib/achoo/achievo.rb
85
- - lib/achoo/temporal.rb
86
- - lib/achoo/rc_loader.rb
87
- - lib/achoo/ui.rb
88
- - lib/achoo/ical.rb
103
+ - lib/achoo.rb
104
+ - test/acceptance/test_register_hours.rb
105
+ - test/acceptance/test_lock_month.rb
106
+ - test/acceptance/test_flexi_time.rb
107
+ - test/unit/test_term_table.rb
108
+ - test/unit/test_term_menu.rb
109
+ - test/unit/test_ui_date_chooser.rb
110
+ - test/unit/test_achievo_date_field.rb
111
+ - test/unit/test_extensions_array.rb
112
+ - test/unit/test_timespan.rb
113
+ - test/unit/test_awake.rb
114
+ - test/unit/test_system_log_entry.rb
115
+ - test/unit/test_system_cstruct.rb
116
+ - test/lib/achievo_mock.rb
117
+ - test/lib/achoo_runner.rb
118
+ - test/lib/test_helpers.rb
89
119
  - Rakefile
90
120
  - README.rdoc
91
121
  - CHANGES
92
122
  - COPYING
93
123
  has_rdoc: true
94
- homepage: http://github.com/kjellm/achoo/
124
+ homepage: http://kjellm.github.com/achoo/
95
125
  licenses: []
96
-
97
126
  post_install_message:
98
127
  rdoc_options: []
99
-
100
- require_paths:
128
+ require_paths:
101
129
  - lib
102
- required_ruby_version: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
106
135
  version: 1.8.1
107
- version:
108
- required_rubygems_version: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
113
- version:
114
- requirements:
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements:
115
143
  - none
116
144
  rubyforge_project:
117
- rubygems_version: 1.3.5
145
+ rubygems_version: 1.6.2
118
146
  signing_key:
119
147
  specification_version: 3
120
148
  summary: Achievo CLI.
121
149
  test_files: []
122
-