ctodo 0.0.2 → 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/.todo +1 -2
- data/README.md +4 -3
- data/lib/ctodo/gcode.rb +42 -0
- data/lib/ctodo/github.rb +7 -8
- data/lib/ctodo/localfs.rb +1 -1
- data/lib/ctodo/redmine.rb +4 -3
- data/lib/ctodo.rb +23 -4
- metadata +5 -4
data/.todo
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# If you don't want to use some of these services just
|
4
4
|
# remove the corresponding lines below:
|
5
5
|
---
|
6
|
-
:gh_user: <github-user>
|
7
|
-
:gh_pass: <github-password>
|
6
|
+
:gh_user: <github-default-user (_not_ your email!)>
|
8
7
|
:red_uri: <redmine-base-uri>
|
9
8
|
:red_key: <redmine-api-key>
|
10
9
|
:red2_uri: <another-redmine-base-uri>
|
data/README.md
CHANGED
@@ -8,8 +8,9 @@ Provider
|
|
8
8
|
--------
|
9
9
|
|
10
10
|
- LocalFS -- grep-like local file system provider
|
11
|
-
- Github -- issues from identically named github.com
|
12
|
-
-
|
11
|
+
- Github -- issues from identically named github.com/<gh_user> repo
|
12
|
+
- Google Project Hosting -- issues from identically named code.google.com/p/ project
|
13
|
+
- Redmine -- issues from identically named project on your.redmine.com server
|
13
14
|
|
14
15
|
Setup
|
15
16
|
-----
|
@@ -25,7 +26,6 @@ Template for ~/.todo
|
|
25
26
|
# remove the corresponding lines below:
|
26
27
|
---
|
27
28
|
:gh_user: <github-user>
|
28
|
-
:gh_pass: <github-password>
|
29
29
|
:red_uri: <redmine-base-uri>
|
30
30
|
:red_key: <redmine-api-key>
|
31
31
|
:red2_uri: <another-redmine-base-uri>
|
@@ -36,4 +36,5 @@ Links
|
|
36
36
|
|
37
37
|
- [Github API](http://developer.github.com/v3/)
|
38
38
|
- [Redmine API](http://www.redmine.org/projects/redmine/wiki/Rest_api)
|
39
|
+
- [Google Project Hosting Issues API](https://code.google.com/p/support/wiki/IssueTrackerAPI)
|
39
40
|
- [HSV color space](https://secure.wikimedia.org/wikipedia/de/wiki/HSV-Farbraum)
|
data/lib/ctodo/gcode.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
module CTodo
|
3
|
+
class GoogleCodeProjectHosting
|
4
|
+
include HTTParty
|
5
|
+
base_uri "https://code.google.com/feeds/issues/p"
|
6
|
+
|
7
|
+
def initialize(conf)
|
8
|
+
@enabled = true
|
9
|
+
if @enabled
|
10
|
+
dir = [:git_repo_dir, :hg_repo_dir, :cur_dir].map {|k| conf[k]}.select {|v| not v.nil?}.first
|
11
|
+
@repo_name = File.basename(dir)
|
12
|
+
# HACK: 1000 should really be enough
|
13
|
+
@limit = (conf[:all] ? 1000 : 25)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_issues(issues)
|
18
|
+
return if not @enabled
|
19
|
+
|
20
|
+
r = self.class.get "/#{@repo_name}/issues/full", :query => {:can => 'open', :"max-results" => @limit}
|
21
|
+
#puts r.code
|
22
|
+
return unless r.code == 200
|
23
|
+
#puts r.inspect
|
24
|
+
|
25
|
+
feed = HTTParty::Parser.call(r.body, :xml)
|
26
|
+
return if feed['feed'].nil?
|
27
|
+
feed = feed['feed']
|
28
|
+
|
29
|
+
return if feed['entry'].nil?
|
30
|
+
|
31
|
+
#puts feed['entry'].first.inspect
|
32
|
+
|
33
|
+
feed['entry'].each do |e|
|
34
|
+
loc = e['link'].select {|link| link['type'] == 'text/html'}.first
|
35
|
+
loc = loc['href'] unless loc.nil?
|
36
|
+
assig = e['owner'].nil? ? nil : e['owner']['username']
|
37
|
+
tags = e['label'].map {|lab| Tag.new(lab, ColorUtils.rgb4string(lab))}
|
38
|
+
issues << Issue.new(e['title'], loc, assig, tags)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ctodo/github.rb
CHANGED
@@ -5,9 +5,10 @@ module CTodo
|
|
5
5
|
base_uri "https://api.github.com"
|
6
6
|
|
7
7
|
def initialize(conf)
|
8
|
-
@enabled = (!conf[:gh_user].nil? and !conf[:
|
8
|
+
@enabled = (!conf[:gh_user].nil? and !conf[:git_repo_dir].nil?)
|
9
9
|
if @enabled
|
10
|
-
|
10
|
+
@login = conf[:gh_user]
|
11
|
+
# needed to locate .git/config to look for other remotes
|
11
12
|
@repo_dir = Pathname.new(conf[:git_repo_dir])
|
12
13
|
@repo_name = File.basename(conf[:git_repo_dir])
|
13
14
|
end
|
@@ -19,17 +20,15 @@ module CTodo
|
|
19
20
|
status_msgs = []
|
20
21
|
|
21
22
|
# try current user first
|
22
|
-
|
23
|
-
login = r['login']
|
24
|
-
|
25
|
-
gh_issues = get_issues_for(login, @repo_name)
|
23
|
+
gh_issues = get_issues_for(@login, @repo_name)
|
26
24
|
if !gh_issues.nil?
|
27
|
-
#
|
25
|
+
# don't output as this is the default
|
26
|
+
#status_msgs << "User: #{@login}"
|
28
27
|
parse_issues(gh_issues, issues)
|
29
28
|
else
|
30
29
|
# find alternative login from "remote origin" config entry
|
31
30
|
alt_login = remote_login("origin")
|
32
|
-
if !alt_login.nil? and alt_login != login
|
31
|
+
if !alt_login.nil? and alt_login != @login
|
33
32
|
alt_gh_issues = get_issues_for(alt_login, @repo_name)
|
34
33
|
if !alt_gh_issues.nil?
|
35
34
|
status_msgs << "User: #{alt_login}"
|
data/lib/ctodo/localfs.rb
CHANGED
@@ -11,7 +11,7 @@ module CTodo
|
|
11
11
|
def initialize(conf)
|
12
12
|
@enabled = true
|
13
13
|
if @enabled
|
14
|
-
@parent_dir =
|
14
|
+
@parent_dir = [:git_repo_dir, :hg_repo_dir, :cur_dir].map {|k| conf[k]}.select {|v| not v.nil?}.first
|
15
15
|
@todo_labels = (conf[:all] ? ALL_LABELS : IMP_LABELS).join('|')
|
16
16
|
end
|
17
17
|
end
|
data/lib/ctodo/redmine.rb
CHANGED
@@ -7,12 +7,13 @@ module CTodo
|
|
7
7
|
def initialize(conf, prefix = 'red')
|
8
8
|
red_uri = conf[:"#{prefix}_uri"]
|
9
9
|
red_key = conf[:"#{prefix}_key"]
|
10
|
-
@enabled = (!red_uri.nil? and !red_key.nil?
|
10
|
+
@enabled = (!red_uri.nil? and !red_key.nil?)
|
11
11
|
if @enabled
|
12
12
|
self.class.base_uri(red_uri)
|
13
13
|
rand_pwd = (0...8).map {65.+(rand(25)).chr}.join
|
14
14
|
self.class.basic_auth(red_key, rand_pwd)
|
15
|
-
|
15
|
+
dir = [:git_repo_dir, :hg_repo_dir, :cur_dir].map {|k| conf[k]}.select {|v| not v.nil?}.first
|
16
|
+
@repo = File.basename(dir)
|
16
17
|
# HACK: 1000 should really be enough
|
17
18
|
@limit = (conf[:all] ? 1000 : 25)
|
18
19
|
end
|
@@ -29,7 +30,7 @@ module CTodo
|
|
29
30
|
p_id = find_id_for_identifier(r['projects'], @repo)
|
30
31
|
return if p_id == nil
|
31
32
|
|
32
|
-
r = self.class.get "/issues.json
|
33
|
+
r = self.class.get "/issues.json", :query => {:project_id => p_id, :offset => 0, :limit => @limit}
|
33
34
|
|
34
35
|
r['issues'].each do |i|
|
35
36
|
loc = "#{self.class.base_uri}/issues/#{i['id']}"
|
data/lib/ctodo.rb
CHANGED
@@ -9,6 +9,7 @@ require 'json'
|
|
9
9
|
|
10
10
|
# ctodo
|
11
11
|
require 'ctodo/color'
|
12
|
+
require 'ctodo/gcode'
|
12
13
|
require 'ctodo/localfs'
|
13
14
|
require 'ctodo/github'
|
14
15
|
require 'ctodo/redmine'
|
@@ -93,10 +94,16 @@ module CTodo
|
|
93
94
|
|
94
95
|
conf[:cur_dir] = Dir.getwd
|
95
96
|
conf[:git_repo_dir] = find_git_repo(Dir.getwd)
|
97
|
+
conf[:hg_repo_dir] = find_hg_repo(Dir.getwd)
|
96
98
|
conf[:all] = @options[:all]
|
97
99
|
conf[:cs] = CTodo.const_get("#{@options[:cs]}ColorSet").new
|
98
100
|
|
99
|
-
ip = [
|
101
|
+
ip = [
|
102
|
+
LocalFS.new(conf),
|
103
|
+
Github.new(conf),
|
104
|
+
Redmine.new(conf), Redmine.new(conf, 'red2'),
|
105
|
+
GoogleCodeProjectHosting.new(conf)
|
106
|
+
]
|
100
107
|
|
101
108
|
issues = []
|
102
109
|
ip.each do |ip| ip.get_issues(issues) end
|
@@ -125,7 +132,8 @@ module CTodo
|
|
125
132
|
tag_list.push "@#{i.assignee}" if @options[:show_assignee] and not i.assignee.nil?
|
126
133
|
tag_list = (tag_list.empty? ? '' : format('(%s) ', tag_list.join(', ')))
|
127
134
|
|
128
|
-
|
135
|
+
# source may be nil
|
136
|
+
if @options[:show_source] and !i.source.nil?
|
129
137
|
puts format("- %-#{title_padding}s %sin %s",
|
130
138
|
title, tag_list, i.source)
|
131
139
|
else
|
@@ -148,14 +156,25 @@ module CTodo
|
|
148
156
|
end
|
149
157
|
|
150
158
|
def find_git_repo(path)
|
151
|
-
|
159
|
+
git_dir_name = Pathname.new(!ENV['GIT_DIR'].nil? ? ENV['GIT_DIR'] : '.git')
|
152
160
|
p = Pathname.new(path)
|
153
161
|
until p.root?
|
154
|
-
git_dir = p +
|
162
|
+
git_dir = p + git_dir_name
|
155
163
|
return p.to_s if git_dir.exist? and git_dir.directory?
|
156
164
|
p = p.parent
|
157
165
|
end
|
158
166
|
nil
|
159
167
|
end
|
168
|
+
|
169
|
+
def find_hg_repo(path)
|
170
|
+
hg_dir_name = '.hg'
|
171
|
+
p = Pathname.new(path)
|
172
|
+
until p.root?
|
173
|
+
hg_dir = p + hg_dir_name
|
174
|
+
return p.to_s if hg_dir.exist? and hg_dir.directory?
|
175
|
+
p = p.parent
|
176
|
+
end
|
177
|
+
nil
|
178
|
+
end
|
160
179
|
end
|
161
180
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Nicolai
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: "0"
|
60
60
|
type: :runtime
|
61
61
|
version_requirements: *id003
|
62
|
-
description:
|
62
|
+
description: Searches for issues on Github/Google Code/custom Redmine instances/local files for current project or folder.
|
63
63
|
email: chrnicolai@gmail.com
|
64
64
|
executables:
|
65
65
|
- todo
|
@@ -70,6 +70,7 @@ extra_rdoc_files: []
|
|
70
70
|
files:
|
71
71
|
- bin/todo
|
72
72
|
- lib/ctodo/color.rb
|
73
|
+
- lib/ctodo/gcode.rb
|
73
74
|
- lib/ctodo/github.rb
|
74
75
|
- lib/ctodo/localfs.rb
|
75
76
|
- lib/ctodo/redmine.rb
|