buildbox 0.2 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7056fe7aa77fdbeac77396ab8bb9939e6fa63e8
4
- data.tar.gz: f994d5019faba63cc0840248974183777757be4a
3
+ metadata.gz: d5f35ee004e331b0dc73aaa7810c3205fee9e94e
4
+ data.tar.gz: e9c09f2b873eaa48ee5a796e0aa5e8fb0ff1b4c7
5
5
  SHA512:
6
- metadata.gz: 39b14fa4bbfa431c6c918b08c8c23570bc39473432b8e7caa331a57ea2d816ef0f7ae7035bae57473aad3b8ee143816f8f41e1a4e4d3433afbb1b2e2af9b5f68
7
- data.tar.gz: eb8ab79fe1c7c55ac9492297f4cd5b88fe69e1c76af611854e5f2630f7bc5be386acc479bd34cbba65d9655e47dc8ac2dc9bd4a7e16e1e2664a1353f5a8a01ec
6
+ metadata.gz: 9571f31377b47d64915fb3040d21f36c5d980c54acc9fa23c9ee5c3aa05b7c97b5cf80a6940a8be2981b99815d4477d4a362723f527a6100cafdd8c7431c0229
7
+ data.tar.gz: 84841e7ad0466986a09a699582c74f6414a09be3affd6c1c0a110fb83727aac795a04a770236194660eb8bc8cf947f2e751281b12b89e12a659b57655a490f22
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildbox (0.2)
4
+ buildbox (0.2.1)
5
5
  celluloid (~> 0.14)
6
6
  faraday (~> 0.8)
7
7
  faraday_middleware (~> 0.9)
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 server:start
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.
@@ -6,10 +6,15 @@ require 'hashie/mash'
6
6
  module Buildbox
7
7
  class API
8
8
  def initialize(config = Buildbox.config)
9
- @config = config
9
+ @config = config
10
10
  end
11
11
 
12
- def worker(access_token: access_token, hostname: hostname)
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
@@ -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:setup'] = OptionParser.new do |opts|
22
- opts.banner = "Usage: buildbox worker:setup [token]"
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:setup']
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:setup"
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 `buildbox worker:start`"
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Buildbox
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -23,7 +23,7 @@ module Buildbox
23
23
  private
24
24
 
25
25
  def projects
26
- @api.worker(:access_token => @access_token, :hostname => hostname).projects
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
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::API do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Build do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::CLI do
4
+ end
@@ -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
 
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Configuration do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Environment do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Monitor do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Runner do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Server do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::UTF8 do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::VERSION do
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Buildbox::Worker do
4
+ end
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: '0.2'
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-08-30 00:00:00.000000000 Z
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
@@ -1 +0,0 @@
1
- 2.0.0-p247