semaphoreapp 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTMwZjlmZmJkMjkzMGRkYzhhYjE3MjNhYWY5ZWFiMzE0NDU3YTg0OA==
5
+ data.tar.gz: !binary |-
6
+ NzcyOGRmYTU4MjliNTNkOTRmYzE1OTUzMmJiOTE4Nzk5MDRhMzY3ZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjJjMmQwNmM2NGFlNDI3ZDBkNzg5OTMzYjkyOWM4N2EwMzVlMmIwZGU4ZGY5
10
+ MzQxMDUyNTU4MjgxMTk5NDRkNGNhYzAyNGM5YTMzZjNjNzVmNzlmNzk4NmM2
11
+ NTBiNjY0NGZhNWVhNWJiYmEwMjBhYjc5NDk1NDg4MWFjZGJiN2Q=
12
+ data.tar.gz: !binary |-
13
+ NTFmMWZhOGZmZmJkZjlhYzYxNWJkMDZiNWY5ZmUyMGVhMGY0NTIyN2EwNGY5
14
+ MDhiY2E3YTYzOTFjNDJhNjkxYmU4NTY4YjUwNjIwNDNkYjdhM2ZhMTUzNDkx
15
+ N2QwNTM5YmVkY2Y1NDM1MDkxNTVlY2ViNmJjYTdkZmQzMzI0OWE=
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Semaphoreapp gem changelog
2
+
3
+ ## 0.2.0
4
+
5
+ Added support for new API endpoints `build_information` and `build_log`
6
+
7
+ ## 0.1.1
8
+
9
+ Bugfixes
10
+
11
+ ## 0.1.0
12
+
13
+ First implementation
data/README.md CHANGED
@@ -78,6 +78,30 @@ or its build history:
78
78
  branch.get_builds
