kraken-build 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
3
3
  gem "httparty"
4
4
 
5
5
  gem "rake"
6
- gem "nokogiri"
7
- #gem "github_api"
8
- #gem "awesome_print"
9
6
 
10
7
  group :test do
11
8
  gem 'rspec'
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 at
1
+ Copyright (c) 2012 Andreas Tiefenthaler, Michael Kohl
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/kraken-build.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/kraken-build/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["at"]
6
- gem.email = ["at@an-ti.eu"]
5
+ gem.authors = ["Andreas Tiefenthaler", "Michael Kohl"]
6
+ gem.email = ["at@an-ti.eu", "citizen428@gmail.com"]
7
7
  gem.description = %q{A simple tool that generates a job for each github branch in your Jenkins environment}
8
8
  gem.summary = %q{Managing your feature branches on Jenkins and Github}
9
9
  gem.homepage = "https://github.com/pxlpnk/kraken-build"
data/lib/kraken-build.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "httparty"
2
- require 'nokogiri'
2
+ require 'rexml/document'
3
3
  require 'cgi'
4
4
 
5
5
  require "kraken-build/version"
@@ -1,9 +1,7 @@
1
1
  class JenkinsApi
2
2
  include HTTParty
3
3
 
4
-
5
4
  def initialize(options = {})
6
-
7
5
  if options[:port]
8
6
  self.class.base_uri "#{options[:host]}:#{options[:port]}"
9
7
  else
@@ -13,20 +11,17 @@ class JenkinsApi
13
11
  if(options[:username] && options[:password])
14
12
  self.class.basic_auth options[:username] , options[:password]
15
13
  end
16
-
17
14
  end
18
15
 
19
16
  def get_jobs(options = {})
20
17
  response = self.class.get("/api/json/", options)
21
-
22
18
  jobs = response["jobs"]
23
19
 
24
- jobs.map{|job| job["name"]}
20
+ jobs.map { |job| job["name"] }
25
21
  end
26
22
 
27
23
  def create_job(job, options = {})
28
- repo = job.split('.').first
29
- branch_name = job.split('.').last
24
+ repo, branch_name = job.split('.')
30
25
  job_config = create_job_configuration(repo, branch_name)
31
26
  options.merge!(
32
27
  :body => job_config,
@@ -36,14 +31,11 @@ class JenkinsApi
36
31
  end
37
32
 
38
33
  def create_job_configuration(repo, branch)
39
-
40
34
  draft = get_job_configuration("#{repo}.master")
35
+ doc = REXML::Document.new(draft)
36
+ REXML::XPath.first(doc, '//branches//hudson.plugins.git.BranchSpec//name').text = branch
41
37
 
42
- doc = Nokogiri.XML(draft)
43
-
44
- doc.xpath('//branches//hudson.plugins.git.BranchSpec//name').first.content = "#{repo}.#{branch}"
45
-
46
- doc.to_xml
38
+ doc.to_s
47
39
  end
48
40
 
49
41
  def get_job_configuration(job, options = {})
@@ -1,5 +1,5 @@
1
1
  module Kraken
2
2
  module Build
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -80,6 +80,14 @@ XML
80
80
  @api.get_job_configuration("FooJob").should be(a)
81
81
  end
82
82
 
83
+ it "#create_job_configuration returns a valid job configuration" do
84
+ xml = <<XML
85
+ <xml><branches><hudson.plugins.git.BranchSpec><name>master</name></hudson.plugins.git.BranchSpec></branches></xml>
86
+ XML
87
+ xml.should_receive(:body).and_return(xml)
88
+ @api.class.should_receive(:get).with('/job/foobar.master/config.xml', {}).and_return(xml)
89
+ @api.create_job_configuration('foobar', 'feature').should =~ /feature/
90
+ end
83
91
  end
84
92
 
85
93
 
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kraken-build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - at
8
+ - Andreas Tiefenthaler
9
+ - Michael Kohl
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
13
+ date: 2012-07-12 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rspec
@@ -79,6 +80,7 @@ description: A simple tool that generates a job for each github branch in your J
79
80
  environment
80
81
  email:
81
82
  - at@an-ti.eu
83
+ - citizen428@gmail.com
82
84
  executables:
83
85
  - kraken-build
84
86
  extensions: []
@@ -98,7 +100,7 @@ files:
98
100
  - lib/kraken-build/jenkins-api.rb
99
101
  - lib/kraken-build/version.rb
100
102
  - spec/lib/github_api_spec.rb
101
- - spec/lib/jenins_api_spec.rb
103
+ - spec/lib/jenkins_api_spec.rb
102
104
  - spec/spec_helper.rb
103
105
  homepage: https://github.com/pxlpnk/kraken-build
104
106
  licenses: []
@@ -114,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
116
  version: '0'
115
117
  segments:
116
118
  - 0
117
- hash: 4316786241406826877
119
+ hash: -1000239270356709481
118
120
  required_rubygems_version: !ruby/object:Gem::Requirement
119
121
  none: false
120
122
  requirements:
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  version: '0'
124
126
  segments:
125
127
  - 0
126
- hash: 4316786241406826877
128
+ hash: -1000239270356709481
127
129
  requirements: []
128
130
  rubyforge_project:
129
131
  rubygems_version: 1.8.24
@@ -132,5 +134,5 @@ specification_version: 3
132
134
  summary: Managing your feature branches on Jenkins and Github
133
135
  test_files:
134
136
  - spec/lib/github_api_spec.rb
135
- - spec/lib/jenins_api_spec.rb
137
+ - spec/lib/jenkins_api_spec.rb
136
138
  - spec/spec_helper.rb