posto 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/posto/application.rb +37 -19
- data/lib/posto/file.rb +6 -2
- data/lib/posto.rb +2 -4
- metadata +5 -4
- data/test/application_test.rb +0 -54
data/lib/posto/application.rb
CHANGED
@@ -1,48 +1,66 @@
|
|
1
1
|
require 'posto/list'
|
2
|
+
require 'posto/file'
|
2
3
|
|
3
4
|
module Posto
|
4
5
|
class Application
|
5
|
-
def initialize(arguments
|
6
|
+
def initialize(arguments)
|
6
7
|
@arguments = arguments
|
7
|
-
@
|
8
|
-
@io =
|
9
|
-
|
10
|
-
|
11
|
-
def run(items)
|
12
|
-
send(@arguments.command, items, *@arguments.params)
|
8
|
+
@list_utility = List
|
9
|
+
@io = STDOUT
|
10
|
+
@file = Posto::File.new(@arguments.filename)
|
13
11
|
end
|
14
12
|
|
15
13
|
def list(items)
|
16
|
-
@io.puts items
|
17
14
|
items
|
18
15
|
end
|
19
16
|
|
20
|
-
def
|
21
|
-
|
17
|
+
def run(items)
|
18
|
+
@io.puts send(@arguments.command, items, *@arguments.params)
|
22
19
|
end
|
23
20
|
|
24
|
-
def
|
25
|
-
|
21
|
+
def sort(items)
|
22
|
+
@file.write @list_utility.sort(items)
|
26
23
|
end
|
27
24
|
|
28
25
|
def resort(items)
|
29
|
-
|
26
|
+
@file.write @list_utility.resort(items)
|
27
|
+
end
|
28
|
+
|
29
|
+
def unsort(items, n = 1)
|
30
|
+
@file.write @list_utility.unsort(items, n.to_i)
|
31
|
+
lookup_item(items, n)
|
30
32
|
end
|
31
33
|
|
32
34
|
def done(items, n = 1)
|
33
|
-
|
35
|
+
@file.write @list_utility.done(items, n.to_i)
|
36
|
+
lookup_item(items, n)
|
37
|
+
end
|
38
|
+
|
39
|
+
def top(items, n = nil)
|
40
|
+
if n.nil?
|
41
|
+
lookup_item(items, 1)
|
42
|
+
else
|
43
|
+
@file.write @list_utility.top(items, n.to_i)
|
44
|
+
lookup_item(items, n)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def quick(items, n = 1)
|
49
|
+
@file.write @list_utility.quick(items, n.to_i)
|
50
|
+
lookup_item(items, n)
|
34
51
|
end
|
35
52
|
|
36
53
|
def add(items, item)
|
37
|
-
|
54
|
+
@file.write @list_utility.add(items, item)
|
55
|
+
item
|
38
56
|
end
|
39
57
|
|
40
|
-
def
|
41
|
-
|
58
|
+
def commit(items)
|
59
|
+
@file.commit(done(items))
|
42
60
|
end
|
43
61
|
|
44
|
-
def
|
45
|
-
|
62
|
+
def lookup_item(items, n)
|
63
|
+
Posto::Item.hide_markdown(items[n.to_i - 1])
|
46
64
|
end
|
47
65
|
|
48
66
|
def method_missing(symbol, *args)
|
data/lib/posto/file.rb
CHANGED
@@ -7,8 +7,12 @@ module Posto
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def write(items)
|
10
|
-
|
11
|
-
|
10
|
+
IO.write(@filename, Template.todo_list(items))
|
11
|
+
end
|
12
|
+
|
13
|
+
def commit(msg)
|
14
|
+
`git add #{@filename}`
|
15
|
+
`git commit -m "#{msg}"`
|
12
16
|
end
|
13
17
|
|
14
18
|
def lines
|
data/lib/posto.rb
CHANGED
@@ -8,10 +8,8 @@ module Posto
|
|
8
8
|
class << self
|
9
9
|
def main(args)
|
10
10
|
arguments = Arguments.new(args)
|
11
|
-
|
12
|
-
|
13
|
-
result = Application.new(arguments).run(items)
|
14
|
-
file.write(result)
|
11
|
+
items = List.choose_item_lines(File.new(arguments.filename).lines)
|
12
|
+
Application.new(arguments).run(items)
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: posto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- test/item_test.rb
|
67
67
|
- test/arguments_test.rb
|
68
68
|
- test/test_helper.rb
|
69
|
-
- test/application_test.rb
|
70
69
|
- test/monkeypatch_array_test.rb
|
71
70
|
homepage: http://github.com/mattraibert/posto
|
72
71
|
licenses:
|
@@ -81,6 +80,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
80
|
- - ! '>='
|
82
81
|
- !ruby/object:Gem::Version
|
83
82
|
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: 3448850985226509015
|
84
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
87
|
none: false
|
86
88
|
requirements:
|
@@ -98,5 +100,4 @@ test_files:
|
|
98
100
|
- test/item_test.rb
|
99
101
|
- test/arguments_test.rb
|
100
102
|
- test/test_helper.rb
|
101
|
-
- test/application_test.rb
|
102
103
|
- test/monkeypatch_array_test.rb
|
data/test/application_test.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'posto/application'
|
3
|
-
require 'grasshopper'
|
4
|
-
require 'minitest/mock'
|
5
|
-
|
6
|
-
class ApplicationTest < MiniTest::Unit::TestCase
|
7
|
-
def test_default
|
8
|
-
array = []
|
9
|
-
result = Posto::Application.new(Stub.like(:command => "list", :params => []), Mock.new, Mock.new).run(array)
|
10
|
-
assert_same(array, result)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_sort
|
14
|
-
mock = Mock.new
|
15
|
-
Posto::Application.new(Stub.like(:command => "sort", :params => []), mock, Mock.new).run([])
|
16
|
-
Mock.verify(mock).sort([])
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_unsort
|
20
|
-
mock = Mock.new
|
21
|
-
Posto::Application.new(Stub.like(:command => "unsort", :params => ["4"]), mock, Mock.new).run([])
|
22
|
-
Mock.verify(mock).unsort([], 4)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_resort
|
26
|
-
mock = Mock.new
|
27
|
-
Posto::Application.new(Stub.like(:command => "resort", :params => []), mock, Mock.new).run([])
|
28
|
-
Mock.verify(mock).resort([])
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_done
|
32
|
-
mock = Mock.new
|
33
|
-
Posto::Application.new(Stub.like(:command => "done", :params => ["4"]), mock, Mock.new).run([])
|
34
|
-
Mock.verify(mock).done([], 4)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_add
|
38
|
-
mock = Mock.new
|
39
|
-
Posto::Application.new(Stub.like(:command => "add", :params => ["a brand new item"]), mock, Mock.new).run([])
|
40
|
-
Mock.verify(mock).add([], "a brand new item")
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_quick
|
44
|
-
mock = Mock.new
|
45
|
-
Posto::Application.new(Stub.like(:command => "quick", :params => ["4"]), mock, Mock.new).run([])
|
46
|
-
Mock.verify(mock).quick([], 4)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_top
|
50
|
-
mock = Mock.new
|
51
|
-
Posto::Application.new(Stub.like(:command => "top", :params => ["4"]), mock, Mock.new).run([])
|
52
|
-
Mock.verify(mock).top([], 4)
|
53
|
-
end
|
54
|
-
end
|