buildbox 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/buildbox/api.rb +9 -2
- data/lib/buildbox/cli.rb +32 -5
- data/lib/buildbox/configuration.rb +11 -0
- data/lib/buildbox/server.rb +3 -2
- data/lib/buildbox/version.rb +1 -1
- data/lib/buildbox/worker.rb +1 -1
- data/spec/buildbox/buildbox/api_spec.rb +4 -0
- data/spec/buildbox/buildbox/build_spec.rb +4 -0
- data/spec/buildbox/buildbox/cli_spec.rb +4 -0
- data/spec/buildbox/buildbox/command_spec.rb +6 -0
- data/spec/buildbox/buildbox/configuration_spec.rb +4 -0
- data/spec/buildbox/buildbox/environment_spec.rb +4 -0
- data/spec/buildbox/buildbox/monitor_spec.rb +4 -0
- data/spec/buildbox/buildbox/runner_spec.rb +4 -0
- data/spec/buildbox/buildbox/server_spec.rb +4 -0
- data/spec/buildbox/buildbox/utf8_spec.rb +4 -0
- data/spec/buildbox/buildbox/version_spec.rb +4 -0
- data/spec/buildbox/buildbox/worker_spec.rb +4 -0
- metadata +24 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f35ee004e331b0dc73aaa7810c3205fee9e94e
|
4
|
+
data.tar.gz: e9c09f2b873eaa48ee5a796e0aa5e8fb0ff1b4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9571f31377b47d64915fb3040d21f36c5d980c54acc9fa23c9ee5c3aa05b7c97b5cf80a6940a8be2981b99815d4477d4a362723f527a6100cafdd8c7431c0229
|
7
|
+
data.tar.gz: 84841e7ad0466986a09a699582c74f6414a09be3affd6c1c0a110fb83727aac795a04a770236194660eb8bc8cf947f2e751281b12b89e12a659b57655a490f22
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Add your worker tokens
|
|
12
12
|
|
13
13
|
Then you can start monitoring for builds like so:
|
14
14
|
|
15
|
-
$ buildbox
|
15
|
+
$ buildbox worker:start
|
16
16
|
|
17
17
|
For more help with the command line interface
|
18
18
|
|
@@ -25,3 +25,7 @@ For more help with the command line interface
|
|
25
25
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
26
26
|
4. Push to the branch (`git push origin my-new-feature`)
|
27
27
|
5. Create new Pull Request
|
28
|
+
|
29
|
+
## Copyright
|
30
|
+
|
31
|
+
Copyright (c) 2013 Keith Pitt. See LICENSE for details.
|
data/lib/buildbox/api.rb
CHANGED
@@ -6,10 +6,15 @@ require 'hashie/mash'
|
|
6
6
|
module Buildbox
|
7
7
|
class API
|
8
8
|
def initialize(config = Buildbox.config)
|
9
|
-
@config
|
9
|
+
@config = config
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def authenticate(api_key)
|
13
|
+
@api_key = api_key
|
14
|
+
get("user")
|
15
|
+
end
|
16
|
+
|
17
|
+
def worker(access_token, hostname)
|
13
18
|
put("workers/#{access_token}", :hostname => hostname)
|
14
19
|
end
|
15
20
|
|
@@ -25,6 +30,8 @@ module Buildbox
|
|
25
30
|
|
26
31
|
def connection
|
27
32
|
@connection ||= Faraday.new(:url => @config.api_endpoint) do |faraday|
|
33
|
+
faraday.basic_auth @api_key || @config.api_key, ''
|
34
|
+
|
28
35
|
faraday.request :json
|
29
36
|
|
30
37
|
faraday.response :logger, Buildbox.logger
|
data/lib/buildbox/cli.rb
CHANGED
@@ -9,6 +9,15 @@ module Buildbox
|
|
9
9
|
@commands = {}
|
10
10
|
@options = {}
|
11
11
|
|
12
|
+
@commands['auth:login'] = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: buildbox auth:login"
|
14
|
+
|
15
|
+
opts.on("--help", "You're looking at it.") do
|
16
|
+
puts @commands['auth:login']
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
12
21
|
@commands['worker:start'] = OptionParser.new do |opts|
|
13
22
|
opts.banner = "Usage: buildbox worker:start"
|
14
23
|
|
@@ -18,11 +27,11 @@ module Buildbox
|
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
21
|
-
@commands['worker:
|
22
|
-
opts.banner = "Usage: buildbox worker:
|
30
|
+
@commands['worker:add'] = OptionParser.new do |opts|
|
31
|
+
opts.banner = "Usage: buildbox worker:add [token]"
|
23
32
|
|
24
33
|
opts.on("--help", "You're looking at it.") do
|
25
|
-
puts @commands['worker:
|
34
|
+
puts @commands['worker:add']
|
26
35
|
exit
|
27
36
|
end
|
28
37
|
end
|
@@ -52,7 +61,7 @@ module Buildbox
|
|
52
61
|
|
53
62
|
if command == "worker:start"
|
54
63
|
Buildbox::Server.new.start
|
55
|
-
elsif command == "worker:
|
64
|
+
elsif command == "worker:add"
|
56
65
|
if @argv.length == 0
|
57
66
|
puts "No token provided"
|
58
67
|
exit 1
|
@@ -63,7 +72,25 @@ module Buildbox
|
|
63
72
|
Buildbox.config.update(:worker_access_tokens => worker_access_tokens << access_token)
|
64
73
|
|
65
74
|
puts "Successfully added worker access token"
|
66
|
-
puts "You can now start the worker with
|
75
|
+
puts "You can now start the worker with: buildbox worker:start"
|
76
|
+
elsif command == "auth:login"
|
77
|
+
if @argv.length == 0
|
78
|
+
puts "No api key provided"
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
api_key = @argv.first
|
83
|
+
|
84
|
+
begin
|
85
|
+
Buildbox::API.new.authenticate(api_key)
|
86
|
+
Buildbox.config.update(:api_key => api_key)
|
87
|
+
|
88
|
+
puts "Successfully added your api_key"
|
89
|
+
puts "You can now add workers with: buildbox worker:add [worker_token]"
|
90
|
+
rescue
|
91
|
+
puts "Could not authenticate your api_key"
|
92
|
+
exit 1
|
93
|
+
end
|
67
94
|
end
|
68
95
|
else
|
69
96
|
puts global.help
|
@@ -14,10 +14,21 @@ module Buildbox
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def api_key
|
18
|
+
ENV['BUILDBOX_API_KEY'] || self[:api_key]
|
19
|
+
end
|
20
|
+
|
17
21
|
def api_endpoint
|
18
22
|
ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://api.buildbox.io/v1"
|
19
23
|
end
|
20
24
|
|
25
|
+
def check
|
26
|
+
unless api_key
|
27
|
+
puts "No api_key set. You can set it with\nbuildbox authenticate [api_key]"
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
def update(attributes)
|
22
33
|
attributes.each_pair { |key, value| self[key] = value }
|
23
34
|
save
|
data/lib/buildbox/server.rb
CHANGED
@@ -9,12 +9,13 @@ module Buildbox
|
|
9
9
|
|
10
10
|
def start
|
11
11
|
loop do
|
12
|
+
@config.check
|
13
|
+
@config.reload
|
14
|
+
|
12
15
|
worker_access_tokens.each do |access_token|
|
13
16
|
Buildbox::Worker.new(access_token, api).work
|
14
17
|
end
|
15
18
|
|
16
|
-
@config.reload
|
17
|
-
|
18
19
|
@logger.info "Sleeping for #{INTERVAL} seconds"
|
19
20
|
sleep INTERVAL
|
20
21
|
end
|
data/lib/buildbox/version.rb
CHANGED
data/lib/buildbox/worker.rb
CHANGED
@@ -23,7 +23,7 @@ module Buildbox
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def projects
|
26
|
-
@api.worker(
|
26
|
+
@api.worker(@access_token, hostname).projects
|
27
27
|
rescue Faraday::Error::ClientError
|
28
28
|
warn "Worker #{@access_token} doesn't exist"
|
29
29
|
[] # return empty array to avoid breakage
|
@@ -4,6 +4,12 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
describe Buildbox::Command do
|
6
6
|
describe "#run" do
|
7
|
+
it "is run within a tty" do
|
8
|
+
result = Buildbox::Command.run(%{ruby -e "puts STDOUT.tty?"})
|
9
|
+
|
10
|
+
result.output.should == "true"
|
11
|
+
end
|
12
|
+
|
7
13
|
it "successfully runs and returns the output from a simple comment" do
|
8
14
|
result = Buildbox::Command.run('echo hello world')
|
9
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Pitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -90,7 +90,6 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- .gitignore
|
92
92
|
- .rspec
|
93
|
-
- .ruby-version
|
94
93
|
- Gemfile
|
95
94
|
- Gemfile.lock
|
96
95
|
- LICENSE.txt
|
@@ -111,7 +110,18 @@ files:
|
|
111
110
|
- lib/buildbox/utf8.rb
|
112
111
|
- lib/buildbox/version.rb
|
113
112
|
- lib/buildbox/worker.rb
|
113
|
+
- spec/buildbox/buildbox/api_spec.rb
|
114
|
+
- spec/buildbox/buildbox/build_spec.rb
|
115
|
+
- spec/buildbox/buildbox/cli_spec.rb
|
114
116
|
- spec/buildbox/buildbox/command_spec.rb
|
117
|
+
- spec/buildbox/buildbox/configuration_spec.rb
|
118
|
+
- spec/buildbox/buildbox/environment_spec.rb
|
119
|
+
- spec/buildbox/buildbox/monitor_spec.rb
|
120
|
+
- spec/buildbox/buildbox/runner_spec.rb
|
121
|
+
- spec/buildbox/buildbox/server_spec.rb
|
122
|
+
- spec/buildbox/buildbox/utf8_spec.rb
|
123
|
+
- spec/buildbox/buildbox/version_spec.rb
|
124
|
+
- spec/buildbox/buildbox/worker_spec.rb
|
115
125
|
- spec/fixtures/repo.git/HEAD
|
116
126
|
- spec/fixtures/repo.git/config
|
117
127
|
- spec/fixtures/repo.git/description
|
@@ -162,7 +172,18 @@ signing_key:
|
|
162
172
|
specification_version: 4
|
163
173
|
summary: Ruby client for buildbox
|
164
174
|
test_files:
|
175
|
+
- spec/buildbox/buildbox/api_spec.rb
|
176
|
+
- spec/buildbox/buildbox/build_spec.rb
|
177
|
+
- spec/buildbox/buildbox/cli_spec.rb
|
165
178
|
- spec/buildbox/buildbox/command_spec.rb
|
179
|
+
- spec/buildbox/buildbox/configuration_spec.rb
|
180
|
+
- spec/buildbox/buildbox/environment_spec.rb
|
181
|
+
- spec/buildbox/buildbox/monitor_spec.rb
|
182
|
+
- spec/buildbox/buildbox/runner_spec.rb
|
183
|
+
- spec/buildbox/buildbox/server_spec.rb
|
184
|
+
- spec/buildbox/buildbox/utf8_spec.rb
|
185
|
+
- spec/buildbox/buildbox/version_spec.rb
|
186
|
+
- spec/buildbox/buildbox/worker_spec.rb
|
166
187
|
- spec/fixtures/repo.git/HEAD
|
167
188
|
- spec/fixtures/repo.git/config
|
168
189
|
- spec/fixtures/repo.git/description
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0-p247
|