bimble 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjU4MGVhZmIwNjFkYTMzM2IxNTdhNTFjMzg4NzMwMTExZTAyYjJlNA==
5
+ data.tar.gz: !binary |-
6
+ YTY3OGUzMTJjZGFkMTljOTIyMmExZDZjODJkMzM3YjU4NTE0NzJiNQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OWU0MGJmNWFiYTljY2RlMmQ2MzExNDUwNzJjNzkzYzUyNzMxNjdkNmVlMjFm
10
+ YzQ2NGJmYWNmZGNjZjM5ODU2NGQwM2VmZDdmZmQ0NjM4YTBiYTczYmEzNjMy
11
+ NjlhYzA1NmZiZTdhNTBmNDE2NzYyNGU3N2JmNDI3NGI4OThkNDQ=
12
+ data.tar.gz: !binary |-
13
+ YzA2MWI3ZWMzODc4NmU4M2I0MWZjZTA3NzAxZjE0MTA5ZTJiY2MzZmZkN2Ni
14
+ ZDIwNWZhNDE1OTc1NWUxYjA3MDgwNzBhNGRjNjE5NmEyNmE1Y2Q1NDIwZTlh
15
+ YjcwNmM4MjU1ZjU1YjQ1Y2JhNzgwMTI0ZmJiMGExMjI1MTRjMGY=
@@ -0,0 +1,18 @@
1
+ .env
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,18 @@
1
+ rvm:
2
+ - 2.1.0
3
+ notifications:
4
+ irc:
5
+ channels:
6
+ - irc.freenode.net#theodi
7
+ template:
8
+ - "%{repository} %{branch} - %{message} %{build_url}"
9
+ on_success: change
10
+ on_failure: always
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: cghgQEppfrTSn3EmPqu0k2ZlerVjDdThEjpUtfR/tnMytznBswJeCbvvEPU52TGgWtbvss2PiBTLulmdX5H/L53DxmEpfINcoz75EfzQ03t0abfs7SRRkU+06eg6QUQbMIklDQW7Mm6CcQ1UGvtOOJOoHvITXPkrf69WOLsjDSA=
15
+ gem: bimble
16
+ on:
17
+ tags: true
18
+ repo: theodi/bimble
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #ruby=2.1.0
4
+ #ruby-gemset=bimble
5
+
6
+ # Specify your gem's dependencies in bimble.gemspec
7
+ gemspec
@@ -0,0 +1,10 @@
1
+ The MIT License (MIT)
2
+ ---------------------
3
+
4
+ Copyright (c) 2013 The Open Data Institute
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ # Bimble
2
+
3
+ A gem and executable to check out a repo, run bundle update, then commit and open a PR.
4
+ One more in a long line of robots to make our lives easier.
5
+
6
+ Oh, and it's called `bimble` because I sometimes misspell `bundle` that way.
7
+
8
+ ## License
9
+
10
+ This code is open source under the MIT license. See the LICENSE.md file for
11
+ full details.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'bimble'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install bimble
26
+
27
+ ## Usage
28
+
29
+ You need to be able to clone via SSH from the user the script will run as.
30
+
31
+ Then:
32
+
33
+ ```
34
+ bimble.rb git@github.com:{user}/{repo}.git
35
+ ```
36
+
37
+ Once the bundle is updated, `Gemfile.lock` **only** will be committed on a new
38
+ branch called `update-dependencies-{date}`. If `GITHUB_OAUTH_TOKEN` is set in `.env`,
39
+ a pull request will be automatically opened (see below).
40
+
41
+ Currently, the best way to run it is probably to set up cron jobs to run the above
42
+ command for each of your repositories. The branch name has the date in, so it's probably
43
+ best not to run more than once a day. We make our [Jenkins](http://jenkins.theodi.org)
44
+ build server run all ours once a week.
45
+
46
+ ## Github OAuth Token
47
+
48
+ The following environment variables should be set in a `.env` file in order to use this app.
49
+
50
+ GITHUB_OAUTH_TOKEN='your-oauth-token-for-your-app'
51
+
52
+ To generate this token, run `./generate_oauth_token.rb` and follow the instructions. You'll need
53
+ to be on a machine with a web browser.
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :spec
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bimble/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bimble"
8
+ spec.version = Bimble::VERSION
9
+ spec.authors = ["James Smith"]
10
+ spec.email = ["james@floppy.org.uk"]
11
+ spec.description = %q{Keep your bundles up to date}
12
+ spec.summary = %q{A gem and executable to check out a repo, run bundle update, then commit and open a PR}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'git'
22
+ spec.add_dependency 'dotenv'
23
+ spec.add_dependency 'github_api'
24
+ spec.add_dependency 'launchy'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "travis"
30
+ spec.add_development_dependency "coveralls"
31
+
32
+ end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'git'
4
+ require 'date'
5
+ require 'dotenv'
6
+ require 'github_api'
7
+
8
+ Dotenv.load
9
+
10
+ def do_update(repo)
11
+ if File.exists?("Gemfile")
12
+ `bundle update`
13
+ branch = commit_to_new_branch(repo)
14
+ open_pull_request(repo, branch) if branch
15
+ end
16
+ end
17
+
18
+ def commit_to_new_branch(repo)
19
+ if repo.status.changed.keys.include? "Gemfile.lock"
20
+ branch = "update-dependencies-#{Date.today.to_s}"
21
+ repo.branch(branch).create
22
+ repo.checkout(branch)
23
+ repo.add("Gemfile.lock")
24
+ repo.commit("automatically updated dependencies")
25
+ repo.push("origin", branch)
26
+ branch
27
+ else
28
+ nil
29
+ end
30
+ end
31
+
32
+ def open_pull_request(repo, branch)
33
+ if ENV['GITHUB_OAUTH_TOKEN']
34
+ github = Github.new oauth_token: ENV['GITHUB_OAUTH_TOKEN']
35
+
36
+ matches = repo.remote("origin").url.match(/\A.+:(.+?)\/([^\.]+).*\Z/)
37
+ if matches
38
+ user, repo_name = matches[1], matches[2]
39
+ github.pull_requests.create user, repo_name,
40
+ title: "automatically updated dependencies",
41
+ head: "#{user}:#{branch}",
42
+ base: "master"
43
+ end
44
+ end
45
+ end
46
+
47
+ Dir.mktmpdir do |tmpdir|
48
+ repo = Git.clone(ARGV[0], tmpdir)
49
+ Dir.chdir(tmpdir) do
50
+ do_update(repo)
51
+ end
52
+ end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'launchy'
4
+ require 'github_api'
5
+
6
+ puts <<EOF
7
+ First, we will create a new Github application.
8
+ If you want put it in an organization, change to that section of the settings page first.
9
+ If you already have an application, just skip this part.
10
+ For the callback URL, you can just enter 'http://example.iana.org/'
11
+ Hit enter to open a browser and create your application.
12
+ EOF
13
+ gets
14
+
15
+ Launchy.open "https://github.com/settings/applications/new"
16
+
17
+ print "Enter the client ID: "
18
+ client_id = gets.strip
19
+
20
+ print "Enter the client secret: "
21
+ client_secret = gets.strip
22
+
23
+ github = Github.new :client_id => client_id, :client_secret => client_secret
24
+ auth_url = github.authorize_url :redirect_uri => 'http://example.iana.org/', :scope => 'repo'
25
+
26
+ Launchy.open auth_url
27
+
28
+ print "Authorize the app, then paste the URL of the page Github redirected you to: "
29
+ token_url = gets.strip
30
+
31
+ token = github.get_token(token_url.split('=').last)
32
+
33
+ print <<EOF
34
+ Your OAuth token is #{token.token}.
35
+ If you want me to write this to .env for you, enter 'overwrite' (warning, .env will be overwritten):
36
+ EOF
37
+ response = gets.strip
38
+
39
+ if response == 'overwrite'
40
+ puts 'OK, overwriting .env'
41
+ File.write '.env', "GITHUB_OAUTH_TOKEN='#{token.token}'"
42
+ else
43
+ puts 'OK, skipping .env'
44
+ end
45
+
46
+ puts 'All done, you should be good to go.'
@@ -0,0 +1,5 @@
1
+ require "bimble/version"
2
+
3
+ module Bimble
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Bimble
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bimble
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: github_api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: launchy
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: travis
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Keep your bundles up to date
140
+ email:
141
+ - james@floppy.org.uk
142
+ executables:
143
+ - bimble.rb
144
+ - generate_oauth_token.rb
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - .gitignore
149
+ - .rspec
150
+ - .travis.yml
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - LICENSE.md
154
+ - README.md
155
+ - Rakefile
156
+ - bimble.gemspec
157
+ - bin/bimble.rb
158
+ - bin/generate_oauth_token.rb
159
+ - lib/bimble.rb
160
+ - lib/bimble/version.rb
161
+ - spec/spec_helper.rb
162
+ homepage: ''
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.2.2
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: A gem and executable to check out a repo, run bundle update, then commit
186
+ and open a PR
187
+ test_files:
188
+ - spec/spec_helper.rb