therapy 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Josh Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ = therapy
2
+
3
+ A command line tool for dealing with your (GitHub) issues. This is a fork of
4
+ http://github.com/technicalpickles/therapist.
5
+
6
+ Install it:
7
+
8
+ $ sudo gem install therapy
9
+
10
+
11
+ It works by guessing groking a git repository to figure out the user and repository on GitHub, and then hitting their API to get the issues. The issues get stashed in .git/issues to avoid constantly hitting the API, and for offline convenience.
12
+
13
+ Here's how you might use it:
14
+
15
+ $ cd jeweler
16
+ $ therapy list
17
+ #1 open: Windows Compatibility
18
+ #2 open: remove jeweler tasks' dependence on rake i.e. to allow thor to use the tasks
19
+ #6 open: Project creation failing (adding origin remote)
20
+ #8 open: rubyforge:release failing because no processor_id or release_id configured for
21
+ #9 open: rake rubyforge:setup creates duplicate packages
22
+ #13 open: GitHub Pages - RDoc to Branch
23
+ #16 open: 'rake release' not idempotent after failure
24
+ #18 open: RDoc rake task looks for VERSION.yml but plaintext is now default
25
+ #19 open: Jeweler can not read my ~/.gitconfig
26
+ #20 open: The Umlaut problem: UTF-8 chars get converted to unicode entities
27
+ #21 open: generating new project double quotes author and e-mail in Rakefile
28
+ #22 open: no such file to load -- shoulda (LoadError)
29
+ #23 open: .gitignore files showing up in s.test_files section of gemspec
30
+
31
+ Knowing an issue you want to look in, you can show more details:
32
+
33
+
34
+ $ therapy show 22
35
+ #22 open: no such file to load -- shoulda (LoadError)
36
+
37
+ user : thopre
38
+ created: Sat Jul 04 06:03:35 -0400 2009
39
+ updated: Sat Jul 04 06:03:35 -0400 2009
40
+ votes : 0
41
+
42
+ I get these errors when i try to do a 'rake test':
43
+
44
+ <snipped for brevity>
45
+
46
+ == Limitations
47
+
48
+ * Issues only ever get fetched once. They should get stale after a while, or you should be able to force a download
49
+ * Was built as a 1 hour spike before Railscamp NE, so no tests yet
50
+
51
+ == Copyright
52
+
53
+ Contributions from Jeff Rafter public domain.
54
+ Copyright (c) 2009 Josh Nichols. See LICENSE for details.
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "therapy"
8
+ gem.summary = %Q{Helps you deal with your (GitHub) issues}
9
+ gem.description = %Q{Therapy is a command line tool to help you interact with GitHub issues. Also supports offline viewing of said issues.}
10
+ gem.email = "josh@technicalpickles.com; jeff@socialrange.org"
11
+ gem.homepage = "http://github.com/jeffrafter/therapy"
12
+ gem.authors = ["Josh Nichols", "Jeff Rafter"]
13
+ gem.add_dependency "nakajima-nakajima"
14
+ gem.add_dependency "optimus-prime"
15
+ gem.add_dependency "git"
16
+ gem.files = FileList["[A-Z]*", "{lib,bin}/**/*", "test/**/*"]
17
+ gem.test_files = FileList["test/**/*"]
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/*_test.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/*_test.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ if File.exist?('VERSION.yml')
51
+ config = YAML.load(File.read('VERSION.yml'))
52
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "therapy #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
62
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'rubygems'
5
+ require 'therapy'
6
+ require 'optimus_prime'
7
+
8
+ class Therapy::Commands
9
+ include OptimusPrime
10
+
11
+ command :list do
12
+ # Lists issues for the current repository
13
+ #
14
+ # USAGE:
15
+ #
16
+ # $ cd path/to/git/repo
17
+ # $ therapy list
18
+ Therapy.new.list
19
+ end
20
+
21
+ command :show do |number|
22
+ # Shows a specific issue for the current repository
23
+ #
24
+ # USAGE:
25
+ #
26
+ # $ cd path/to/git/repo
27
+ # $ therapy show <number>
28
+ number.gsub!('#', '')
29
+ Therapy.new.show(number)
30
+ end
31
+
32
+ command :fetch do
33
+ # Fetches issues for the current repository
34
+ # USAGE:
35
+ #
36
+ # $ cd path/to/git/repo
37
+ # $ therapy list
38
+ Therapy.new.fetch
39
+ end
40
+ end
41
+
42
+ Therapy::Commands.new
@@ -0,0 +1,110 @@
1
+ require 'git'
2
+ require 'net/http'
3
+
4
+ class Therapy
5
+ attr_accessor :username, :repository, :config
6
+ def initialize()
7
+ @git = Git.open(Dir.pwd)
8
+ @config = Git.global_config
9
+
10
+ origin_url = @git.remote('origin').url
11
+ origin_url =~ /git@github\.com:(.*)\/(.*)\.git/
12
+ @username = $1
13
+ @repository = $2
14
+
15
+ @out = $stdout
16
+ end
17
+
18
+
19
+ def list
20
+ fetch_issues unless File.exist?(open_issues_file)
21
+
22
+ open_issues.each do |issue|
23
+ @out.puts "##{issue['number'].to_s.ljust 3} #{issue['state'].rjust 6}: #{issue['title']}"
24
+ end
25
+ end
26
+
27
+ def show(number)
28
+ fetch_issue(number) unless File.exist?(issue_file(number))
29
+
30
+ issue = YAML.load(File.read(issue_file(number)))['issue']
31
+
32
+ @out.puts "##{issue['number']} #{issue['state']}: #{issue['title']}"
33
+ @out.puts
34
+ @out.puts "user : #{issue['user']}"
35
+ @out.puts "created: #{issue['created_at']}"
36
+ @out.puts "updated: #{issue['updated_at']}"
37
+ @out.puts "votes : #{issue['votes']}"
38
+ @out.puts
39
+ @out.puts issue['body']
40
+ end
41
+
42
+ def fetch
43
+ fetch_issues
44
+ end
45
+
46
+ def open_issues
47
+ YAML.load(File.read(open_issues_file))['issues']
48
+ end
49
+
50
+ private
51
+
52
+ def fetch_issues
53
+ @out.puts "Fetching issues for #{@username}/#{@repository}"
54
+
55
+ FileUtils.mkdir_p(issues_dir)
56
+
57
+ response = Net::HTTP.post_form(URI.parse(list_issues_url), post_auth)
58
+ @out.puts "There was an error fetching the issues (#{response.code}): #{response.body}" and return if response.code != '200'
59
+
60
+ File.open open_issues_file, "w" do |file|
61
+ file.write response.body
62
+ end
63
+
64
+ open_issues.each do |issue|
65
+ fetch_issue(issue['number'])
66
+ end
67
+ end
68
+
69
+ def fetch_issue(number)
70
+ @out.puts "Fetching issue #{number} for #{@username}/#{@repository}"
71
+
72
+ FileUtils.mkdir_p(issues_dir)
73
+
74
+ response = Net::HTTP.post_form(URI.parse(show_issues_url(number)), post_auth)
75
+ @out.puts "There was an error fetching the issues (#{response.code}): #{response.body}" and return if response.code != '200'
76
+
77
+ File.open issue_file(number), "w" do |file|
78
+ file.write response.body
79
+ end
80
+ end
81
+
82
+ def issues_dir
83
+ '.git/issues'
84
+ end
85
+
86
+ def show_issues_url(number)
87
+ "http://github.com/api/v2/yaml/issues/show/#{username}/#{repository}/#{number}"
88
+ end
89
+
90
+ def list_issues_url
91
+ "http://github.com/api/v2/yaml/issues/list/#{username}/#{repository}/open"
92
+ end
93
+
94
+ def open_issues_file
95
+ "#{issues_dir}/open.yml"
96
+ end
97
+
98
+ def issue_file(number)
99
+ "#{issues_dir}/#{number}.yml"
100
+ end
101
+
102
+ def post_auth
103
+ options = {}
104
+ if (@config['github.token'] && @config['github.user'])
105
+ options['token'] = @config['github.token']
106
+ options['login'] = @config['github.user']
107
+ end
108
+ options
109
+ end
110
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'therapy'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class TherapyTest < Test::Unit::TestCase
4
+ should "find the git config" do
5
+ therapy = Therapy.new
6
+ assert_equal "jeffrafter", therapy.config["github.user"]
7
+ assert_equal "Jeff Rafter", therapy.config["user.name"]
8
+ end
9
+
10
+ should "fetch some issues" do
11
+ therapy = Therapy.new
12
+ therapy.username = "jeffrafter"
13
+ therapy.repository = "therapy"
14
+ therapy.config["github.user"] = nil
15
+ therapy.config["github.token"] = nil
16
+ l = therapy.fetch
17
+ puts "#{l}"
18
+ assert_not_nil l
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: therapy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nichols
8
+ - Jeff Rafter
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-02-04 00:00:00 -08:00
14
+ default_executable: therapy
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: nakajima-nakajima
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: optimus-prime
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: git
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ description: Therapy is a command line tool to help you interact with GitHub issues. Also supports offline viewing of said issues.
47
+ email: josh@technicalpickles.com; jeff@socialrange.org
48
+ executables:
49
+ - therapy
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - LICENSE
57
+ - README.rdoc
58
+ - Rakefile
59
+ - VERSION
60
+ - bin/therapy
61
+ - lib/therapy.rb
62
+ - test/test_helper.rb
63
+ - test/therapy_test.rb
64
+ has_rdoc: true
65
+ homepage: http://github.com/jeffrafter/therapy
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --charset=UTF-8
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.5
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Helps you deal with your (GitHub) issues
92
+ test_files:
93
+ - test/test_helper.rb
94
+ - test/therapy_test.rb