github_issues 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +1 -0
- data/Rakefile +1 -0
- data/github_issues.gemspec +24 -0
- data/lib/.DS_Store +0 -0
- data/lib/github_issues.rb +7 -0
- data/lib/github_issues/base.rb +86 -0
- data/lib/github_issues/version.rb +3 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Readme
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "github_issues/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "github_issues"
|
7
|
+
s.version = GithubIssues::VERSION
|
8
|
+
s.authors = ["Jon Phenow"]
|
9
|
+
s.email = ["jon.phenow@tstmedia.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Github API connector}
|
12
|
+
s.description = %q{}
|
13
|
+
|
14
|
+
s.rubyforge_project = "github_issues"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module GithubIssues
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def configure(args={})
|
5
|
+
# work out the default app_root
|
6
|
+
app_root = args[:app_root] || '.'
|
7
|
+
|
8
|
+
config_file = args[:config_file] || '/config/github_issues.yml'
|
9
|
+
yml_file = app_root+config_file
|
10
|
+
|
11
|
+
raise yml_file+" not found" unless File.exist? yml_file
|
12
|
+
@config = YAML.load(File.open yml_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def base_url
|
16
|
+
base = @config['repo_organization'] || @config['repo_user']
|
17
|
+
"https://api.github.com/repos/#{base}/#{@config['repo']}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(id)
|
21
|
+
JSON.parse(api_request("#{base_url}/issues/#{id}", 'GET'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(options={})
|
25
|
+
JSON.parse(api_request("#{base_url}/issues", 'GET', options))
|
26
|
+
end
|
27
|
+
|
28
|
+
def create(options={})
|
29
|
+
JSON.parse(api_request("#{base_url}/issues", 'POST', options))
|
30
|
+
end
|
31
|
+
|
32
|
+
def update(id, options={})
|
33
|
+
JSON.parse(api_request("#{base_url}/issues/#{id}", 'PATCH', options))
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_label(options={})
|
37
|
+
JSON.parse(api_request("#{base_url}/labels", 'POST', options))
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete_label(id)
|
41
|
+
JSON.parse(api_request("#{base_url}/labels/#{id}", 'DELETE'))
|
42
|
+
end
|
43
|
+
|
44
|
+
def api_request(api_url, http_method='GET', params={})
|
45
|
+
|
46
|
+
url = URI.parse(api_url)
|
47
|
+
|
48
|
+
if http_method == 'POST'
|
49
|
+
http = Net::HTTP.new(url.host, url.port)
|
50
|
+
http.use_ssl = true
|
51
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
52
|
+
|
53
|
+
request = Net::HTTP::Post.new(url.request_uri)
|
54
|
+
request.body = params.to_json
|
55
|
+
request.basic_auth @config['username'], @config['password']
|
56
|
+
elsif http_method == 'DELETE'
|
57
|
+
http = Net::HTTP.new(url.host, url.port)
|
58
|
+
http.use_ssl = true
|
59
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
60
|
+
|
61
|
+
request = Net::HTTP::Delete.new(url.request_uri)
|
62
|
+
request.basic_auth @config['username'], @config['password']
|
63
|
+
elsif http_method == 'PATCH'
|
64
|
+
http = Net::HTTP.new(url.host, url.port)
|
65
|
+
http.use_ssl = true
|
66
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
67
|
+
|
68
|
+
request = Net::HTTP::Patch.new(url.request_uri)
|
69
|
+
request.body = params.to_json
|
70
|
+
request.basic_auth @config['username'], @config['password']
|
71
|
+
else
|
72
|
+
url.query = URI.encode_www_form(params)
|
73
|
+
http = Net::HTTP.new(url.host, url.port)
|
74
|
+
http.use_ssl = true
|
75
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
76
|
+
|
77
|
+
request = Net::HTTP::Get.new(url.request_uri)
|
78
|
+
request.basic_auth @config['username'], @config['password']
|
79
|
+
end
|
80
|
+
|
81
|
+
response = http.request(request)
|
82
|
+
response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
end # class
|
86
|
+
end # module
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_issues
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Phenow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: ''
|
31
|
+
email:
|
32
|
+
- jon.phenow@tstmedia.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- README
|
40
|
+
- Rakefile
|
41
|
+
- github_issues.gemspec
|
42
|
+
- lib/.DS_Store
|
43
|
+
- lib/github_issues.rb
|
44
|
+
- lib/github_issues/base.rb
|
45
|
+
- lib/github_issues/version.rb
|
46
|
+
homepage: ''
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project: github_issues
|
66
|
+
rubygems_version: 1.8.19
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Github API connector
|
70
|
+
test_files: []
|