github_api 0.3.4 → 0.3.5

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.
Files changed (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Repos
5
- module Keys
6
-
7
- VALID_KEY_PARAM_NAMES = %w[ title key ].freeze
8
-
9
- # List deploy keys
10
- #
11
- # = Examples
12
- # @github = Github.new
13
- # @github.repos.keys 'user-name', 'repo-name'
14
- # @github.repos.keys 'user-name', 'repo-name' { |key| ... }
15
- #
16
- def keys(user_name=nil, repo_name=nil, params={})
17
- _update_user_repo_params(user_name, repo_name)
18
- _validate_user_repo_params(user, repo) unless user? && repo?
19
- _normalize_params_keys(params)
20
-
21
- response = get("/repos/#{user}/#{repo}/keys")
22
- return response unless block_given?
23
- response.each { |el| yield el }
24
- end
25
-
26
- # Get a key
27
- #
28
- # = Examples
29
- # @github = Github.new
30
- # @github.repos.get_key 'user-name', 'repo-name', 'key-id'
31
- #
32
- def get_key(user_name, repo_name, key_id, params={})
33
- _update_user_repo_params(user_name, repo_name)
34
- _validate_user_repo_params(user, repo) unless user? && repo?
35
- _validate_presence_of key_id
36
- _normalize_params_keys(params)
37
-
38
- get("/repos/#{user}/#{repo}/keys/#{key_id}", params)
39
- end
40
-
41
- # Create a key
42
- #
43
- # = Inputs
44
- # * <tt>:title</tt> - Required string.
45
- # * <tt>:key</tt> - Required string.
46
- #
47
- # = Examples
48
- # @github = Github.new
49
- # @github.repos.create_key 'user-name', 'repo-name',
50
- # "title" => "octocat@octomac",
51
- # "key" => "ssh-rsa AAA..."
52
- #
53
- def create_key(user_name=nil, repo_name=nil, params={})
54
- _update_user_repo_params(user_name, repo_name)
55
- _validate_user_repo_params(user, repo) unless user? && repo?
56
- _normalize_params_keys(params)
57
- _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
58
-
59
- raise ArgumentError, "Required params are: #{VALID_KEY_PARAM_NAMES.join(', ')}" unless _validate_inputs(VALID_KEY_PARAM_NAMES, params)
60
-
61
- post("/repos/#{user}/#{repo}/keys", params)
62
- end
63
-
64
- # Edit a key
65
- #
66
- # = Inputs
67
- # * <tt>:title</tt> - Required string.
68
- # * <tt>:key</tt> - Required string.
69
- #
70
- # = Examples
71
- # @github = Github.new
72
- # @github.repos.create_key 'user-name', 'repo-name',
73
- # "title" => "octocat@octomac",
74
- # "key" => "ssh-rsa AAA..."
75
- #
76
- def edit_key(user_name, repo_name, key_id, params={})
77
- _update_user_repo_params(user_name, repo_name)
78
- _validate_user_repo_params(user, repo) unless user? && repo?
79
- _validate_presence_of key_id
80
-
81
- _normalize_params_keys(params)
82
- _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
83
-
84
- patch("/repos/#{user}/#{repo}/keys/#{key_id}", params)
85
- end
86
-
87
- # Delete key
88
- #
89
- # = Examples
90
- # @github = Github.new
91
- # @github.repos.delete_key 'user-name', 'repo-name', 'key-id'
92
- #
93
- def delete_key(user_name, repo_name, key_id, params={})
94
- _update_user_repo_params(user_name, repo_name)
95
- _validate_user_repo_params(user, repo) unless user? && repo?
96
- _validate_presence_of key_id
97
- _normalize_params_keys(params)
98
-
99
- delete("/repos/#{user}/#{repo}/keys/#{key_id}", params)
100
- end
101
-
102
- end # Keys
103
- end # Repos
104
- end # Github
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Repos
5
- module PubSubHubbub
6
-
7
- # Subscribe to existing topic through pubsubhubbub
8
- #
9
- # = Parameters
10
- # * topic - Required string - The URI of the GitHub repository to subscribe to. The path must be in the format of /:user/:repo/events/:event.
11
- # * callback - Required string - The URI to receive the updates to the topic.
12
- #
13
- # = Examples
14
- # @github = Github.new :oauth_token => '...'
15
- # @github.subscribe 'https://github.com/:user/:repo/events/push',
16
- # 'github://Email?address=peter-murach@gmail.com',
17
- # :verify => 'sync',
18
- # :secret => '...'
19
- #
20
- def subscribe(topic, callback, params={})
21
- _validate_presence_of topic, callback
22
- _normalize_params_keys(params)
23
- _merge_action!("subscribe", topic, callback, params)
24
-
25
- post("/hub", params)
26
- end
27
-
28
- # Unsubscribe from existing topic though pubsubhubbub
29
- #
30
- #
31
- def unsubscribe(topic, callback, params={})
32
- _validate_presence_of topic, callback
33
- _normalize_params_keys(params)
34
- _merge_action!("unsubscribe", topic, callback, params)
35
-
36
- post("/hub", params)
37
- end
38
-
39
- # Subscribe repository to service hook through pubsubhubbub
40
- #
41
- # = Parameters
42
- # * repo-name - Required string,
43
- # * service-name - Required string
44
- # * <tt>:event</tt> - Required hash key for the type of event. The default event is <tt>push</tt>
45
- #
46
- # = Examples
47
- # @github = Github.new :oauth_token => '...'
48
- # @github.repos.subscribe_service 'user-name', 'repo-name', 'campfire',
49
- # :subdomain => 'github',
50
- # :room => 'Commits',
51
- # :token => 'abc123',
52
- # :event => 'watch'
53
- #
54
- def subscribe_service(user_name, repo_name, service_name, params={})
55
- _validate_presence_of user_name, repo_name, service_name
56
- _normalize_params_keys(params)
57
- event = params.delete('event') || 'push'
58
- topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
59
- callback = "github://#{service_name}?#{params.serialize}"
60
-
61
- subscribe(topic, callback)
62
- end
63
- alias :subscribe_repository :subscribe_service
64
-
65
- # Subscribe repository to service hook through pubsubhubbub
66
- #
67
- # = Parameters
68
- # * repo-name - Required string,
69
- # * service-name - Required string
70
- # * <tt>:event</tt> - Optional hash key for the type of event. The default event is <tt>push</tt>
71
- #
72
- # = Examples
73
- # @github = Github.new :oauth_token => '...'
74
- # @github.repos.unsubscribe_service 'user-name', 'repo-name', 'campfire'
75
- #
76
- def unsubscribe_service(user_name, repo_name, service_name, params={})
77
- _validate_presence_of user_name, repo_name, service_name
78
- _normalize_params_keys(params)
79
- event = params.delete('event') || 'push'
80
- topic = "https://github.com/#{user_name}/#{repo_name}/events/#{event}"
81
- callback = "github://#{service_name}"
82
-
83
- unsubscribe(topic, callback)
84
- end
85
- alias :unsubscribe_repository :unsubscribe_service
86
-
87
- private
88
-
89
- def _merge_action!(action, topic, callback, params) # :nodoc:
90
- options = {
91
- "hub.mode" => action.to_s,
92
- "hub.topic" => topic.to_s,
93
- "hub.callback" => callback,
94
- "hub.verify" => params.delete('verify') || 'sync',
95
- "hub.secret" => params.delete('secret') || ''
96
- }
97
- params.merge! options
98
- end
99
-
100
- end # PubSubHubbub
101
- end # Repos
102
- end # Github
@@ -1,94 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Repos
5
- module Watching
6
-
7
- # List repo watchers
8
- #
9
- # = Examples
10
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
11
- # @github.repos.watchers
12
- # @github.repos.watchers { |watcher| ... }
13
- #
14
- def watchers(user_name=nil, repo_name=nil, params={})
15
- _update_user_repo_params(user_name, repo_name)
16
- _validate_user_repo_params(user, repo) unless user? && repo?
17
- _normalize_params_keys(params)
18
-
19
- response = get("/repos/#{user}/#{repo}/watchers")
20
- return response unless block_given?
21
- response.each { |el| yield el }
22
- end
23
-
24
- # List repos being watched by a user
25
- #
26
- # = Examples
27
- # @github = Github.new :user => 'user-name'
28
- # @github.repos.watched
29
- #
30
- # List repos being watched by the authenticated user
31
- #
32
- # = Examples
33
- # @github = Github.new :oauth_token => '...'
34
- # @github.repos.watched
35
- #
36
- def watched(user_name=nil, params={})
37
- _update_user_repo_params(user_name)
38
- _normalize_params_keys(params)
39
-
40
- response = if user
41
- get("/users/#{user}/watched")
42
- else
43
- get("/user/watched")
44
- end
45
- return response unless block_given?
46
- response.each { |el| yield el }
47
- end
48
-
49
- # Check if you are watching a repository
50
- #
51
- # Returns <tt>true</tt> if this repo is watched by you, <tt>false</tt> otherwise
52
- # = Examples
53
- # @github = Github.new
54
- # @github.repos.watching? 'user-name', 'repo-name'
55
- #
56
- def watching?(user_name, repo_name, params={})
57
- _validate_presence_of user_name, repo_name
58
- _normalize_params_keys(params)
59
- get("/user/watched/#{user_name}/#{repo_name}")
60
- true
61
- rescue Github::ResourceNotFound
62
- false
63
- end
64
-
65
- # Watch a repository
66
- #
67
- # You need to be authenticated to watch a repository
68
- #
69
- # = Examples
70
- # @github = Github.new
71
- # @github.repos.start_watching 'user-name', 'repo-name'
72
- #
73
- def start_watching(user_name, repo_name, params={})
74
- _validate_presence_of user_name, repo_name
75
- _normalize_params_keys(params)
76
- put("/user/watched/#{user_name}/#{repo_name}")
77
- end
78
-
79
- # Stop watching a repository
80
- #
81
- # You need to be authenticated to stop watching a repository.
82
- # = Examples
83
- # @github = Github.new
84
- # @github.repos.start_watching 'user-name', 'repo-name'
85
- #
86
- def stop_watching(user_name, repo_name, params={})
87
- _validate_presence_of user_name, repo_name
88
- _normalize_params_keys(params)
89
- delete("/user/watched/#{user_name}/#{repo_name}")
90
- end
91
-
92
- end # Watching
93
- end # Repos
94
- end # Github
@@ -1,84 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'base64'
4
- require 'addressable/uri'
5
- require 'multi_json'
6
-
7
- module Github
8
- # Defines HTTP verbs
9
- module Request
10
-
11
- METHODS = [:get, :post, :put, :delete, :patch]
12
- METHODS_WITH_BODIES = [ :post, :put, :patch ]
13
-
14
- TOKEN_REQUIRED_REGEXP = [
15
- /repos\/.*\/.*\/comments/,
16
- ]
17
-
18
- def get(path, params={}, options={})
19
- request(:get, path, params, options)
20
- end
21
-
22
- def patch(path, params={}, options={})
23
- request(:patch, path, params, options)
24
- end
25
-
26
- def post(path, params={}, options={})
27
- request(:post, path, params, options)
28
- end
29
-
30
- def put(path, params={}, options={})
31
- request(:put, path, params, options)
32
- end
33
-
34
- def delete(path, params={}, options={})
35
- request(:delete, path, params, options)
36
- end
37
-
38
- def request(method, path, params, options)
39
- if !METHODS.include?(method)
40
- raise ArgumentError, "unkown http method: #{method}"
41
- end
42
- _extract_mime_type(params, options)
43
-
44
- puts "EXECUTED: #{method} - #{path} with #{params} and #{options}"
45
-
46
- response = connection(options).send(method) do |request|
47
- case method.to_sym
48
- when *(METHODS - METHODS_WITH_BODIES)
49
- request.url(path, params)
50
- when *METHODS_WITH_BODIES
51
- request.path = path
52
- request.body = MultiJson.encode(_process_params(params)) unless params.empty?
53
- end
54
- end
55
- response.body
56
- end
57
-
58
- private
59
-
60
- def _process_params(params) # :nodoc:
61
- return params['data'] if params.has_key?('data')
62
- return params
63
- end
64
-
65
- def _extract_mime_type(params, options) # :nodoc:
66
- options['resource'] = params.delete('resource') || ''
67
- options['mime_type'] = params.delete('mime_type')
68
- end
69
-
70
- # no need for this smizzle
71
- def formatted_path(path, options={})
72
- [ path, options.fetch(:format, format) ].compact.join('.')
73
- end
74
-
75
- def basic_auth(login, password) # :nodoc:
76
- auth = Base64.encode("#{login}:#{password}")
77
- auth.gsub!("\n", "")
78
- end
79
-
80
- def token_auth
81
- end
82
-
83
- end # Request
84
- end # Github
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'faraday'
4
- require 'base64'
5
-
6
- module Github
7
- module Request
8
- class BasicAuth < Faraday::Middleware
9
- dependency 'base64'
10
-
11
- def call(env)
12
- env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"")
13
-
14
- @app.call env
15
- end
16
-
17
- def initialize(app, *args)
18
- @app = app
19
- credentials = ""
20
- options = args.last.is_a?(Hash) ? args.pop : {}
21
- if options.has_key? :login
22
- credentials = "#{options[:login]}:#{options[:password]}"
23
- elsif options.has_key? :basic_auth
24
- credentials = "#{options[:basic_auth]}"
25
- end
26
- @auth = Base64.encode64(credentials)
27
- @auth.gsub!("\n", "")
28
- end
29
- end # BasicAuth
30
- end # Request
31
- end # Github
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'faraday'
4
-
5
- module Github
6
- module Request
7
- class Caching < Faraday::Middleware
8
- attr_reader :cache
9
-
10
- def initialize(app, cache = nil, options={})
11
- super(app)
12
- @cache = cache || Proc.new{}.call
13
- end
14
-
15
- def call(env)
16
- if env[:method] == :get
17
- # TODO choose cache method
18
- # file_store
19
- # mem_cache_store
20
- # memory_store
21
- else
22
- @app.call(env)
23
- end
24
- end
25
-
26
- def cache_key
27
- url = env[:url].dup
28
- if url.query
29
- end
30
- end
31
- end
32
- end # Request
33
- end # Github