tpope-pickler 0.0.3 → 0.0.4
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/lib/pickler/runner.rb +99 -15
- data/lib/pickler/tracker/project.rb +1 -0
- data/lib/pickler/tracker/story.rb +5 -1
- data/pickler.gemspec +1 -1
- metadata +1 -1
data/lib/pickler/runner.rb
CHANGED
@@ -1,31 +1,115 @@
|
|
1
1
|
class Pickler
|
2
2
|
class Runner
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :argv
|
5
|
+
|
6
|
+
def pickler
|
7
|
+
@pickler ||= Pickler.new(Dir.getwd)
|
8
|
+
end
|
5
9
|
|
6
10
|
def initialize(argv)
|
7
11
|
@argv = argv
|
8
|
-
@
|
12
|
+
@tty = $stdout.tty?
|
13
|
+
end
|
14
|
+
|
15
|
+
COLORS = {
|
16
|
+
:black => 0,
|
17
|
+
:red => 1,
|
18
|
+
:green => 2,
|
19
|
+
:yellow => 3,
|
20
|
+
:blue => 4,
|
21
|
+
:magenta => 5,
|
22
|
+
:cyan => 6,
|
23
|
+
:white => 7
|
24
|
+
}
|
25
|
+
|
26
|
+
STATE_COLORS = {
|
27
|
+
nil => COLORS[:black],
|
28
|
+
"rejected" => COLORS[:red],
|
29
|
+
"accepted" => COLORS[:green],
|
30
|
+
"delivered" => COLORS[:yellow],
|
31
|
+
"unscheduled" => COLORS[:white],
|
32
|
+
"started" => COLORS[:magenta],
|
33
|
+
"finished" => COLORS[:cyan],
|
34
|
+
"unstarted" => COLORS[:blue]
|
35
|
+
}
|
36
|
+
|
37
|
+
STATE_SYMBOLS = {
|
38
|
+
"unscheduled" => " ",
|
39
|
+
"unstarted" => ":|",
|
40
|
+
"started" => ":/",
|
41
|
+
"finished" => ":)",
|
42
|
+
"delivered" => ";)",
|
43
|
+
"rejected" => ":(",
|
44
|
+
"accepted" => ":D"
|
45
|
+
}
|
46
|
+
|
47
|
+
TYPE_COLORS = {
|
48
|
+
'chore' => COLORS[:blue],
|
49
|
+
'feature' => COLORS[:magenta],
|
50
|
+
'bug' => COLORS[:red],
|
51
|
+
'release' => COLORS[:cyan]
|
52
|
+
}
|
53
|
+
|
54
|
+
TYPE_SYMBOLS = {
|
55
|
+
"feature" => "*",
|
56
|
+
"chore" => "%",
|
57
|
+
"release" => "!",
|
58
|
+
"bug" => "/"
|
59
|
+
}
|
60
|
+
|
61
|
+
def color?
|
62
|
+
case pickler.config["color"]
|
63
|
+
when "always" then true
|
64
|
+
when "never" then false
|
65
|
+
else
|
66
|
+
@tty && RUBY_PLATFORM !~ /mswin|mingw/
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def puts_summary(story)
|
71
|
+
summary = "%6d " % story.id
|
72
|
+
type = story.estimate || TYPE_SYMBOLS[story.story_type]
|
73
|
+
state = STATE_SYMBOLS[story.current_state]
|
74
|
+
if color?
|
75
|
+
summary << "\e[3#{STATE_COLORS[story.current_state]}m#{state}\e[00m "
|
76
|
+
summary << "\e[01;3#{TYPE_COLORS[story.story_type]}m#{type}\e[00m "
|
77
|
+
else
|
78
|
+
summary << "#{state} #{type} "
|
79
|
+
end
|
80
|
+
summary << story.name
|
81
|
+
puts summary
|
82
|
+
end
|
83
|
+
|
84
|
+
def paginated_output
|
85
|
+
stdout = $stdout
|
86
|
+
if @tty && pager = pickler.config["pager"]
|
87
|
+
# Modeled after git
|
88
|
+
ENV["LESS"] ||= "FRSX"
|
89
|
+
IO.popen(pager,"w") do |io|
|
90
|
+
$stdout = io
|
91
|
+
yield
|
92
|
+
end
|
93
|
+
else
|
94
|
+
yield
|
95
|
+
end
|
96
|
+
ensure
|
97
|
+
$stdout = stdout
|
9
98
|
end
|
10
99
|
|
11
100
|
def run
|
12
101
|
case first = argv.shift
|
13
102
|
when 'show', /^\d+$/
|
14
103
|
story = pickler.project.story(first == 'show' ? argv.shift : first)
|
15
|
-
|
104
|
+
paginated_output do
|
105
|
+
puts story
|
106
|
+
end
|
16
107
|
when 'search'
|
17
|
-
stories = pickler.project.stories(*argv)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
next unless stories[state]
|
23
|
-
puts unless first
|
24
|
-
first = false
|
25
|
-
puts state.upcase
|
26
|
-
puts '-' * state.length
|
27
|
-
stories[state].each do |story|
|
28
|
-
puts "[#{story.id}] #{story.story_type.capitalize}: #{story.name}"
|
108
|
+
stories = pickler.project.stories(*argv)
|
109
|
+
stories.reject! {|s| %w(unscheduled unstarted accepted).include?(s.current_state)} if argv.empty?
|
110
|
+
paginated_output do
|
111
|
+
stories.each do |story|
|
112
|
+
puts_summary story
|
29
113
|
end
|
30
114
|
end
|
31
115
|
when 'push'
|
@@ -8,7 +8,7 @@ class Pickler
|
|
8
8
|
attr_reader :project, :iteration
|
9
9
|
reader :url, :labels
|
10
10
|
date_reader :created_at, :accepted_at, :deadline
|
11
|
-
accessor :current_state, :name, :description, :
|
11
|
+
accessor :current_state, :name, :description, :owned_by, :requested_by, :story_type
|
12
12
|
|
13
13
|
def initialize(project, attributes = {})
|
14
14
|
@project = project
|
@@ -78,6 +78,10 @@ class Pickler
|
|
78
78
|
[@attributes["notes"]].flatten.compact.map {|n| Note.new(self,n)}
|
79
79
|
end
|
80
80
|
|
81
|
+
def estimate
|
82
|
+
@attributes["estimate"].to_i < 0 ? nil : @attributes["estimate"]
|
83
|
+
end
|
84
|
+
|
81
85
|
def comment!(body)
|
82
86
|
raise ArgumentError if body.strip.empty? || body.size > 5000
|
83
87
|
response = tracker.request_xml(:post, "#{resource_url}/notes",{:text => body}.to_xml(:root => 'note'))
|
data/pickler.gemspec
CHANGED