nofxx-pickler 0.0.10 → 0.1.0
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/README.rdoc +8 -0
- data/lib/pickler/runner.rb +50 -16
- data/lib/pickler.rb +74 -0
- data/pickler.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -58,6 +58,14 @@ Push a given feature and change its state to finished.
|
|
58
58
|
|
59
59
|
List all stories assigned to your username.
|
60
60
|
|
61
|
+
pickler open bug Something
|
62
|
+
|
63
|
+
Opens a bug with "Something" as title.
|
64
|
+
|
65
|
+
pickler bug Something
|
66
|
+
|
67
|
+
Same. Try "chore" too.
|
68
|
+
|
61
69
|
pickler --help
|
62
70
|
|
63
71
|
Full list of commands.
|
data/lib/pickler/runner.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'optparse'
|
2
3
|
|
3
4
|
class Pickler
|
4
5
|
class Runner
|
5
|
-
|
6
6
|
class Base
|
7
|
+
include Editor
|
7
8
|
attr_reader :argv
|
8
9
|
|
9
10
|
def initialize(argv)
|
@@ -127,10 +128,8 @@ class Pickler
|
|
127
128
|
end
|
128
129
|
|
129
130
|
def puts_summary(story)
|
130
|
-
summary = "%6d
|
131
|
+
summary = "%6d " % story.id
|
131
132
|
type = story.estimate || TYPE_SYMBOLS[story.story_type]
|
132
|
-
state = STATE_SYMBOLS[story.current_state]
|
133
|
-
summary << colorize("3#{STATE_COLORS[story.current_state]}", state) << ' '
|
134
133
|
summary << colorize("01;3#{TYPE_COLORS[story.story_type]}", type) << ' '
|
135
134
|
summary << story.name
|
136
135
|
puts " " + summary
|
@@ -281,7 +280,8 @@ class Pickler
|
|
281
280
|
paginated_output do
|
282
281
|
first = true
|
283
282
|
stories.group_by(&:current_state).each do |state, state_stories|
|
284
|
-
|
283
|
+
state_icon = STATE_SYMBOLS[state]
|
284
|
+
print colorize("01;3#{STATE_COLORS[state]}", "= #{state.capitalize} #{state_icon}")
|
285
285
|
sum = state_stories.sum {|s| s.estimate || 0 }
|
286
286
|
len = state_stories.length
|
287
287
|
puts colorize("01;30", " (#{sum} points, #{len} #{len > 1 ? 'stories' : 'story' })")
|
@@ -294,6 +294,7 @@ class Pickler
|
|
294
294
|
end
|
295
295
|
first = false
|
296
296
|
end
|
297
|
+
puts
|
297
298
|
end
|
298
299
|
end
|
299
300
|
end
|
@@ -453,7 +454,40 @@ Requires launchy (gem install launchy).
|
|
453
454
|
end
|
454
455
|
end
|
455
456
|
|
456
|
-
|
457
|
+
command :open do
|
458
|
+
banner_arguments "<type> <story> <paragraph> ..."
|
459
|
+
summary "Create a new story"
|
460
|
+
|
461
|
+
process do |type, title, *paragraphs|
|
462
|
+
st = Pickler::Tracker::Story.new(pickler.project)
|
463
|
+
st.story_type = type
|
464
|
+
st.name = title
|
465
|
+
st.description = paragraphs.join("\n")
|
466
|
+
puts st.save ? "#{type.capitalize} created." : "Problems..."
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
command :bug do
|
471
|
+
banner_arguments "<story> <paragraph> ..."
|
472
|
+
summary "Create a new bug"
|
473
|
+
|
474
|
+
process do |*paragraphs|
|
475
|
+
title, paragraphs = gets_from_editor unless title = paragraphs.delete_at(0)
|
476
|
+
Pickler.run ["open", "bug", title, *paragraphs]
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
command :chore do
|
481
|
+
banner_arguments "<story> <paragraph> ..."
|
482
|
+
summary "Create a new chore"
|
483
|
+
|
484
|
+
process do |*paragraphs|
|
485
|
+
title, paragraphs = gets_from_editor unless title = paragraphs.delete_at(0)
|
486
|
+
Pickler.run ["open", "chore", title, *paragraphs]
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
command :started do
|
457
491
|
summary "Started stories."
|
458
492
|
description <<-EOF
|
459
493
|
Show only started stories.
|
@@ -501,13 +535,13 @@ on ~/.tracker.yml.
|
|
501
535
|
}
|
502
536
|
|
503
537
|
STATE_SYMBOLS = {
|
504
|
-
"unscheduled" => "
|
505
|
-
"unstarted" => "
|
506
|
-
"started" => "
|
507
|
-
"finished" => "
|
508
|
-
"delivered" => "
|
509
|
-
"rejected" => "
|
510
|
-
"accepted" => "
|
538
|
+
"unscheduled" => "..",
|
539
|
+
"unstarted" => "=|",
|
540
|
+
"started" => "=/",
|
541
|
+
"finished" => "=)",
|
542
|
+
"delivered" => "=D",
|
543
|
+
"rejected" => "=(",
|
544
|
+
"accepted" => "xD"
|
511
545
|
}
|
512
546
|
|
513
547
|
TYPE_COLORS = {
|
@@ -519,9 +553,9 @@ on ~/.tracker.yml.
|
|
519
553
|
|
520
554
|
TYPE_SYMBOLS = {
|
521
555
|
"feature" => "*",
|
522
|
-
"chore" => "
|
523
|
-
"release" => "
|
524
|
-
"bug" => "
|
556
|
+
"chore" => "Ø",
|
557
|
+
"release" => "√",
|
558
|
+
"bug" => "¤"
|
525
559
|
}
|
526
560
|
|
527
561
|
def run
|
data/lib/pickler.rb
CHANGED
@@ -134,6 +134,80 @@ class Pickler
|
|
134
134
|
feature(string).story
|
135
135
|
end
|
136
136
|
|
137
|
+
#
|
138
|
+
# Stolen from GHI - git://github.com/stephencelis/ghi.git
|
139
|
+
|
140
|
+
module Editor
|
141
|
+
def launch_editor(file)
|
142
|
+
system "#{editor} #{file.path}"
|
143
|
+
end
|
144
|
+
|
145
|
+
def gets_from_editor
|
146
|
+
if windows?
|
147
|
+
warn "Windows fail => Please supply the message appended on the command"
|
148
|
+
exit 1
|
149
|
+
end
|
150
|
+
File.open message_path, "a+", &file_proc("feature")
|
151
|
+
return @message.shift.strip, @message.join.sub(/\b\n\b/, " ").strip
|
152
|
+
end
|
153
|
+
|
154
|
+
def delete_message
|
155
|
+
File.delete message_path
|
156
|
+
rescue Errno::ENOENT, TypeError
|
157
|
+
nil
|
158
|
+
end
|
159
|
+
|
160
|
+
def message_path
|
161
|
+
File.join curr_dir, message_filename
|
162
|
+
end
|
163
|
+
def edit_format(issue)
|
164
|
+
l = []
|
165
|
+
l << ""
|
166
|
+
l << ""
|
167
|
+
l << "# The first line will be the 'title', subsequent ones 'description'."
|
168
|
+
l << "# Lines beginning '#' will be ignored and empty messages discarded."
|
169
|
+
end
|
170
|
+
private
|
171
|
+
|
172
|
+
def editor
|
173
|
+
ENV["GHI_EDITOR"] || ENV["VISUAL"] || ENV["EDITOR"] || "vi"
|
174
|
+
end
|
175
|
+
|
176
|
+
def curr_dir
|
177
|
+
@curr_dir ||= `git rev-parse --git-dir 2>/dev/null`.chomp
|
178
|
+
end
|
179
|
+
|
180
|
+
def message_filename
|
181
|
+
@message_filename ||= "PICKLER_#{Time.now.to_i}_MESSAGE"
|
182
|
+
end
|
183
|
+
|
184
|
+
def file_proc(issue)
|
185
|
+
lambda do |file|
|
186
|
+
file << edit_format(issue).join("\n") if File.zero? file.path
|
187
|
+
file.rewind
|
188
|
+
launch_editor file
|
189
|
+
@message = File.readlines(file.path).find_all { |l| !l.match(/^#/) }
|
190
|
+
|
191
|
+
if @message.to_s =~ /\A\s*\Z/
|
192
|
+
raise Pickler::Error, "Aborted."
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
private
|
198
|
+
|
199
|
+
def puts(*args)
|
200
|
+
rescue NoMethodError
|
201
|
+
# Do nothing.
|
202
|
+
ensure
|
203
|
+
$stdout.puts(*args)
|
204
|
+
end
|
205
|
+
|
206
|
+
def windows?
|
207
|
+
RUBY_PLATFORM.include?("mswin")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
137
211
|
protected
|
138
212
|
|
139
213
|
end
|
data/pickler.gemspec
CHANGED