billd 0.0.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.
- data/.gitignore +5 -0
- data/.rbenv-version +1 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +48 -0
- data/README.markdown +1 -0
- data/Rakefile +9 -0
- data/billd.gemspec +25 -0
- data/bin/billd +9 -0
- data/features/billd.feature +21 -0
- data/features/support/env.rb +3 -0
- data/lib/billd/build.rb +24 -0
- data/lib/billd/cli.rb +11 -0
- data/lib/billd/parser.rb +13 -0
- data/lib/billd/status.rb +18 -0
- data/lib/billd/version.rb +3 -0
- data/spec/billd/build_spec.rb +30 -0
- data/spec/billd/cli_spec.rb +15 -0
- data/spec/billd/parser_spec.rb +24 -0
- data/spec/billd/status_spec.rb +28 -0
- data/spec/spec_helper.rb +4 -0
- metadata +126 -0
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p125
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
billd (0.0.1)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.4.9)
|
11
|
+
childprocess (>= 0.2.3)
|
12
|
+
cucumber (>= 1.1.1)
|
13
|
+
ffi (= 1.0.11)
|
14
|
+
rspec (>= 2.7.0)
|
15
|
+
builder (3.0.0)
|
16
|
+
childprocess (0.2.3)
|
17
|
+
ffi (~> 1.0.6)
|
18
|
+
cucumber (1.1.4)
|
19
|
+
builder (>= 2.1.2)
|
20
|
+
diff-lcs (>= 1.1.2)
|
21
|
+
gherkin (~> 2.7.1)
|
22
|
+
json (>= 1.4.6)
|
23
|
+
term-ansicolor (>= 1.0.6)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
ffi (1.0.11)
|
26
|
+
gherkin (2.7.1)
|
27
|
+
json (>= 1.4.6)
|
28
|
+
json (1.6.3)
|
29
|
+
nokogiri (1.5.2)
|
30
|
+
rake (0.9.2.2)
|
31
|
+
rspec (2.7.0)
|
32
|
+
rspec-core (~> 2.7.0)
|
33
|
+
rspec-expectations (~> 2.7.0)
|
34
|
+
rspec-mocks (~> 2.7.0)
|
35
|
+
rspec-core (2.7.1)
|
36
|
+
rspec-expectations (2.7.0)
|
37
|
+
diff-lcs (~> 1.1.2)
|
38
|
+
rspec-mocks (2.7.0)
|
39
|
+
term-ansicolor (1.0.7)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
aruba
|
46
|
+
billd!
|
47
|
+
rake
|
48
|
+
rspec
|
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[](http://travis-ci.org/jamesottaway/billd)
|
data/Rakefile
ADDED
data/billd.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "billd/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "billd"
|
7
|
+
s.version = Billd::VERSION
|
8
|
+
s.authors = ["James Ottaway"]
|
9
|
+
s.email = ["james@ottaway.mp"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{It parses builds}
|
12
|
+
s.description = %q{For those times when you need to control something based on the status of your build}
|
13
|
+
|
14
|
+
s.rubyforge_project = "billd"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "nokogiri"
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "aruba"
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
end
|
data/bin/billd
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Billd
|
2
|
+
|
3
|
+
Scenario:
|
4
|
+
Given a file named "build.xml" with:
|
5
|
+
"""
|
6
|
+
<Projects>
|
7
|
+
<Project name="successful-project" lastBuildStatus="Success" activity="Sleeping"/>
|
8
|
+
<Project name="building-from-success-project" lastBuildStatus="Success" activity="Building"/>
|
9
|
+
<Project name="building-from-failure-project" lastBuildStatus="Failure" activity="Building"/>
|
10
|
+
<Project name="failed-project" lastBuildStatus="Failure" activity="Sleeping"/>
|
11
|
+
</Projects>
|
12
|
+
"""
|
13
|
+
When I run `billd build.xml`
|
14
|
+
And the stdout should contain:
|
15
|
+
"""
|
16
|
+
successful-project: Success!
|
17
|
+
building-from-success-project: Building!
|
18
|
+
building-from-failure-project: Building!
|
19
|
+
failed-project: Failure!
|
20
|
+
"""
|
21
|
+
Then the exit status should be 0
|
data/lib/billd/build.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Billd
|
4
|
+
class Build
|
5
|
+
def initialize status
|
6
|
+
@status = status
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
Nokogiri.parse(@status).children.attribute('name').value
|
11
|
+
end
|
12
|
+
|
13
|
+
def outcome
|
14
|
+
outcome = :success
|
15
|
+
outcome = :failure if @status[%Q{lastBuildStatus="Failure"}]
|
16
|
+
outcome = :building if @status[%Q{activity="Building"}]
|
17
|
+
outcome
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
"#{name}: #{outcome.to_s.capitalize}!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/billd/cli.rb
ADDED
data/lib/billd/parser.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'billd/build'
|
3
|
+
|
4
|
+
module Billd
|
5
|
+
class Parser
|
6
|
+
def self.parse uri
|
7
|
+
source = Kernel.open(uri).read
|
8
|
+
xml = Nokogiri.parse source
|
9
|
+
projects = xml.elements.first
|
10
|
+
projects.elements.map { |e| Billd::Build.new(e.to_xml) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/billd/status.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'billd/parser'
|
2
|
+
|
3
|
+
module Billd
|
4
|
+
class Status
|
5
|
+
attr_reader :builds
|
6
|
+
|
7
|
+
def initialize uri
|
8
|
+
@builds = Billd::Parser.parse(uri)
|
9
|
+
end
|
10
|
+
|
11
|
+
def overall
|
12
|
+
result = :success
|
13
|
+
result = :failure if @builds.any? { |b| b.outcome == :failure }
|
14
|
+
result = :building if @builds.any? { |b| b.outcome == :building }
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'billd/build'
|
3
|
+
|
4
|
+
describe Billd::Build do
|
5
|
+
subject { Billd::Build.new(status) }
|
6
|
+
let(:status) { %Q{<Project name="my-project" lastBuildStatus="Success"/>} }
|
7
|
+
|
8
|
+
its(:name) { should == 'my-project' }
|
9
|
+
its(:to_s) { should == 'my-project: Success!' }
|
10
|
+
|
11
|
+
describe 'passing' do
|
12
|
+
let(:status) { %Q{<Project name="my-project" lastBuildStatus="Success" activity="Sleeping"/>} }
|
13
|
+
its(:outcome) { should == :success }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'failing' do
|
17
|
+
let(:status) { %Q{<Project name="my-project" lastBuildStatus="Failure" activity="Sleeping"/>} }
|
18
|
+
its(:outcome) { should == :failure }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'building from success' do
|
22
|
+
let(:status) { %Q{<Project name="my-project" lastBuildStatus="Success" activity="Building"/>} }
|
23
|
+
its(:outcome) { should == :building }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'building from failure' do
|
27
|
+
let(:status) { %Q{<Project name="my-project" lastBuildStatus="Failure" activity="Building"/>} }
|
28
|
+
its(:outcome) { should == :building }
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'billd/cli'
|
3
|
+
|
4
|
+
describe Billd::Cli do
|
5
|
+
let(:uri) { '//build/status' }
|
6
|
+
let(:build_output) { 'i am a build' }
|
7
|
+
let(:argv) { [uri] }
|
8
|
+
let(:build) { mock 'Build', :to_s => build_output }
|
9
|
+
let(:status) { mock 'Status', :builds => [build] }
|
10
|
+
|
11
|
+
before { Billd::Status.should_receive(:new).with(uri).and_return(status) }
|
12
|
+
before { STDOUT.should_receive(:puts).with(build_output) }
|
13
|
+
|
14
|
+
it { Billd::Cli.execute(argv) }
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'billd/parser'
|
3
|
+
|
4
|
+
describe Billd::Parser do
|
5
|
+
let(:build1) { mock 'Build' }
|
6
|
+
let(:build2) { mock 'Build' }
|
7
|
+
let(:build3) { mock 'Build' }
|
8
|
+
let(:uri) { '//build/status' }
|
9
|
+
let(:status1) { '<Project name="project1"/>' }
|
10
|
+
let(:status2) { '<Project name="project2"/>' }
|
11
|
+
let(:status3) { '<Project name="project3"/>' }
|
12
|
+
let(:statuses) { "<Projects>#{status1}#{status2}#{status3}</Projects>" }
|
13
|
+
let(:stream) { mock 'File', :read => statuses }
|
14
|
+
|
15
|
+
subject { Billd::Parser.parse(uri) }
|
16
|
+
|
17
|
+
before { Kernel.should_receive(:open).with(uri).and_return(stream) }
|
18
|
+
before { Billd::Build.should_receive(:new).with(status1).and_return(build1) }
|
19
|
+
before { Billd::Build.should_receive(:new).with(status2).and_return(build2) }
|
20
|
+
before { Billd::Build.should_receive(:new).with(status3).and_return(build3) }
|
21
|
+
|
22
|
+
its(:size) { should == 3 }
|
23
|
+
it { should == [build1, build2, build3] }
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'billd/status'
|
3
|
+
|
4
|
+
describe Billd::Status do
|
5
|
+
let(:uri) { '//build/status' }
|
6
|
+
let(:successful) { mock 'successful build', :outcome => :success }
|
7
|
+
let(:failed) { mock 'failed build', :outcome => :failure }
|
8
|
+
let(:building) { mock 'build being built', :outcome => :building }
|
9
|
+
let(:parsed_builds) { [successful, failed, building] }
|
10
|
+
|
11
|
+
before { Billd::Parser.should_receive(:parse).with(uri).and_return(parsed_builds) }
|
12
|
+
|
13
|
+
subject { Billd::Status.new(uri) }
|
14
|
+
|
15
|
+
its(:builds) { should == parsed_builds }
|
16
|
+
|
17
|
+
describe 'overall' do
|
18
|
+
describe 'failure > success' do
|
19
|
+
let(:parsed_builds) { [successful, failed] }
|
20
|
+
its(:overall) { should == :failure }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'building > failure' do
|
24
|
+
let(:parsed_builds) { [failed, building] }
|
25
|
+
its(:overall) { should == :building }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: billd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Ottaway
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70241263494480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70241263494480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70241263492920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70241263492920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: aruba
|
38
|
+
requirement: &70241263491720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70241263491720
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70241263490220 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70241263490220
|
58
|
+
description: For those times when you need to control something based on the status
|
59
|
+
of your build
|
60
|
+
email:
|
61
|
+
- james@ottaway.mp
|
62
|
+
executables:
|
63
|
+
- billd
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- .rbenv-version
|
69
|
+
- .rspec
|
70
|
+
- .travis.yml
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- README.markdown
|
74
|
+
- Rakefile
|
75
|
+
- billd.gemspec
|
76
|
+
- bin/billd
|
77
|
+
- features/billd.feature
|
78
|
+
- features/support/env.rb
|
79
|
+
- lib/billd/build.rb
|
80
|
+
- lib/billd/cli.rb
|
81
|
+
- lib/billd/parser.rb
|
82
|
+
- lib/billd/status.rb
|
83
|
+
- lib/billd/version.rb
|
84
|
+
- spec/billd/build_spec.rb
|
85
|
+
- spec/billd/cli_spec.rb
|
86
|
+
- spec/billd/parser_spec.rb
|
87
|
+
- spec/billd/status_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: ''
|
90
|
+
licenses: []
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
hash: -4471539915762378743
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: -4471539915762378743
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project: billd
|
115
|
+
rubygems_version: 1.8.11
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: It parses builds
|
119
|
+
test_files:
|
120
|
+
- features/billd.feature
|
121
|
+
- features/support/env.rb
|
122
|
+
- spec/billd/build_spec.rb
|
123
|
+
- spec/billd/cli_spec.rb
|
124
|
+
- spec/billd/parser_spec.rb
|
125
|
+
- spec/billd/status_spec.rb
|
126
|
+
- spec/spec_helper.rb
|