Neurogami-ghissues 0.1.2

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/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2009-08-30
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
data/README.markdown ADDED
@@ -0,0 +1,80 @@
1
+ # Neurogami::GHIssues
2
+
3
+ by James Britt / Neurogami
4
+
5
+ james@neurogami.com
6
+
7
+ http://www.neurogami.com
8
+
9
+ ## DESCRIPTION:
10
+
11
+ CLI app to interact with GitHub 'issues' API
12
+
13
+ ## FEATURES/PROBLEMS:
14
+
15
+ Quite new. Does some useful stuff.
16
+
17
+ Allows for fetching open tickets and adding new tickets from the command line.
18
+
19
+
20
+ ## SYNOPSIS:
21
+
22
+ ghissues open
23
+ Lists open issues
24
+
25
+ ghissues open reload
26
+ Lists open issues after refreshing the local issues cache file.
27
+
28
+ ghissues create
29
+ Creates new issue. You get prompted for values
30
+
31
+
32
+ You need a .ghissues file in the directory from which you invoke the app. It needs
33
+ to be a YAML file, like this:
34
+
35
+ owner: your_github_account_name
36
+ repo: the_repo_you_are_dealing_withm
37
+ issues_cache_file: some_file_name_for_caching_issues.yaml
38
+
39
+ Also, you need to define an ENV value for GH_AUTH_TOKEN
40
+
41
+ See http://github.com/blog/170-token-authentication
42
+
43
+ ## REQUIREMENTS:
44
+
45
+ Ruby. I think that's all. And a github account and repo to use this with. Oh, and issues.
46
+
47
+
48
+ ## INSTALL:
49
+
50
+ The usual gem install stuff, with the required github additions.
51
+
52
+ After adding github.com as a gem source,
53
+
54
+ sudo gem i neurogami-ghissues
55
+
56
+
57
+ ## LICENSE:
58
+
59
+ (The MIT License)
60
+
61
+ Copyright (c) 2009 James Britt / Neurogami
62
+
63
+ Permission is hereby granted, free of charge, to any person obtaining
64
+ a copy of this software and associated documentation files (the
65
+ 'Software'), to deal in the Software without restriction, including
66
+ without limitation the rights to use, copy, modify, merge, publish,
67
+ distribute, sublicense, and/or sell copies of the Software, and to
68
+ permit persons to whom the Software is furnished to do so, subject to
69
+ the following conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
76
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
77
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
78
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
79
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
80
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ # Look in the tasks/setup.rb file for the various options that can be
2
+ # configured in this Rakefile. The .rake files in the tasks directory
3
+ # are where the options are used.
4
+
5
+ begin
6
+ require 'bones'
7
+ Bones.setup
8
+ rescue LoadError
9
+ begin
10
+ load 'tasks/setup.rb'
11
+ rescue LoadError
12
+ raise RuntimeError, '### please install the "bones" gem ###'
13
+ end
14
+ end
15
+
16
+ ensure_in_path 'lib'
17
+ require 'ghissues'
18
+
19
+ task :default => 'spec:run'
20
+
21
+ PROJ.name = 'ghissues'
22
+ PROJ.authors = 'James Britt'
23
+ PROJ.email = 'james@neurogami.com'
24
+ PROJ.url = 'http://neurogami.com/code'
25
+ PROJ.version = Ghissues::VERSION
26
+ PROJ.rubyforge.name = 'ghissues' # There is no RF project
27
+
28
+ PROJ.spec.opts << '--color'
29
+
30
+
31
+ # EOF
data/bin/ghissues ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ require 'ostruct'
4
+ require 'optparse'
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ghissues]))
7
+
8
+ options = OpenStruct.new
9
+
10
+ def help
11
+ puts "Usage:
12
+
13
+ ghissues open
14
+ Lists open issues
15
+
16
+ ghissues create title, body
17
+ Creates a new issue "
18
+ end
19
+
20
+
21
+
22
+ (help; exit) if ARGV.empty?
23
+
24
+ #begin
25
+ Neurogami::GHIssues.send *ARGV
26
+ #rescue Exception
27
+ # warn "Yikes! Error invoking #{arg}:\n#{$!.inspect}"
28
+ #end
29
+
30
+
data/lib/ghissues.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'version'
2
+
3
+ module Ghissues
4
+
5
+ # :stopdoc:
6
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+
10
+ # Returns the version string for the library.
11
+ #
12
+ def self.version
13
+ VERSION
14
+ end
15
+
16
+ # Returns the library path for the module. If any arguments are given,
17
+ # they will be joined to the end of the libray path using
18
+ # <tt>File.join</tt>.
19
+ #
20
+ def self.libpath( *args )
21
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ end
23
+
24
+ # Returns the lpath for the module. If any arguments are given,
25
+ # they will be joined to the end of the path using
26
+ # <tt>File.join</tt>.
27
+ #
28
+ def self.path( *args )
29
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ end
31
+
32
+ # Utility method used to require all files ending in .rb that lie in the
33
+ # directory below this file that has the same name as the filename passed
34
+ # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # the _filename_ does not have to be equivalent to the directory.
36
+ #
37
+ def self.require_all_libs_relative_to( fname, dir = nil )
38
+ dir ||= ::File.basename(fname, '.*')
39
+ search_me = ::File.expand_path(
40
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+
42
+ Dir.glob(search_me).sort.each {|rb| require rb}
43
+ end
44
+
45
+ end # module Ghissues
46
+
47
+ Ghissues.require_all_libs_relative_to(__FILE__)
48
+
49
+ # EOF
@@ -0,0 +1,91 @@
1
+ require 'open-uri'
2
+ require 'yaml'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'yaml'
6
+
7
+ module Neurogami
8
+ class GHIssues
9
+ class << self
10
+
11
+ def open *args
12
+ nocache = args && args.first =~ /reload|refresh/i
13
+ paged_issues nocache
14
+ end
15
+
16
+
17
+ def create
18
+ ARGV.clear
19
+ print "Issue title: "
20
+ title = gets.strip
21
+ print "Issue body: "
22
+ body = gets.strip
23
+ create_issue title, body
24
+ end
25
+
26
+ private
27
+
28
+ def read_config
29
+ begin
30
+ @@config_file = "#{Dir.pwd}/.ghissues"
31
+ unless File.exist? @@config_file
32
+ warn "You need to have config properties in #{@@config_file}"
33
+ exit
34
+ end
35
+ @@config = YAML.load IO.read(@@config_file)
36
+ end
37
+ end
38
+
39
+ def config
40
+ @@config ||= read_config
41
+ end
42
+
43
+ def create_issue title, body
44
+ token = ENV['GH_AUTH_TOKEN']
45
+ url = "http://github.com/api/v2/yaml/issues/open/#{config['owner']}/#{config['repo']}"
46
+ res = Net::HTTP.post_form(URI.parse(url), {'title'=> title, 'body' => body, 'login' => config['owner'], 'token'=> token })
47
+ if res.body.to_s.strip.empty?
48
+ raise "There was problem creating the new issue: #{res.error!}"
49
+ else
50
+ warn "Posted issue\n" + res.body
51
+ end
52
+ end
53
+
54
+ def ___
55
+ warn "\n" + '_' * 30
56
+ end
57
+
58
+ def paged_issues no_cache = false
59
+ ARGV.clear
60
+ warn "Hit enter after each issue to see the next one"
61
+ issues(no_cache).each do |issue|
62
+ ___
63
+ warn "Title: #{issue['title']}"
64
+ warn "Details: \n#{issue['body']}"
65
+ ___
66
+ gets
67
+ end
68
+ warn "\nThat's it!"
69
+ end
70
+
71
+
72
+ def issues no_cache = false
73
+ issues_cache = config['issues_cache_file'] || 'issues.yaml'
74
+ if no_cache || !File.exist?(issues_cache)
75
+ warn "Reloading issues from GitHub ..."
76
+ File.open(issues_cache, 'w'){ |f| f.puts get_issues }
77
+ end
78
+ YAML.load(IO.read(issues_cache))['issues']
79
+ end
80
+
81
+ def get_issues
82
+ url = "http://github.com/api/v2/yaml/issues/list/#{config['owner']}/#{config['repo']}/open"
83
+ issues = Kernel.open(url).read
84
+ raise "Failed to get issues" if issues.to_s.strip.empty?
85
+ issues
86
+ end
87
+
88
+
89
+ end
90
+ end
91
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+
2
+ module Ghissues
3
+
4
+ # :stopdoc:
5
+ VERSION = '0.1.2'
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+
4
+ describe Ghissues do
5
+ end
6
+
7
+ # EOF
@@ -0,0 +1,16 @@
1
+
2
+ require File.expand_path(
3
+ File.join(File.dirname(__FILE__), %w[.. lib ghissues]))
4
+
5
+ Spec::Runner.configure do |config|
6
+ # == Mock Framework
7
+ #
8
+ # RSpec uses it's own mocking framework by default. If you prefer to
9
+ # use mocha, flexmock or RR, uncomment the appropriate line:
10
+ #
11
+ # config.mock_with :mocha
12
+ # config.mock_with :flexmock
13
+ # config.mock_with :rr
14
+ end
15
+
16
+ # EOF
File without changes
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Neurogami-ghissues
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - James Britt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-01 00:00:00 -07:00
13
+ default_executable: ghissues
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bones
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.5.0
24
+ version:
25
+ description: CLI app to interact with GitHub 'issues' API
26
+ email: james@neurogami.com
27
+ executables:
28
+ - ghissues
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - README.markdown
34
+ - bin/ghissues
35
+ files:
36
+ - History.txt
37
+ - README.markdown
38
+ - Rakefile
39
+ - bin/ghissues
40
+ - lib/ghissues.rb
41
+ - lib/version.rb
42
+ - lib/ghissues/ghissues.rb
43
+ - spec/ghissues_spec.rb
44
+ - spec/spec_helper.rb
45
+ - test/test_ghissues.rb
46
+ has_rdoc: false
47
+ homepage: http://github.com/Neurogami/ghissues/tree/master
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --main
51
+ - README.txt
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: ghissues
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Neurogami::GHIssues lets you do some basic interaction with the GitHub 'issues' Web API.
73
+ test_files:
74
+ - test/test_ghissues.rb