bob_the_builder 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/bobify +136 -0
- data/lib/bob_the_builder/bob.rb +194 -0
- data/lib/bob_the_builder/git_hub_uploader.rb +41 -0
- data/lib/bob_the_builder.rb +20 -0
- data/spec/bob_the_builder_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -0
- metadata +266 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "rspec", "~> 2.3.0"
|
5
|
+
gem "bundler", "~> 1.0.0"
|
6
|
+
gem "jeweler", "~> 1.6.4"
|
7
|
+
gem "rcov", ">= 0"
|
8
|
+
end
|
9
|
+
|
10
|
+
gem 'rest-client', :require => 'rest_client'
|
11
|
+
gem 'json'
|
12
|
+
gem 'git'
|
13
|
+
gem 'zipruby'
|
14
|
+
|
15
|
+
gem 'orderedhash' if RUBY_VERSION < '1.9'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
json (1.6.1)
|
11
|
+
mime-types (1.17.2)
|
12
|
+
orderedhash (0.0.6)
|
13
|
+
rake (0.9.2.2)
|
14
|
+
rcov (0.9.11)
|
15
|
+
rest-client (1.6.7)
|
16
|
+
mime-types (>= 1.16)
|
17
|
+
rspec (2.3.0)
|
18
|
+
rspec-core (~> 2.3.0)
|
19
|
+
rspec-expectations (~> 2.3.0)
|
20
|
+
rspec-mocks (~> 2.3.0)
|
21
|
+
rspec-core (2.3.1)
|
22
|
+
rspec-expectations (2.3.0)
|
23
|
+
diff-lcs (~> 1.1.2)
|
24
|
+
rspec-mocks (2.3.0)
|
25
|
+
zipruby (0.3.6)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 1.0.0)
|
32
|
+
git
|
33
|
+
jeweler (~> 1.6.4)
|
34
|
+
json
|
35
|
+
orderedhash
|
36
|
+
rcov
|
37
|
+
rest-client
|
38
|
+
rspec (~> 2.3.0)
|
39
|
+
zipruby
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ivan Valdes (@ivanvc)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= bob_the_builder
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to bob_the_builder
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Ivan Valdes (@ivanvc). See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "bob_the_builder"
|
18
|
+
gem.homepage = "http://github.com/ivanvc/bob_the_builder"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{one-line summary of your gem}
|
21
|
+
gem.description = %Q{longer description of your gem}
|
22
|
+
gem.email = "ivan@ooyala.com"
|
23
|
+
gem.authors = ["Ivan Valdes (@ivanvc)"]
|
24
|
+
gem.executables = ['bobify']
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
gem.add_dependency 'rest-client'
|
27
|
+
gem.add_dependency 'json'
|
28
|
+
gem.add_dependency 'git'
|
29
|
+
gem.add_dependency 'zipruby'
|
30
|
+
end
|
31
|
+
Jeweler::RubygemsDotOrgTasks.new
|
32
|
+
|
33
|
+
require 'rspec/core'
|
34
|
+
require 'rspec/core/rake_task'
|
35
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
36
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
37
|
+
end
|
38
|
+
|
39
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
40
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
41
|
+
spec.rcov = true
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :spec
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "bob_the_builder #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/bobify
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Mainly based in capistrano's capify
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: #{File.basename($0)} [path]"
|
9
|
+
|
10
|
+
opts.on("-h", "--help", "Displays this help info") do
|
11
|
+
puts opts
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
opts.parse!(ARGV)
|
17
|
+
rescue OptionParser::ParseError => e
|
18
|
+
warn e.message
|
19
|
+
puts opts
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if ARGV.empty?
|
25
|
+
abort "Please specify the directory to bobify, e.g. `#{File.basename($0)} .'"
|
26
|
+
elsif !File.exists?(ARGV.first)
|
27
|
+
abort "`#{ARGV.first}' does not exist."
|
28
|
+
elsif !File.directory?(ARGV.first)
|
29
|
+
abort "`#{ARGV.first}' is not a directory."
|
30
|
+
elsif ARGV.length > 1
|
31
|
+
abort "Too many arguments; please specify only the directory to bobify."
|
32
|
+
end
|
33
|
+
|
34
|
+
def unindent(string)
|
35
|
+
indentation = string[/\A\s*/]
|
36
|
+
string.strip.gsub(/^#{indentation}/, "")
|
37
|
+
end
|
38
|
+
|
39
|
+
files = {
|
40
|
+
"script/config.yml" => (<<-FILE),
|
41
|
+
output: 'builds/example_v{{version}}_{{date}}.sample'
|
42
|
+
build_command: '{{my_cmd}} {{var}} -libs {{lib}} -output {{output}}'
|
43
|
+
my_cmd: bash
|
44
|
+
var: '-c'
|
45
|
+
lib: '~/Code/libs'
|
46
|
+
|
47
|
+
changes_regexp: 'PSE-'
|
48
|
+
github:
|
49
|
+
username: 'github_username'
|
50
|
+
password: 'password'
|
51
|
+
repo: 'owner/repo'
|
52
|
+
|
53
|
+
production:
|
54
|
+
server: user@server:/var/www/prod
|
55
|
+
staging:
|
56
|
+
server: user@server:/var/www/staging
|
57
|
+
daily_build:
|
58
|
+
server: user@server:/var/www/dailies
|
59
|
+
development:
|
60
|
+
output: builds/example.swf
|
61
|
+
lib: 'libs/'
|
62
|
+
server: user@server:/var/www/dev
|
63
|
+
FILE
|
64
|
+
"script/deploy" => unindent(<<-FILE),
|
65
|
+
#!/usr/bin/env ruby
|
66
|
+
require 'rubygems'
|
67
|
+
require 'bob_the_builder'
|
68
|
+
include BobTheBuilder
|
69
|
+
|
70
|
+
# The first argument is the environment, matches the one from the config
|
71
|
+
# file. It also takes two optional arguments, the directory where the git
|
72
|
+
# repo is, defaults to '.'. The last one is the branch that bob should use
|
73
|
+
# defaults to 'master'.
|
74
|
+
builder = Bob.new(ARGV[0] || 'development')
|
75
|
+
builder.build
|
76
|
+
# The deploy option has an optional argument, where this deploy should be
|
77
|
+
# done. Defaults to 'server', but can be 'github'.
|
78
|
+
builder.deploy
|
79
|
+
FILE
|
80
|
+
|
81
|
+
"script/daily_build" => (<<-FILE),
|
82
|
+
#!/usr/bin/env ruby
|
83
|
+
require 'rubygems'
|
84
|
+
require 'bob_the_builder'
|
85
|
+
|
86
|
+
# The first argument is the environment, matches the one from the config
|
87
|
+
# file. It also takes two optional arguments, the directory where the git
|
88
|
+
# repo is, defaults to '.'. The last one is the branch that bob should use
|
89
|
+
# defaults to 'master'.
|
90
|
+
builder = Bob.new('daily_build')
|
91
|
+
include BobTheBuilder
|
92
|
+
|
93
|
+
# We don't want the daily build if there are no changes, or if the source
|
94
|
+
# doesn't compiles.
|
95
|
+
if builder.changes_since_last_version? && builder.build
|
96
|
+
# Bump the version 'patch', 'minor' or 'major'.
|
97
|
+
builder.version_bump! ARGV[0]
|
98
|
+
builder.build
|
99
|
+
# Deploy to the server, and to GitHub.
|
100
|
+
builder.deploy
|
101
|
+
builder.deploy 'github'
|
102
|
+
end
|
103
|
+
FILE
|
104
|
+
"script/build" => unindent(<<-FILE)
|
105
|
+
#!/usr/bin/env ruby
|
106
|
+
require 'rubygems'
|
107
|
+
require 'bob_the_builder'
|
108
|
+
include BobTheBuilder
|
109
|
+
|
110
|
+
# The first argument is the environment, matches the one from the config
|
111
|
+
# file. It also takes two optional arguments, the directory where the git
|
112
|
+
# repo is, defaults to '.'. The last one is the branch that bob should use
|
113
|
+
# defaults to 'master'.
|
114
|
+
Bob.new(ARGV[0] || 'development').build
|
115
|
+
FILE
|
116
|
+
}
|
117
|
+
|
118
|
+
base = ARGV.shift
|
119
|
+
files.each do |file, content|
|
120
|
+
file = File.join(base, file)
|
121
|
+
if File.exists?(file)
|
122
|
+
warn "[skip] '#{file}' already exists"
|
123
|
+
elsif File.exists?(file.downcase)
|
124
|
+
warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
|
125
|
+
else
|
126
|
+
unless File.exists?(File.dirname(file))
|
127
|
+
puts "[add] making directory '#{File.dirname(file)}'"
|
128
|
+
FileUtils.mkdir(File.dirname(file))
|
129
|
+
end
|
130
|
+
puts "[add] writing '#{file}'"
|
131
|
+
File.open(file, "w") { |f| f.write(content) }
|
132
|
+
FileUtils.chmod(0755, file) if File.extname(file).empty?
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
puts "[done] bobified!"
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module BobTheBuilder
|
2
|
+
class Bob
|
3
|
+
attr_reader :output, :environment, :repo
|
4
|
+
|
5
|
+
def initialize(env, repo_location = '.', branch_name = 'master')
|
6
|
+
@environment = env
|
7
|
+
@repo = Git.open(repo_location)
|
8
|
+
if repo.branches.any? { |br| br.name == branch_name }
|
9
|
+
repo.branch(branch_name).checkout
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def version_bump!(change_type)
|
14
|
+
unless type == 'patch' || type == 'minor' || type == 'major'
|
15
|
+
ohai "Change type not recognized selecting 'patch' as default value"
|
16
|
+
type = 'patch'
|
17
|
+
end
|
18
|
+
|
19
|
+
@current_version = next_version(change_type)
|
20
|
+
ohai "Updating git version"
|
21
|
+
repo.add_tag(current_version)
|
22
|
+
repo.push('origin', repo.branch.name, true)
|
23
|
+
ohai "Git version updated to", current_version
|
24
|
+
end
|
25
|
+
|
26
|
+
def build(version = nil)
|
27
|
+
version ||= current_version
|
28
|
+
ohai "Updating submodules..."
|
29
|
+
git('submodule init')
|
30
|
+
git('submodule update')
|
31
|
+
ohai "Submodules updated"
|
32
|
+
|
33
|
+
ohai "Building..."
|
34
|
+
options['date'] = Time.now.strftime("%Y-%m-%d")
|
35
|
+
options['version'] = version
|
36
|
+
FileUtils.mkdir_p(File.dirname(File.expand_path(option('output'))))
|
37
|
+
run option('build_command')
|
38
|
+
|
39
|
+
@output = option('output')
|
40
|
+
ohai "Done! Compiled to", output
|
41
|
+
output
|
42
|
+
end
|
43
|
+
|
44
|
+
def deploy(location = 'server')
|
45
|
+
unless output
|
46
|
+
ohai("In order to deploy there must be at least one build")
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
if location == 'server'
|
51
|
+
upload_to_server
|
52
|
+
elsif location == 'github'
|
53
|
+
upload_to_github
|
54
|
+
else
|
55
|
+
ohai "I don't know how to deploy to", location
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def changes_since_last_version?
|
60
|
+
newer_commits.any? do |commit|
|
61
|
+
commit.message =~ Regexp.new(option('changes_regexp'))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def upload_to_server
|
67
|
+
[option('server')].flatten.compact.each do |server|
|
68
|
+
ohai "Copying build to", server
|
69
|
+
run("scp #{output} #{server}")
|
70
|
+
ohai "Done!"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def upload_to_github
|
75
|
+
unless option('username', 'github') || option('password', 'github') ||
|
76
|
+
option('repo', 'github')
|
77
|
+
ohai "Missing GitHub credentials"
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
81
|
+
ohai "Uploading to GitHub..."
|
82
|
+
uploader = GitHubUploader.new option('username', 'github'),
|
83
|
+
option('password', 'github'), option('repo', 'github')
|
84
|
+
zip = Tempfile.new(File.basename(output))
|
85
|
+
zip.write(buffer_from_output_zip)
|
86
|
+
zip.rewind
|
87
|
+
begin
|
88
|
+
uploader.create(output + '.zip', zip, "v#{current_version}")
|
89
|
+
ensure
|
90
|
+
zip.close
|
91
|
+
zip.unlink
|
92
|
+
end
|
93
|
+
ohai "Done!"
|
94
|
+
end
|
95
|
+
|
96
|
+
def buffer_from_output_zip
|
97
|
+
Zip::Archive.open_buffer(Zip::CREATE) do |ar|
|
98
|
+
base = File.basename(output)
|
99
|
+
if File.directory?(output)
|
100
|
+
ar.add_dir(base)
|
101
|
+
Dir["#{output}/**/*"].each do |f|
|
102
|
+
if File.directory?(f)
|
103
|
+
ar.add_dir([base, File.basename(f)].join('/'))
|
104
|
+
else
|
105
|
+
ar.add_file([base, File.basename(f)].join('/'), f)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
ar.add_file(base, output)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def newer_commits
|
115
|
+
if current_version
|
116
|
+
repo.log.since(current_version)
|
117
|
+
else
|
118
|
+
repo.log
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def next_version(change_type = 'patch')
|
123
|
+
version = current_version.split('.').map(&:to_i) | [0, 0, 0]
|
124
|
+
|
125
|
+
case change_type
|
126
|
+
when 'patch'
|
127
|
+
version[2] += 1
|
128
|
+
when 'minor'
|
129
|
+
version[1] += 1
|
130
|
+
version[2] = 0
|
131
|
+
when 'major'
|
132
|
+
version[0] += 1
|
133
|
+
version[1] = version[2] = 0
|
134
|
+
else
|
135
|
+
return '-1'
|
136
|
+
end
|
137
|
+
|
138
|
+
version[0...3].join('.')
|
139
|
+
end
|
140
|
+
|
141
|
+
def current_version
|
142
|
+
@current_version ||= repo.tags.size.zero? ? '0.0.0' : repo.tags.last.name
|
143
|
+
end
|
144
|
+
|
145
|
+
def options
|
146
|
+
@options ||= begin
|
147
|
+
file = if File.exist?(Dir.pwd + '/config.yml')
|
148
|
+
'config.yml'
|
149
|
+
elsif File.exist?(Dir.pwd + '/script/config.yml')
|
150
|
+
'script/config.yml'
|
151
|
+
else
|
152
|
+
ohai "config.yml should be placed either in where you are running",
|
153
|
+
"this script, or in the script folder."
|
154
|
+
raise
|
155
|
+
end
|
156
|
+
YAML.load(File.read file)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def option(option, namespace = nil)
|
161
|
+
env = namespace || environment
|
162
|
+
option = ENV[[env, option].join('_').upcase] ||
|
163
|
+
ENV[[env, option].join('_').downcase] ||
|
164
|
+
ENV[option.upcase] || ENV[option.downcase] ||
|
165
|
+
!repo.config(['bob', env, option].join('.')).empty? &&
|
166
|
+
repo.config(['bob', env, option].join('.')) ||
|
167
|
+
!repo.config(['bob', option].join('.')).empty? &&
|
168
|
+
repo.config(['bob', option].join('.')) ||
|
169
|
+
options[env] && options[env][option] || options[option]
|
170
|
+
|
171
|
+
return unless option
|
172
|
+
apply_options(option)
|
173
|
+
end
|
174
|
+
|
175
|
+
def apply_options(input)
|
176
|
+
input.gsub(/\{\{([\w-]+)\}\}/) { option $1 }
|
177
|
+
end
|
178
|
+
|
179
|
+
def git(cmd)
|
180
|
+
run('git ' + cmd)
|
181
|
+
end
|
182
|
+
|
183
|
+
def run(cmd)
|
184
|
+
result = `#{cmd}`.chomp
|
185
|
+
raise 'Runtime Error executing command: ' + cmd unless $?.success?
|
186
|
+
|
187
|
+
result
|
188
|
+
end
|
189
|
+
|
190
|
+
def ohai(*msg)
|
191
|
+
puts "=> #{msg.join(' ')}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module BobTheBuilder
|
2
|
+
class GitHubUploader
|
3
|
+
def initialize(username, password, repository)
|
4
|
+
@username = CGI.escape(username)
|
5
|
+
@password = CGI.escape(password)
|
6
|
+
@repository = repository
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(filename, file, description)
|
10
|
+
url = "https://%s:%s@api.github.com/repos/%s/downloads" %
|
11
|
+
[@username, @password, @repository]
|
12
|
+
params = { 'name' => File.basename(filename),
|
13
|
+
'size' => File.size(file.path),
|
14
|
+
'description' => description }
|
15
|
+
response = RestClient.post(url, params.to_json)
|
16
|
+
upload_to_s3(JSON.parse(response.body), file)
|
17
|
+
rescue
|
18
|
+
puts $!.inspect
|
19
|
+
raise
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def upload_to_s3(response, file)
|
24
|
+
params = RUBY_VERSION < "1.9" ? OrderedHash.new : {}
|
25
|
+
params['key'] = response['path']
|
26
|
+
params['acl'] = response['acl']
|
27
|
+
params['success_action_status'] = 201
|
28
|
+
params['Filename'] = response['name']
|
29
|
+
params['AWSAccessKeyId'] = response['accesskeyid']
|
30
|
+
params['Policy'] = response['policy']
|
31
|
+
params['Signature'] = response['signature']
|
32
|
+
params['Content-Type'] = response['mime_type']
|
33
|
+
params['file'] = file
|
34
|
+
params[:multipart] = true
|
35
|
+
RestClient.post(response['s3_url'], params)
|
36
|
+
rescue
|
37
|
+
puts $!.inspect
|
38
|
+
raise
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# From ruby-git
|
2
|
+
# Add the directory containing this file to the start of the load path if it
|
3
|
+
# # isn't there already.
|
4
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
5
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
6
|
+
|
7
|
+
require 'cgi'
|
8
|
+
require 'yaml'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
require 'rest_client'
|
12
|
+
require 'json'
|
13
|
+
require 'git'
|
14
|
+
require 'zipruby'
|
15
|
+
|
16
|
+
require 'bob_the_builder/bob'
|
17
|
+
require 'bob_the_builder/git_hub_uploader'
|
18
|
+
|
19
|
+
module BobTheBuilder
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'bob_the_builder'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,266 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bob_the_builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ivan Valdes (@ivanvc)
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-11-04 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
requirement: *id001
|
32
|
+
prerelease: false
|
33
|
+
name: rest-client
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
hash: 3
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
requirement: *id002
|
46
|
+
prerelease: false
|
47
|
+
name: json
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
requirement: *id003
|
60
|
+
prerelease: false
|
61
|
+
name: git
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
type: :runtime
|
73
|
+
requirement: *id004
|
74
|
+
prerelease: false
|
75
|
+
name: zipruby
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :runtime
|
87
|
+
requirement: *id005
|
88
|
+
prerelease: false
|
89
|
+
name: orderedhash
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 2
|
99
|
+
- 3
|
100
|
+
- 0
|
101
|
+
version: 2.3.0
|
102
|
+
type: :development
|
103
|
+
requirement: *id006
|
104
|
+
prerelease: false
|
105
|
+
name: rspec
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 23
|
113
|
+
segments:
|
114
|
+
- 1
|
115
|
+
- 0
|
116
|
+
- 0
|
117
|
+
version: 1.0.0
|
118
|
+
type: :development
|
119
|
+
requirement: *id007
|
120
|
+
prerelease: false
|
121
|
+
name: bundler
|
122
|
+
- !ruby/object:Gem::Dependency
|
123
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ~>
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 7
|
129
|
+
segments:
|
130
|
+
- 1
|
131
|
+
- 6
|
132
|
+
- 4
|
133
|
+
version: 1.6.4
|
134
|
+
type: :development
|
135
|
+
requirement: *id008
|
136
|
+
prerelease: false
|
137
|
+
name: jeweler
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
type: :development
|
149
|
+
requirement: *id009
|
150
|
+
prerelease: false
|
151
|
+
name: rcov
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
version: "0"
|
162
|
+
type: :runtime
|
163
|
+
requirement: *id010
|
164
|
+
prerelease: false
|
165
|
+
name: rest-client
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 3
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
version: "0"
|
176
|
+
type: :runtime
|
177
|
+
requirement: *id011
|
178
|
+
prerelease: false
|
179
|
+
name: json
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
version_requirements: &id012 !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
hash: 3
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
version: "0"
|
190
|
+
type: :runtime
|
191
|
+
requirement: *id012
|
192
|
+
prerelease: false
|
193
|
+
name: git
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
version_requirements: &id013 !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
hash: 3
|
201
|
+
segments:
|
202
|
+
- 0
|
203
|
+
version: "0"
|
204
|
+
type: :runtime
|
205
|
+
requirement: *id013
|
206
|
+
prerelease: false
|
207
|
+
name: zipruby
|
208
|
+
description: longer description of your gem
|
209
|
+
email: ivan@ooyala.com
|
210
|
+
executables:
|
211
|
+
- bobify
|
212
|
+
extensions: []
|
213
|
+
|
214
|
+
extra_rdoc_files:
|
215
|
+
- LICENSE.txt
|
216
|
+
- README.rdoc
|
217
|
+
files:
|
218
|
+
- .document
|
219
|
+
- .rspec
|
220
|
+
- Gemfile
|
221
|
+
- Gemfile.lock
|
222
|
+
- LICENSE.txt
|
223
|
+
- README.rdoc
|
224
|
+
- Rakefile
|
225
|
+
- VERSION
|
226
|
+
- bin/bobify
|
227
|
+
- lib/bob_the_builder.rb
|
228
|
+
- lib/bob_the_builder/bob.rb
|
229
|
+
- lib/bob_the_builder/git_hub_uploader.rb
|
230
|
+
- spec/bob_the_builder_spec.rb
|
231
|
+
- spec/spec_helper.rb
|
232
|
+
homepage: http://github.com/ivanvc/bob_the_builder
|
233
|
+
licenses:
|
234
|
+
- MIT
|
235
|
+
post_install_message:
|
236
|
+
rdoc_options: []
|
237
|
+
|
238
|
+
require_paths:
|
239
|
+
- lib
|
240
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
hash: 3
|
246
|
+
segments:
|
247
|
+
- 0
|
248
|
+
version: "0"
|
249
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
|
+
none: false
|
251
|
+
requirements:
|
252
|
+
- - ">="
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
hash: 3
|
255
|
+
segments:
|
256
|
+
- 0
|
257
|
+
version: "0"
|
258
|
+
requirements: []
|
259
|
+
|
260
|
+
rubyforge_project:
|
261
|
+
rubygems_version: 1.8.5
|
262
|
+
signing_key:
|
263
|
+
specification_version: 3
|
264
|
+
summary: one-line summary of your gem
|
265
|
+
test_files: []
|
266
|
+
|