starter 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/starter/tasks/github.rb +34 -4
  2. metadata +2 -2
@@ -1,7 +1,7 @@
1
1
  require "starter/tasks/starter"
2
2
 
3
3
  desc "Create an issue on GitHub"
4
- task "github:issue" => "github_repo" do
4
+ task "github:issues:create" => "github_repo" do
5
5
 
6
6
  repo = $STARTER[:github_repo]
7
7
  labels = repo.labels.map { |label| label["name"] }.join(" ")
@@ -45,11 +45,41 @@ task "github:issue" => "github_repo" do
45
45
  end
46
46
  end
47
47
 
48
+
49
+ def format_issue(issue, format="plain")
50
+ if issue["assignee"]
51
+ login = issue["assignee"]["login"]
52
+ else
53
+ login = nil
54
+ end
55
+ case format
56
+ when "markdown"
57
+ "* #{login || "<unassigned>"} - [#{issue.number}](#{issue.html_url}) - #{issue.title}"
58
+ when "plain"
59
+ "* %-16s - %-4s - %s" % [login, "##{issue.number}", issue.title]
60
+ else
61
+ raise "Unknown format for issue printing: '#{format}'"
62
+ end
63
+ end
64
+
65
+ desc "show GitHub issues. Optional labels= and format="
48
66
  task "github:issues" => "github_repo" do
49
67
  repo = $STARTER[:github_repo]
50
- repo.issues.each do |issue|
51
- line = "#%-6i %s" % issue.values_at(*%w[ number title ])
52
- puts line
68
+ options = {}
69
+ require "pp"
70
+ if labels = ENV["labels"] || ENV["label"]
71
+ options[:labels] = labels
72
+ end
73
+ format = ENV["format"] || "plain"
74
+
75
+ issues = []
76
+ repo.issues(options).each do |issue|
77
+ issues << format_issue(issue, format)
78
+ end
79
+ if issues.size > 0
80
+ puts
81
+ puts issues
82
+ puts
53
83
  end
54
84
  end
55
85
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
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: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: git