pushpop-github 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+
4
+ rvm:
5
+ - 2.1.1
6
+
7
+ script:
8
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pushpop'
4
+ gem 'github_api'
5
+
6
+ group :development, :test do
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'debugger'
10
+ gem 'mail'
11
+ gem 'twilio-ruby'
12
+ end
@@ -0,0 +1,94 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (4.1.1)
5
+ i18n (~> 0.6, >= 0.6.9)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.3.6)
11
+ builder (3.2.2)
12
+ clockwork (0.7.5)
13
+ activesupport
14
+ tzinfo
15
+ columnize (0.3.6)
16
+ debugger (1.6.6)
17
+ columnize (>= 0.3.1)
18
+ debugger-linecache (~> 1.2.0)
19
+ debugger-ruby_core_source (~> 1.3.2)
20
+ debugger-linecache (1.2.0)
21
+ debugger-ruby_core_source (1.3.2)
22
+ descendants_tracker (0.0.4)
23
+ thread_safe (~> 0.3, >= 0.3.1)
24
+ diff-lcs (1.2.5)
25
+ faraday (0.9.0)
26
+ multipart-post (>= 1.2, < 3)
27
+ github_api (0.11.3)
28
+ addressable (~> 2.3)
29
+ descendants_tracker (~> 0.0.1)
30
+ faraday (~> 0.8, < 0.10)
31
+ hashie (>= 1.2)
32
+ multi_json (>= 1.7.5, < 2.0)
33
+ nokogiri (~> 1.6.0)
34
+ oauth2
35
+ hashie (3.0.0)
36
+ i18n (0.6.9)
37
+ json (1.8.1)
38
+ jwt (1.0.0)
39
+ keen (0.8.2)
40
+ addressable (~> 2.3.5)
41
+ multi_json (~> 1.3)
42
+ mail (2.5.4)
43
+ mime-types (~> 1.16)
44
+ treetop (~> 1.4.8)
45
+ mime-types (1.25.1)
46
+ mini_portile (0.6.0)
47
+ minitest (5.3.4)
48
+ multi_json (1.10.1)
49
+ multi_xml (0.5.5)
50
+ multipart-post (2.0.0)
51
+ nokogiri (1.6.2.1)
52
+ mini_portile (= 0.6.0)
53
+ oauth2 (0.9.4)
54
+ faraday (>= 0.8, < 0.10)
55
+ jwt (~> 1.0)
56
+ multi_json (~> 1.3)
57
+ multi_xml (~> 0.5)
58
+ rack (~> 1.2)
59
+ polyglot (0.3.4)
60
+ pushpop (0.1.0)
61
+ clockwork
62
+ keen
63
+ rack (1.5.2)
64
+ rake (10.3.2)
65
+ rspec (2.14.1)
66
+ rspec-core (~> 2.14.0)
67
+ rspec-expectations (~> 2.14.0)
68
+ rspec-mocks (~> 2.14.0)
69
+ rspec-core (2.14.8)
70
+ rspec-expectations (2.14.5)
71
+ diff-lcs (>= 1.1.3, < 2.0)
72
+ rspec-mocks (2.14.6)
73
+ thread_safe (0.3.4)
74
+ treetop (1.4.15)
75
+ polyglot
76
+ polyglot (>= 0.3.1)
77
+ twilio-ruby (3.11.5)
78
+ builder (>= 2.1.2)
79
+ jwt (>= 0.1.2)
80
+ multi_json (>= 1.3.0)
81
+ tzinfo (1.2.1)
82
+ thread_safe (~> 0.1)
83
+
84
+ PLATFORMS
85
+ ruby
86
+
87
+ DEPENDENCIES
88
+ debugger
89
+ github_api
90
+ mail
91
+ pushpop
92
+ rake
93
+ rspec
94
+ twilio-ruby
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Author Josh Dzielak
2
+ Copyright (c) 2014 Keen Labs
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,178 @@
1
+ ## pushpop-github
2
+
3
+ [![Build Status](https://travis-ci.org/pushpop-project/pushpop-github.svg)](https://travis-ci.org/pushpop-project/pushpop-github)
4
+
5
+ Github API integration for [Pushpop](https://github.com/keenlabs/pushpop).
6
+
7
+ ### Installation
8
+
9
+ Add the `pushpop-github` gem to your Gemfile:
10
+
11
+ ``` ruby
12
+ gem 'pushpop-github'
13
+ ```
14
+
15
+ or install it locally:
16
+
17
+ ``` shell
18
+ $ gem install pushpop-github
19
+ ```
20
+
21
+ ### Usage
22
+
23
+ Here's a simple that job defines a `github` step, setting a `user` and `repository`:
24
+
25
+ ``` ruby
26
+ require 'pushpop-github'
27
+
28
+ job do
29
+
30
+ github do
31
+ user 'keenlabs'
32
+ repository 'pushpop'
33
+ end
34
+
35
+ step do |repository, _|
36
+ puts "keenlabs/pushpop has #{repository.stargazers_count} stars!"
37
+ end
38
+
39
+ end
40
+ ```
41
+
42
+ The `github` step pulls repository information from the Github API and passes it on to
43
+ the next step.
44
+
45
+ ##### Repository fields
46
+
47
+ Here's what repository data looks like, using the main Pushpop repository as an example:
48
+
49
+ ``` json
50
+ {
51
+ "id": 18272447,
52
+ "name": "pushpop",
53
+ "full_name": "keenlabs/pushpop",
54
+ "owner": {
55
+ "login": "keenlabs",
56
+ "id": 1315418,
57
+ "avatar_url": "https://avatars.githubusercontent.com/u/1315418?",
58
+ "gravatar_id": "b948c4bc2de9618c488431612d2ff99d",
59
+ "url": "https://api.github.com/users/keenlabs",
60
+ "html_url": "https://github.com/keenlabs",
61
+ "followers_url": "https://api.github.com/users/keenlabs/followers",
62
+ "following_url": "https://api.github.com/users/keenlabs/following{/other_user}",
63
+ "gists_url": "https://api.github.com/users/keenlabs/gists{/gist_id}",
64
+ "starred_url": "https://api.github.com/users/keenlabs/starred{/owner}{/repo}",
65
+ "subscriptions_url": "https://api.github.com/users/keenlabs/subscriptions",
66
+ "organizations_url": "https://api.github.com/users/keenlabs/orgs",
67
+ "repos_url": "https://api.github.com/users/keenlabs/repos",
68
+ "events_url": "https://api.github.com/users/keenlabs/events{/privacy}",
69
+ "received_events_url": "https://api.github.com/users/keenlabs/received_events",
70
+ "type": "Organization",
71
+ "site_admin": false
72
+ },
73
+ "private": false,
74
+ "html_url": "https://github.com/keenlabs/pushpop",
75
+ "description": "Send alerts and recurring reports based on Keen IO events",
76
+ "fork": false,
77
+ "url": "https://api.github.com/repos/keenlabs/pushpop",
78
+ "forks_url": "https://api.github.com/repos/keenlabs/pushpop/forks",
79
+ "keys_url": "https://api.github.com/repos/keenlabs/pushpop/keys{/key_id}",
80
+ "collaborators_url": "https://api.github.com/repos/keenlabs/pushpop/collaborators{/collaborator}",
81
+ "teams_url": "https://api.github.com/repos/keenlabs/pushpop/teams",
82
+ "hooks_url": "https://api.github.com/repos/keenlabs/pushpop/hooks",
83
+ "issue_events_url": "https://api.github.com/repos/keenlabs/pushpop/issues/events{/number}",
84
+ "events_url": "https://api.github.com/repos/keenlabs/pushpop/events",
85
+ "assignees_url": "https://api.github.com/repos/keenlabs/pushpop/assignees{/user}",
86
+ "branches_url": "https://api.github.com/repos/keenlabs/pushpop/branches{/branch}",
87
+ "tags_url": "https://api.github.com/repos/keenlabs/pushpop/tags",
88
+ "blobs_url": "https://api.github.com/repos/keenlabs/pushpop/git/blobs{/sha}",
89
+ "git_tags_url": "https://api.github.com/repos/keenlabs/pushpop/git/tags{/sha}",
90
+ "git_refs_url": "https://api.github.com/repos/keenlabs/pushpop/git/refs{/sha}",
91
+ "trees_url": "https://api.github.com/repos/keenlabs/pushpop/git/trees{/sha}",
92
+ "statuses_url": "https://api.github.com/repos/keenlabs/pushpop/statuses/{sha}",
93
+ "languages_url": "https://api.github.com/repos/keenlabs/pushpop/languages",
94
+ "stargazers_url": "https://api.github.com/repos/keenlabs/pushpop/stargazers",
95
+ "contributors_url": "https://api.github.com/repos/keenlabs/pushpop/contributors",
96
+ "subscribers_url": "https://api.github.com/repos/keenlabs/pushpop/subscribers",
97
+ "subscription_url": "https://api.github.com/repos/keenlabs/pushpop/subscription",
98
+ "commits_url": "https://api.github.com/repos/keenlabs/pushpop/commits{/sha}",
99
+ "git_commits_url": "https://api.github.com/repos/keenlabs/pushpop/git/commits{/sha}",
100
+ "comments_url": "https://api.github.com/repos/keenlabs/pushpop/comments{/number}",
101
+ "issue_comment_url": "https://api.github.com/repos/keenlabs/pushpop/issues/comments/{number}",
102
+ "contents_url": "https://api.github.com/repos/keenlabs/pushpop/contents/{+path}",
103
+ "compare_url": "https://api.github.com/repos/keenlabs/pushpop/compare/{base}...{head}",
104
+ "merges_url": "https://api.github.com/repos/keenlabs/pushpop/merges",
105
+ "archive_url": "https://api.github.com/repos/keenlabs/pushpop/{archive_format}{/ref}",
106
+ "downloads_url": "https://api.github.com/repos/keenlabs/pushpop/downloads",
107
+ "issues_url": "https://api.github.com/repos/keenlabs/pushpop/issues{/number}",
108
+ "pulls_url": "https://api.github.com/repos/keenlabs/pushpop/pulls{/number}",
109
+ "milestones_url": "https://api.github.com/repos/keenlabs/pushpop/milestones{/number}",
110
+ "notifications_url": "https://api.github.com/repos/keenlabs/pushpop/notifications{?since,all,participating}",
111
+ "labels_url": "https://api.github.com/repos/keenlabs/pushpop/labels{/name}",
112
+ "releases_url": "https://api.github.com/repos/keenlabs/pushpop/releases{/id}",
113
+ "created_at": "2014-03-30T19:57:28Z",
114
+ "updated_at": "2014-06-09T06:15:31Z",
115
+ "pushed_at": "2014-05-22T00:54:09Z",
116
+ "git_url": "git://github.com/keenlabs/pushpop.git",
117
+ "ssh_url": "git@github.com:keenlabs/pushpop.git",
118
+ "clone_url": "https://github.com/keenlabs/pushpop.git",
119
+ "svn_url": "https://github.com/keenlabs/pushpop",
120
+ "homepage": "",
121
+ "size": 896,
122
+ "stargazers_count": 17,
123
+ "watchers_count": 17,
124
+ "language": "Ruby",
125
+ "has_issues": true,
126
+ "has_downloads": true,
127
+ "has_wiki": true,
128
+ "forks_count": 4,
129
+ "mirror_url": null,
130
+ "open_issues_count": 1,
131
+ "forks": 4,
132
+ "open_issues": 1,
133
+ "watchers": 17,
134
+ "default_branch": "master",
135
+ "organization": {
136
+ "login": "keenlabs",
137
+ "id": 1315418,
138
+ "avatar_url": "https://avatars.githubusercontent.com/u/1315418?",
139
+ "gravatar_id": "b948c4bc2de9618c488431612d2ff99d",
140
+ "url": "https://api.github.com/users/keenlabs",
141
+ "html_url": "https://github.com/keenlabs",
142
+ "followers_url": "https://api.github.com/users/keenlabs/followers",
143
+ "following_url": "https://api.github.com/users/keenlabs/following{/other_user}",
144
+ "gists_url": "https://api.github.com/users/keenlabs/gists{/gist_id}",
145
+ "starred_url": "https://api.github.com/users/keenlabs/starred{/owner}{/repo}",
146
+ "subscriptions_url": "https://api.github.com/users/keenlabs/subscriptions",
147
+ "organizations_url": "https://api.github.com/users/keenlabs/orgs",
148
+ "repos_url": "https://api.github.com/users/keenlabs/repos",
149
+ "events_url": "https://api.github.com/users/keenlabs/events{/privacy}",
150
+ "received_events_url": "https://api.github.com/users/keenlabs/received_events",
151
+ "type": "Organization",
152
+ "site_admin": false
153
+ },
154
+ "network_count": 4,
155
+ "subscribers_count": 15
156
+ }
157
+ ```
158
+ Any of these properties can be accessed by calling the property name on the repository object:
159
+
160
+ ``` ruby
161
+ repository.has_downloads #=> true
162
+ repository.owner.url #=> "https://api.github.com/users/keenlabs"
163
+ ```
164
+
165
+ See the [Github API Documentation](https://developer.github.com/v3) for more information.
166
+
167
+ ### Credits
168
+
169
+ `pushpop-github` uses the excellent [github_api](https://github.com/peter-murach/github) gem to
170
+ communicate with the Github API. It has, like, everything.
171
+
172
+ ### Contributing
173
+
174
+ Please do! Run the specs with rake:
175
+
176
+ ``` shell
177
+ $ bundle exec rake spec
178
+ ```
@@ -0,0 +1,16 @@
1
+ $stdout.sync = true
2
+
3
+ $: << File.join(File.dirname(__FILE__), './lib')
4
+
5
+ begin
6
+ require 'rspec/core/rake_task'
7
+ desc 'Run Rspec unit tests'
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task default: :spec
13
+ rescue LoadError
14
+ end
15
+
16
+
@@ -0,0 +1,43 @@
1
+ require 'pushpop'
2
+ require 'github_api'
3
+
4
+ module Pushpop
5
+
6
+ class Github < Step
7
+
8
+ PLUGIN_NAME = 'github'
9
+
10
+ Pushpop::Job.register_plugin(PLUGIN_NAME, self)
11
+
12
+ attr_accessor :_user
13
+ attr_accessor :_repository
14
+
15
+ def run(last_response=nil, step_responses=nil)
16
+ self.configure(last_response, step_responses)
17
+
18
+ if self._user && self._repository
19
+ get_repository_from_api
20
+ else
21
+ raise 'Please set user and repository fields'
22
+ end
23
+ end
24
+
25
+ def user(user)
26
+ self._user = user
27
+ end
28
+
29
+ def repository(repository)
30
+ self._repository = repository
31
+ end
32
+
33
+ def get_repository_from_api
34
+ ::Github::Repos.new(:user => self._user, :repo => self._repository).get
35
+ end
36
+
37
+ def configure(last_response=nil, step_responses=nil)
38
+ self.instance_exec(last_response, step_responses, &block)
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,5 @@
1
+ module Pushpop
2
+ class Github
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'pushpop-github/version'
4
+
5
+ Gem::Specification.new do |s|
6
+
7
+ s.name = "pushpop-github"
8
+ s.version = Pushpop::Github::VERSION
9
+ s.authors = ["Josh Dzielak"]
10
+ s.email = "josh@keen.io"
11
+ s.homepage = "https://github.com/pushpop-project/pushpop-github"
12
+ s.summary = "Github API plugin for pushpop"
13
+ s.description = "Github API plugin for pushpop"
14
+
15
+ s.add_dependency "pushpop"
16
+ s.add_dependency "github_api"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
23
+
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pushpop::Github do
4
+ it 'should return repository information' do
5
+ step = Pushpop::Github.new do
6
+ user 'keenlabs'
7
+ repository 'pushpop'
8
+ end
9
+ repo = step.run
10
+ repo.language.should == "Ruby"
11
+ end
12
+
13
+ it 'should register as a plugin' do
14
+ github_job = job do
15
+ github do
16
+ user 'keenlabs'
17
+ repository 'pushpop'
18
+ end
19
+ end
20
+ repo, _ = github_job.run
21
+ repo.language.should == "Ruby"
22
+ end
23
+
24
+ it 'should raise an error if repository is not configured' do
25
+ expect {
26
+ step = Pushpop::Github.new do
27
+ user 'keenlabs'
28
+ end
29
+ step.run
30
+ }.to raise_error /Please set/
31
+ end
32
+
33
+ it 'should raise an error if user is not configured' do
34
+ expect {
35
+ step = Pushpop::Github.new do
36
+ repository 'pushpop'
37
+ end
38
+ step.run
39
+ }.to raise_error /Please set/
40
+ end
41
+
42
+ end
@@ -0,0 +1,11 @@
1
+ $: << File.join(File.dirname(__FILE__), '../lib')
2
+
3
+ require 'pushpop'
4
+ require 'pushpop-github'
5
+
6
+ RSpec.configure do |config|
7
+ config.before :each do
8
+ Pushpop.jobs.clear
9
+ end
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pushpop-github
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josh Dzielak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pushpop
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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
+ - !ruby/object:Gem::Dependency
31
+ name: github_api
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Github API plugin for pushpop
47
+ email: josh@keen.io
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - .travis.yml
53
+ - Gemfile
54
+ - Gemfile.lock
55
+ - LICENSE
56
+ - README.md
57
+ - Rakefile
58
+ - lib/pushpop-github.rb
59
+ - lib/pushpop-github/version.rb
60
+ - pushpop-github.gemspec
61
+ - spec/pushpop-github_spec.rb
62
+ - spec/spec_helper.rb
63
+ homepage: https://github.com/pushpop-project/pushpop-github
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.23
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Github API plugin for pushpop
87
+ test_files:
88
+ - spec/pushpop-github_spec.rb
89
+ - spec/spec_helper.rb