79
79
  ```
80
80
 
81
+ ### Builds
82
+
83
+ Note that the following examples assume you already have a `build` object, which you can obtain by doing something like:
84
+
85
+ ```ruby
86
+ build = Semaphoreapp::Branch.find_by_name('3f1004b8343faabda63d441734526c854380ab89', 'master').get_builds.first
87
+ ```
88
+
89
+ To get the build information:
90
+
91
+ ```ruby
92
+ build.get_information
93
+ ```
94
+
95
+ This will return a `BuildInformation` instance which in turn contains a list of `Commit` instances.
96
+
97
+ To get the build log:
98
+
99
+ ```ruby
100
+ build.get_log
101
+ ```
102
+
103
+ This will return a `BuildLog` instance which in turn contains a list of `Thread` instances. Each of the threads contains a list of `Command` instances.
104
+
81
105
  ## Object model
82
106
 
83
107
  The gem uses classes to represent objects returned by API calls. The classes are:
@@ -87,6 +111,10 @@ The gem uses classes to represent objects returned by API calls. The classes are
87
111
  * `Branch`: a branch in a project.
88
112
  * `Build`: a CI build. It may have a `Commit` object.
89
113
  * `Commit`: a Git commit.
114
+ * `BuildInformation`: the information related to a build. It may have many `Commit` objects.
115
+ * `BuildLog`: the log for a build. It may have many `Thread` objects.
116
+ * `Thread`: a build thread. It may have many `Command` objects.
117
+ * `Command`: a command in a build thread.
90
118
 
91
119
  ## Tests
92
120
 
data/lib/semaphoreapp.rb CHANGED
@@ -10,9 +10,13 @@ require "semaphoreapp/base"
10
10
  require "semaphoreapp/branch"
11
11
  require "semaphoreapp/branch_status"
12
12
  require "semaphoreapp/build"
13
+ require "semaphoreapp/build_information"
14
+ require "semaphoreapp/build_log"
15
+ require "semaphoreapp/command"
13
16
  require "semaphoreapp/commit"
14
17
  require "semaphoreapp/json_api"
15
18
  require "semaphoreapp/project"
19
+ require "semaphoreapp/thread"
16
20
  require "semaphoreapp/version"
17
21
 
18
22
  module Semaphoreapp
@@ -25,6 +25,16 @@ module Semaphoreapp
25
25
  send_request(branch_status_url(project_hash_id, id)).body
26
26
  end
27
27
 
28
+ def self.get_build_information(project_hash_id, id, build_number, options={})
29
+ set_auth_token(options)
30
+ send_request(build_information_url(project_hash_id, id, build_number)).body
31
+ end
32
+
33
+ def self.get_build_log(project_hash_id, id, build_number, options={})
34
+ set_auth_token(options)
35
+ send_request(build_log_url(project_hash_id, id, build_number)).body
36
+ end
37
+
28
38
  def self.projects_url
29
39
  url_with_auth_token("#{API_URL}/projects")
30
40
  end
@@ -41,6 +51,14 @@ module Semaphoreapp
41
51
  url_with_auth_token("#{API_URL}/projects/#{project_hash_id}/#{id}/status")
42
52
  end
43
53
 
54
+ def self.build_information_url(project_hash_id, id, build_number)
55
+ url_with_auth_token("#{API_URL}/projects/#{project_hash_id}/#{id}/builds/#{build_number}")
56
+ end
57
+
58
+ def self.build_log_url(project_hash_id, id, build_number)
59
+ url_with_auth_token("#{API_URL}/projects/#{project_hash_id}/#{id}/builds/#{build_number}/log")
60
+ end
61
+
44
62
  def self.url_with_auth_token(url, options={})
45
63
  "/#{url}?auth_token=#{Semaphoreapp.auth_token}" << begin
46
64
  options[:page].nil? ? '' : "&page=#{options[:page]}"
@@ -12,7 +12,7 @@ module Semaphoreapp
12
12
 
13
13
  private
14
14
 
15
- def self.build_from_hash(source_hash, &block)
15
+ def self.build_from_hash(source_hash, *params, &block)
16
16
  self.new(
17
17
  source_hash.dup.tap do |hash|
18
18
  block.call(hash) unless block.nil?
@@ -7,7 +7,7 @@ module Semaphoreapp
7
7
 
8
8
  def get_builds
9
9
  history = Semaphoreapp::JsonApi.get_branch_history(project_hash_id, id)
10
- Semaphoreapp::Build.build(history['builds'])
10
+ Semaphoreapp::Build.build(history['builds'], project_hash_id, id)
11
11
  end
12
12
 
13
13
  def self.find(project_hash_id, branch_id)
@@ -1,11 +1,30 @@
1
1
  module Semaphoreapp
2
2
  class Build < Base
3
3
 
4
+ def get_information
5
+ Semaphoreapp::BuildInformation.build(
6
+ Semaphoreapp::JsonApi.get_build_information(project_hash_id, branch_id, build_number)
7
+ )
8
+ end
9
+
10
+ def get_log
11
+ Semaphoreapp::BuildLog.build(
12
+ Semaphoreapp::JsonApi.get_build_log(project_hash_id, branch_id, build_number)
13
+ )
14
+ end
15
+
16
+ def self.build(source, project_hash_id, branch_id)
17
+ super(source, project_hash_id, branch_id)
18
+ end
19
+
20
+
4
21
  private
5
22
 
6
- def self.build_from_hash(build)
23
+ def self.build_from_hash(build, project_hash_id, branch_id)
7
24
  super do |hash|
8
25
  hash['commit'] = Semaphoreapp::Commit.build(hash['commit'])
26
+ hash['project_hash_id'] = project_hash_id
27
+ hash['branch_id'] = branch_id
9
28
  end
10
29
  end
11
30
 
@@ -0,0 +1,14 @@
1
+ module Semaphoreapp
2
+ class BuildInformation < Base
3
+
4
+
5
+ private
6
+
7
+ def self.build_from_hash(build_information)
8
+ super do |hash|
9
+ hash['commits'] = Semaphoreapp::Commit.build(hash['commits'])
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Semaphoreapp
2
+ class BuildLog < Base
3
+
4
+
5
+ private
6
+
7
+ def self.build_from_hash(threads)
8
+ super do |hash|
9
+ hash['threads'] = Semaphoreapp::Thread.build(hash['threads'])
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Semaphoreapp
2
+ class Command < Base
3
+
4
+ end
5
+ end
@@ -16,6 +16,14 @@ module Semaphoreapp
16
16
  raise_if_error(JSON.parse(super))
17
17
  end
18
18
 
19
+ def self.get_build_information(project_hash_id, id, build_number, options={})
20
+ raise_if_error(JSON.parse(super))
21
+ end
22
+
23
+ def self.get_build_log(project_hash_id, id, build_number, options={})
24
+ raise_if_error(JSON.parse(super))
25
+ end
26
+
19
27
 
20
28
  private
21
29
 
@@ -0,0 +1,14 @@
1
+ module Semaphoreapp
2
+ class Thread < Base
3
+
4
+
5
+ private
6
+
7
+ def self.build_from_hash(branch_status)
8
+ super do |hash|
9
+ hash['commands'] = Semaphoreapp::Command.build(hash['commands'])
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Semaphoreapp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,21 @@
1
+ {
2
+ "branch_name": "gem_updates",
3
+ "branch_url": "https://semaphoreapp.com/projects/44/branches/50",
4
+ "branch_status_url": "https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/89/status?auth_token=Yds3w6o26FLfJTnVK2y9",
5
+ "branch_history_url": "https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/89?auth_token=Yds3w6o26FLfJTnVK2y9",
6
+ "project_name": "base-app",
7
+ "build_url": "https://semaphoreapp.com/projects/44/branches/50/builds/15",
8
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/89/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9",
9
+ "build_number": 15,
10
+ "result": "passed",
11
+ "started_at": "2012-07-09T15:23:53Z",
12
+ "finished_at": "2012-07-09T15:30:16Z",
13
+ "commit": {
14
+ "id": "dc395381e650f3bac18457909880829fc20e34ba",
15
+ "url": "https://github.com/renderedtext/base-app/commit/dc395381e650f3bac18457909880829fc20e34ba",
16
+ "author_name": "Vladimir Saric",
17
+ "author_email": "vladimir@renderedtext.com",
18
+ "message": "Update 'shoulda' gem.",
19
+ "timestamp": "2012-07-04T18:14:08Z"
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "commits": [
3
+ {
4
+ "id": "47b51ec00ce04dd78fdefe65428e4216580ce89a",
5
+ "url": "https://github.com/renderedtext/base-app/commit/47b51ec00ce04dd78fdefe65428e4216580ce89a",
6
+ "author_name": "Marko Anastasov",
7
+ "author_email": "marko@renderedtext.com",
8
+ "message": "Update cucumber and related stuff.",
9
+ "timestamp": "2013-03-18T09:59:29Z"
10
+ }
11
+ ],
12
+ "project_name": "base-app",
13
+ "branch_name": "master",
14
+ "number": 1,
15
+ "result": "passed",
16
+ "created_at": "2013-03-18T10:40:13Z",
17
+ "updated_at": "2013-03-18T10:51:27Z",
18
+ "started_at": "2013-03-18T10:40:20Z",
19
+ "finished_at": "2013-03-18T10:51:26Z",
20
+ "html_url": "https://semaphoreapp.com/projects/653/branches/4204/builds/26"
21
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "threads": [
3
+ {
4
+ "number": 1,
5
+ "commands": [
6
+ {
7
+ "name": "bundle install --deployment --path vendor/bundle",
8
+ "result": "0",
9
+ "output": "Fetching source index from http://rubygems.org/ Installing rake (10.0.3) Installing i18n (0.6.1) Installing multi_json (1.6.1) Installing activesupport (3.2.11) Installing builder (3.0.4) Installing activemodel (3.2.11) Installing erubis (2.7.0) Installing journey (1.0.4) Installing rack (1.4.5) Installing rack-cache (1.2) Installing rack-test (0.6.2) Installing hike (1.2.1) Installing tilt (1.3.3) Installing sprockets (2.2.2) Installing actionpack (3.2.11) Installing mime-types (1.21) Installing polyglot (0.3.3) Installing treetop (1.4.12) Installing mail (2.4.4) Installing actionmailer (3.2.11) Installing arel (3.0.2) Installing tzinfo (0.3.35) Installing activerecord (3.2.11) Installing activeresource (3.2.11) Installing addressable (2.3.3) Installing kaminari (0.14.1) Installing polyamorous (0.5.0) Installing meta_search (1.1.3) Using bundler (1.3.0) Installing rack-ssl (1.3.2) Installing json (1.7.7)",
10
+ "start_time": "2013-03-12T09:24:30Z",
11
+ "finish_time": "2013-03-12T09:24:37Z",
12
+ "duration": "00:45"
13
+ },
14
+ {
15
+ "name": "gem --version",
16
+ "result": "0",
17
+ "output": "1.8.23",
18
+ "start_time": "2013-03-12T09:25:30Z",
19
+ "finish_time": "2013-03-12T09:25:37Z",
20
+ "duration": "00:00"
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "number": 2,
26
+ "commands": [
27
+ {
28
+ "name": "bundle exec rake db:test:prepare",
29
+ "result": "0",
30
+ "output": "",
31
+ "start_time": "2013-03-12T09:24:37Z",
32
+ "finish_time": "2013-03-12T09:24:44Z",
33
+ "duration": "00:07"
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9"
39
+ }
@@ -1,6 +1,7 @@
1
1
  [
2
2
  {
3
- "build_url": "http://semaphoreapp.com/projects/57/branches/80/builds/46",
3
+ "build_url": "https://semaphoreapp.com/projects/57/branches/80/builds/46",
4
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/80/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9",
4
5
  "build_number": 46,
5
6
  "result": "failed",
6
7
  "started_at": "2012-10-02T15:01:41Z",
@@ -15,7 +16,8 @@
15
16
  }
16
17
  },
17
18
  {
18
- "build_url": "http://semaphoreapp.com/projects/57/branches/80/builds/45",
19
+ "build_url": "https://semaphoreapp.com/projects/57/branches/80/builds/45",
20
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/80/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9",
19
21
  "build_number": 45,
20
22
  "result": "passed",
21
23
  "started_at": "2012-10-02T14:47:06Z",
@@ -9,11 +9,12 @@
9
9
  "branches": [
10
10
  {
11
11
  "branch_name": "master",
12
- "branch_url": "http://10.0.1.76:3000/projects/61/branches/85",
13
- "branch_status_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/status?auth_token=Yds3w6o26FLfJTnVK2y9",
14
- "branch_history_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85?auth_token=Yds3w6o26FLfJTnVK2y9",
12
+ "branch_url": "https://semaphoreapp.com/projects/61/branches/85",
13
+ "branch_status_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/status?auth_token=Yds3w6o26FLfJTnVK2y9",
14
+ "branch_history_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85?auth_token=Yds3w6o26FLfJTnVK2y9",
15
15
  "project_name": "testapp-sphinx",
16
- "build_url": "http://10.0.1.76:3000/projects/61/branches/85/builds/1",
16
+ "build_url": "https://semaphoreapp.com/projects/61/branches/85/builds/1",
17
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9",
17
18
  "build_number": 1,
18
19
  "result": "passed",
19
20
  "started_at": "2012-09-04T11:55:07Z",
@@ -31,11 +32,12 @@
31
32
  "branches": [
32
33
  {
33
34
  "branch_name": "mongoid3",
34
- "branch_url": "http://10.0.1.76:3000/projects/63/branches/89",
35
- "branch_status_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/status?auth_token=Yds3w6o26FLfJTnVK2y9",
36
- "branch_history_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85?auth_token=Yds3w6o26FLfJTnVK2y9",
35
+ "branch_url": "https://semaphoreapp.com/projects/63/branches/89",
36
+ "branch_status_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/status?auth_token=Yds3w6o26FLfJTnVK2y9",
37
+ "branch_history_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85?auth_token=Yds3w6o26FLfJTnVK2y9",
37
38
  "project_name": "testapp-mongodb",
38
- "build_url": "http://10.0.1.76:3000/projects/63/branches/89/builds/3",
39
+ "build_url": "https://semaphoreapp.com/projects/63/branches/89/builds/3",
40
+ "build_info_url": "https://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/builds/1?auth_token=Yds3w6o26FLfJTnVK2y9",
39
41
  "build_number": 3,
40
42
  "result": "passed",
41
43
  "started_at": "2012-09-14T11:11:39Z",
@@ -6,7 +6,7 @@ describe Semaphoreapp::BranchStatus do
6
6
 
7
7
  context "with a hash" do
8
8
 
9
- let(:test_hash){ fixture(:branch_statuses).first }
9
+ let(:test_hash){ fixture(:branch_status) }
10
10
  subject{ Semaphoreapp::BranchStatus.build(test_hash) }
11
11
 
12
12
  it "should call build_from_hash" do
@@ -16,28 +16,16 @@ describe Semaphoreapp::BranchStatus do
16
16
 
17
17
  end
18
18
 
19
- context "with an array" do
20
-
21
- let(:test_array){ fixture(:branch_statuses) }
22
- subject{ Semaphoreapp::BranchStatus.build(test_array) }
23
-
24
- it "should call build_from_array" do
25
- Semaphoreapp::BranchStatus.should_receive(:build_from_array).with(test_array)
26
- subject
27
- end
28
-
29
- end
30
-
31
19
  end
32
20
 
33
21
  describe ".build_from_hash" do
34
22
 
35
- let(:test_hash){ fixture(:branch_statuses).first }
23
+ let(:test_hash){ fixture(:branch_status) }
36
24
  subject{ Semaphoreapp::BranchStatus.build_from_hash(test_hash) }
37
25
 
38
26
  it{ should be_an_instance_of Semaphoreapp::BranchStatus }
39
27
 
40
- fixture(:branch_statuses).first.reject{ |key| key == 'commit' }.each do |key, value|
28
+ fixture(:branch_status).reject{ |key| key == 'commit' }.each do |key, value|
41
29
  it "should have attribute #{key}" do
42
30
  subject.send(key).should == value
43
31
  end
@@ -58,21 +46,4 @@ describe Semaphoreapp::BranchStatus do
58
46
 
59
47
  end
60
48
 
61
- describe ".build_from_array" do
62
-
63
- let(:test_array){ fixture(:branch_statuses) }
64
- subject{ Semaphoreapp::BranchStatus.build_from_array(test_array) }
65
-
66
- it{ should be_an_instance_of Array }
67
-
68
- it "should call build_from_hash for all the hashes in the array" do
69
- test_array.each do |test_hash|
70
- Semaphoreapp::BranchStatus.should_receive(:build_from_hash).with(test_hash)
71
- end
72
-
73
- subject
74
- end
75
-
76
- end
77
-
78
49
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Semaphoreapp::BuildInformation do
4
+
5
+ describe ".build" do
6
+
7
+ context "with a hash" do
8
+
9
+ let(:test_hash){ fixture(:build_information) }
10
+ subject{ Semaphoreapp::BuildInformation.build(test_hash) }
11
+
12
+ it "should call build_from_hash" do
13
+ Semaphoreapp::BuildInformation.should_receive(:build_from_hash).with(test_hash)
14
+ subject
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ describe ".build_from_hash" do
22
+
23
+ let(:test_hash){ fixture(:build_information) }
24
+ subject{ Semaphoreapp::BuildInformation.build_from_hash(test_hash) }
25
+
26
+ it{ should be_an_instance_of Semaphoreapp::BuildInformation }
27
+
28
+ fixture(:build_information).reject{ |key| key == 'commits' }.each do |key, value|
29
+ it "should have attribute #{key}" do
30
+ subject.send(key).should == value
31
+ end
32
+ end
33
+
34
+ context "with commits" do
35
+ it "should have an array as the commits attribute" do
36
+ subject.commits.should be_an_instance_of Array
37
+ end
38
+
39
+ it "should contain Commit objects" do
40
+ subject.commits.map(&:class).uniq.should == [Semaphoreapp::Commit]
41
+ end
42
+ end
43
+
44
+ context "without commits" do
45
+ before{ test_hash.delete('commits') }
46
+ it "should set the commits attribute to nil" do
47
+ subject.commits.should be_nil
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Semaphoreapp::BuildLog do
4
+
5
+ describe ".build" do
6
+
7
+ context "with a hash" do
8
+
9
+ let(:test_hash){ fixture(:build_log) }
10
+ subject{ Semaphoreapp::BuildLog.build(test_hash) }
11
+
12
+ it "should call build_from_hash" do
13
+ Semaphoreapp::BuildLog.should_receive(:build_from_hash).with(test_hash)
14
+ subject
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ describe ".build_from_hash" do
22
+
23
+ let(:test_hash){ fixture(:build_log) }
24
+ subject{ Semaphoreapp::BuildLog.build_from_hash(test_hash) }
25
+
26
+ it{ should be_an_instance_of Semaphoreapp::BuildLog }
27
+
28
+ fixture(:build_log).reject{ |key| key == 'threads' }.each do |key, value|
29
+ it "should have attribute #{key}" do
30
+ subject.send(key).should == value
31
+ end
32
+ end
33
+
34
+ context "with threads" do
35
+ it "should have an array as the threads attribute" do
36
+ subject.threads.should be_an_instance_of Array
37
+ end
38
+
39
+ it "should contain Thread objects" do
40
+ subject.threads.map(&:class).uniq.should == [Semaphoreapp::Thread]
41
+ end
42
+ end
43
+
44
+ context "without threads" do
45
+ before{ test_hash.delete('threads') }
46
+ it "should set the threads attribute to nil" do
47
+ subject.threads.should be_nil
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -3,26 +3,32 @@ require 'spec_helper'
3
3
  describe Semaphoreapp::Build do
4
4
 
5
5
  describe ".build" do
6
+ let(:test_source){ { } }
7
+ subject{ Semaphoreapp::Build.build(test_source, 'project_hash_id', 'branch_id') }
6
8
 
7
- context "with a hash" do
9
+ it "should persist project_hash_id" do
10
+ subject.project_hash_id.should == 'project_hash_id'
11
+ end
12
+
13
+ it "should persist branch_id" do
14
+ subject.branch_id.should == 'branch_id'
15
+ end
8
16
 
9
- let(:test_hash){ fixture(:builds).first }
10
- subject{ Semaphoreapp::Build.build(test_hash) }
17
+ context "with a hash" do
18
+ let(:test_source){ fixture(:builds).first }
11
19
 
12
20
  it "should call build_from_hash" do
13
- Semaphoreapp::Build.should_receive(:build_from_hash).with(test_hash)
21
+ Semaphoreapp::Build.should_receive(:build_from_hash).with(test_source, 'project_hash_id', 'branch_id')
14
22
  subject
15
23
  end
16
24
 
17
25
  end
18
26
 
19
27
  context "with an array" do
20
-
21
- let(:test_array){ fixture(:builds) }
22
- subject{ Semaphoreapp::Build.build(test_array) }
28
+ let(:test_source){ fixture(:builds) }
23
29
 
24
30
  it "should call build_from_array" do
25
- Semaphoreapp::Build.should_receive(:build_from_array).with(test_array)
31
+ Semaphoreapp::Build.should_receive(:build_from_array).with(test_source, 'project_hash_id', 'branch_id')
26
32
  subject
27
33
  end
28
34
 
@@ -33,7 +39,7 @@ describe Semaphoreapp::Build do
33
39
  describe ".build_from_hash" do
34
40
 
35
41
  let(:test_hash){ fixture(:builds).first }
36
- subject{ Semaphoreapp::Build.build_from_hash(test_hash) }
42
+ subject{ Semaphoreapp::Build.build_from_hash(test_hash, 'project_hash_id', 'branch_id') }
37
43
 
38
44
  it{ should be_an_instance_of Semaphoreapp::Build }
39
45
 
@@ -61,13 +67,13 @@ describe Semaphoreapp::Build do
61
67
  describe ".build_from_array" do
62
68
 
63
69
  let(:test_array){ fixture(:builds) }
64
- subject{ Semaphoreapp::Build.build_from_array(test_array) }
70
+ subject{ Semaphoreapp::Build.build_from_array(test_array, 'project_hash_id', 'branch_id') }
65
71
 
66
72
  it{ should be_an_instance_of Array }
67
73
 
68
74
  it "should call build_from_hash for all the hashes in the array" do
69
75
  test_array.each do |test_hash|
70
- Semaphoreapp::Build.should_receive(:build_from_hash).with(test_hash)
76
+ Semaphoreapp::Build.should_receive(:build_from_hash).with(test_hash, 'project_hash_id', 'branch_id')
71
77
  end
72
78
 
73
79
  subject
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Semaphoreapp::Thread do
4
+
5
+ describe ".build" do
6
+
7
+ context "with a hash" do
8
+
9
+ let(:test_hash){ fixture(:build_log)['threads'].first }
10
+ subject{ Semaphoreapp::Thread.build(test_hash) }
11
+
12
+ it "should call build_from_hash" do
13
+ Semaphoreapp::Thread.should_receive(:build_from_hash).with(test_hash)
14
+ subject
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ describe ".build_from_hash" do
22
+
23
+ let(:test_hash){ fixture(:build_log)['threads'].first }
24
+ subject{ Semaphoreapp::Thread.build_from_hash(test_hash) }
25
+
26
+ it{ should be_an_instance_of Semaphoreapp::Thread }
27
+
28
+ fixture(:build_log)['threads'].first.reject{ |key| key == 'commands' }.each do |key, value|
29
+ it "should have attribute #{key}" do
30
+ subject.send(key).should == value
31
+ end
32
+ end
33
+
34
+ context "with commands" do
35
+ it "should have an array as the commands attribute" do
36
+ subject.commands.should be_an_instance_of Array
37
+ end
38
+
39
+ it "should contain Command objects" do
40
+ subject.commands.map(&:class).uniq.should == [Semaphoreapp::Command]
41
+ end
42
+ end
43
+
44
+ context "without commands" do
45
+ before{ test_hash.delete('commands') }
46
+ it "should set the commands attribute to nil" do
47
+ subject.commands.should be_nil
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphoreapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alessandro Morandi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
11
+ date: 2013-04-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: awesome_print
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: pry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: pry-debugger
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -99,6 +88,7 @@ extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
90
  - .gitignore
91
+ - CHANGELOG.md
102
92
  - Gemfile
103
93
  - LICENSE
104
94
  - README.md
@@ -109,59 +99,72 @@ files:
109
99
  - lib/semaphoreapp/branch.rb
110
100
  - lib/semaphoreapp/branch_status.rb
111
101
  - lib/semaphoreapp/build.rb
102
+ - lib/semaphoreapp/build_information.rb
103
+ - lib/semaphoreapp/build_log.rb
104
+ - lib/semaphoreapp/command.rb
112
105
  - lib/semaphoreapp/commit.rb
113
106
  - lib/semaphoreapp/json_api.rb
114
107
  - lib/semaphoreapp/project.rb
108
+ - lib/semaphoreapp/thread.rb
115
109
  - lib/semaphoreapp/version.rb
116
110
  - semaphoreapp.gemspec
117
- - spec/fixtures/branch_statuses.json
111
+ - spec/fixtures/branch_status.json
118
112
  - spec/fixtures/branches.json
113
+ - spec/fixtures/build_information.json
114
+ - spec/fixtures/build_log.json
119
115
  - spec/fixtures/builds.json
120
116
  - spec/fixtures/commit.json
121
117
  - spec/fixtures/projects.json
122
118
  - spec/semaphoreapp/api_spec.rb
123
119
  - spec/semaphoreapp/branch_spec.rb
124
120
  - spec/semaphoreapp/branch_status_spec.rb
121
+ - spec/semaphoreapp/build_information_spec.rb
122
+ - spec/semaphoreapp/build_log_spec.rb
125
123
  - spec/semaphoreapp/build_spec.rb
126
124
  - spec/semaphoreapp/commit_spec.rb
127
125
  - spec/semaphoreapp/json_api_spec.rb
128
126
  - spec/semaphoreapp/project_spec.rb
127
+ - spec/semaphoreapp/thread_spec.rb
129
128
  - spec/spec_helper.rb
130
129
  homepage: http://github.com/Simbul/semaphoreapp
131
130
  licenses: []
131
+ metadata: {}
132
132
  post_install_message:
133
133
  rdoc_options: []
134
134
  require_paths:
135
135
  - lib
136
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
- none: false
138
137
  requirements:
139
138
  - - ! '>='
140
139
  - !ruby/object:Gem::Version
141
140
  version: '0'
142
141
  required_rubygems_version: !ruby/object:Gem::Requirement
143
- none: false
144
142
  requirements:
145
143
  - - ! '>='
146
144
  - !ruby/object:Gem::Version
147
145
  version: '0'
148
146
  requirements: []
149
147
  rubyforge_project:
150
- rubygems_version: 1.8.24
148
+ rubygems_version: 2.0.3
151
149
  signing_key:
152
- specification_version: 3
150
+ specification_version: 4
153
151
  summary: A client for the Semaphore API
154
152
  test_files:
155
- - spec/fixtures/branch_statuses.json
153
+ - spec/fixtures/branch_status.json
156
154
  - spec/fixtures/branches.json
155
+ - spec/fixtures/build_information.json
156
+ - spec/fixtures/build_log.json
157
157
  - spec/fixtures/builds.json
158
158
  - spec/fixtures/commit.json
159
159
  - spec/fixtures/projects.json
160
160
  - spec/semaphoreapp/api_spec.rb
161
161
  - spec/semaphoreapp/branch_spec.rb
162
162
  - spec/semaphoreapp/branch_status_spec.rb
163
+ - spec/semaphoreapp/build_information_spec.rb
164
+ - spec/semaphoreapp/build_log_spec.rb
163
165
  - spec/semaphoreapp/build_spec.rb
164
166
  - spec/semaphoreapp/commit_spec.rb
165
167
  - spec/semaphoreapp/json_api_spec.rb
166
168
  - spec/semaphoreapp/project_spec.rb
169
+ - spec/semaphoreapp/thread_spec.rb
167
170
  - spec/spec_helper.rb
@@ -1,42 +0,0 @@
1
- [
2
- {
3
- "branch_name": "master",
4
- "branch_url": "http://10.0.1.76:3000/projects/61/branches/85",
5
- "branch_status_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85/status?auth_token=Yds3w6o26FLfJTnVK2y9",
6
- "branch_history_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/85?auth_token=Yds3w6o26FLfJTnVK2y9",
7
- "project_name": "testapp-sphinx",
8
- "build_url": "http://10.0.1.76:3000/projects/61/branches/85/builds/1",
9
- "build_number": 1,
10
- "result": "passed",
11
- "started_at": "2012-09-04T11:55:07Z",
12
- "finished_at": "2012-09-04T12:01:16Z",
13
- "commit": {
14
- "id": "a31d32d5de89613369f934eb7d30fbeb08883334",
15
- "url": "https://github.com/renderedtext/base-app/commit/a31d32d5de89613369f934eb7d30fbeb08883334",
16
- "author_name": "Vladimir Saric",
17
- "author_email": "vladimir@renderedtext.com",
18
- "message": "Update 'shoulda' gem.",
19
- "timestamp": "2012-10-02T07:00:14Z"
20
- }
21
- },
22
- {
23
- "branch_name": "testbranch",
24
- "branch_url": "http://10.0.1.76:3000/projects/61/branches/86",
25
- "branch_status_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/86/status?auth_token=Yds3w6o26FLfJTnVK2y9",
26
- "branch_history_url": "http://semaphoreapp.com/api/v1/projects/3f1004b8343faabda63d441734526c854380ab89/86?auth_token=Yds3w6o26FLfJTnVK2y9",
27
- "project_name": "testapp-sphinx",
28
- "build_url": "http://10.0.1.76:3000/projects/61/branches/86/builds/1",
29
- "build_number": 1,
30
- "result": "failed",
31
- "started_at": "2012-09-05T11:55:07Z",
32
- "finished_at": "2012-09-05T12:01:16Z",
33
- "commit": {
34
- "id": "73fce130ad23f265add5d55ee1da1c23b38f85a4",
35
- "url": "https://github.com/renderedtext/base-app/commit/73fce130ad23f265add5d55ee1da1c23b38f85a4",
36
- "author_name": "Marko Anastasov",
37
- "author_email": "marko@renderedtext.com",
38
- "message": "Update 'factory_girl_rails' gem and use new short FactoryGirl syntax.",
39
- "timestamp": "2012-10-02T07:00:14Z"
40
- }
41
- }
42
- ]