ciquantum 0.0.17 → 0.0.18

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.
@@ -1,8 +1,7 @@
1
1
 
2
2
  require 'ciquantum/version'
3
3
  require 'ciquantum/config'
4
- require 'ciquantum/unfuddle'
5
- require 'ciquantum/unfuddle/changeset'
4
+ require 'ciquantum/adapter'
6
5
  require 'ciquantum/utils/mailer'
7
6
  require 'ciquantum/utils/coverage_merger'
8
7
  require 'ciquantum/git'
@@ -0,0 +1,17 @@
1
+
2
+ Dir[File.join(File.dirname(__FILE__), "adapter/**/*.rb")].each {|f| require f}
3
+
4
+ module CIQuantum
5
+ module Adapter
6
+ class << self
7
+
8
+ def from_config config
9
+ name = config.adapter.to_s
10
+ puts config.config_string
11
+ puts "Config: #{config}; Name: #{name}"
12
+ const_get(name).from_config(config) unless name.empty?
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ module CIQuantum
2
+ module Adapter
3
+ class Gitlab < Struct.new(:config)
4
+
5
+ def self.config_name
6
+ 'gitlab'
7
+ end
8
+
9
+ def self.from_config config
10
+ self.new config[config_name]
11
+ end
12
+
13
+ def commit_url commit
14
+ "https://gitlab.sqtools.ru:11443/#{config.project}/commits/#{commit.sha}"
15
+ end
16
+
17
+ def url
18
+ "https://gitlab.sqtools.ru:11443/#{config.project}"
19
+ end
20
+
21
+ def [] command
22
+ return config[command]
23
+ end
24
+
25
+ def commit_from_request request
26
+ hash = JSON.parse request.body.read.strip
27
+ return (hash["repository"]["name"] == config.project) ? hash["after"] : nil
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module CIQuantum
3
+ module Adapter
4
+ class Unfuddle < Struct.new(:config)
5
+
6
+ def self.config_name
7
+ 'unfuddle'
8
+ end
9
+
10
+ def self.from_config config
11
+ self.new config[config_name]
12
+ end
13
+
14
+ def commit_url commit
15
+ "http://#{config.user}.unfuddle.com/a#/repositories/#{config.project}/commit?commit=#{commit.sha}"
16
+ end
17
+
18
+ def url
19
+ "https://#{config.user}.unfuddle.com/a#/repositories/#{config.project}/browse"
20
+ end
21
+
22
+ def [] command
23
+ return config[command]
24
+ end
25
+
26
+ def commit_from_request request
27
+ begin
28
+ xml = request.body.read
29
+ return Changeset.new(xml).commit
30
+ rescue Unfuddle::ChangesetError => e
31
+ nil
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,46 @@
1
+ require 'active_support/core_ext'
2
+
3
+ module CIQuantum
4
+ module Adater
5
+ class Unfuddle
6
+ class ChangesetError < StandardError ; end
7
+
8
+ class Changeset
9
+ FIELDS = %w(repository_id revision message committer_name committer_date).freeze
10
+
11
+ attr_reader :author
12
+ attr_reader :message
13
+ attr_reader :date
14
+ attr_reader :commit
15
+ attr_reader :repo
16
+ attr_reader :xml
17
+
18
+ def initialize(xml)
19
+ xml = xml.to_s.strip
20
+ raise ChangesetError, 'Changeset XML required!' if xml.empty?
21
+
22
+ begin
23
+ @data = Hash.from_xml(xml)
24
+ rescue REXML::ParseException
25
+ raise ChangesetError, 'Invalid XML data!'
26
+ end
27
+
28
+ raise ChangesetError, 'Invalid changeset!' unless @data.key?('changeset')
29
+
30
+ @xml = xml
31
+ @data = @data['changeset']
32
+
33
+ unless (FIELDS & @data.keys).size == FIELDS.size
34
+ raise ChangesetError, 'Invalid changeset!'
35
+ end
36
+
37
+ @commit = @data['revision']
38
+ @author = @data['committer_name']
39
+ @message = @data['message']
40
+ @date = @data['committer_date']
41
+ @repo = @data['repository_id']
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -30,6 +30,7 @@ module CIQuantum
30
30
  end
31
31
  end
32
32
 
33
+
33
34
  def config_string
34
35
  @parent ? "#{@parent.config_string}.#{@command}" : @command
35
36
  end
@@ -17,7 +17,7 @@ module CIQuantum
17
17
  def initialize(project_path)
18
18
  @is_building = false
19
19
  @project_path = File.expand_path(project_path)
20
- @adapter = Unfuddle.from_config(repo_config)
20
+ @adapter = Adapter.from_config(repo_config)
21
21
 
22
22
  @projectname = repo_config.projectname.to_s
23
23
  @coverage_path = repo_config.coveragepath.to_s
@@ -225,7 +225,9 @@ module CIQuantum
225
225
  end
226
226
 
227
227
  def read_build(name)
228
- Build.load(path_in_project(".git/builds/#{name}"), @project_path)
228
+ build = Build.load(path_in_project(".git/builds/#{name}"), @project_path)
229
+ build.commit.get_url! adapter if build && build.commit && adapter
230
+ build
229
231
  end
230
232
 
231
233
  def read_last_build
@@ -82,15 +82,10 @@ module CIQuantum
82
82
  end
83
83
 
84
84
  post '/push' do
85
- begin
86
- xml = request.body.read
87
- changeset = Unfuddle::Changeset.new(xml)
88
- if quantum.git.current_branch_contains_commit? changeset.commit
89
- quantum.build
90
- end
91
- rescue Unfuddle::ChangesetError => e
92
- logger.error "[error] Changeset error: #{e.inspect}, Content: #{xml.inspect}"
93
- halt 400, "Changeset Error: #{e.message}"
85
+ puts "Request received on push:\n#{request.body.read}"
86
+ commit = quantum.adapter.commit_from_request request
87
+ if quantum.git.current_branch_contains_commit? commit
88
+ quantum.build
94
89
  end
95
90
  end
96
91
 
@@ -1,3 +1,3 @@
1
1
  module CIQuantum
2
- Version = VERSION = "0.0.17"
2
+ Version = VERSION = "0.0.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ciquantum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-22 00:00:00.000000000 Z
14
+ date: 2012-07-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -193,6 +193,10 @@ files:
193
193
  - examples/ciquantum.ru
194
194
  - examples/ciquantumd
195
195
  - lib/ciquantum.rb
196
+ - lib/ciquantum/adapter.rb
197
+ - lib/ciquantum/adapter/gitlab.rb
198
+ - lib/ciquantum/adapter/unfuddle.rb
199
+ - lib/ciquantum/adapter/unfuddle/changeset.rb
196
200
  - lib/ciquantum/build.rb
197
201
  - lib/ciquantum/commit.rb
198
202
  - lib/ciquantum/config.rb
@@ -202,8 +206,6 @@ files:
202
206
  - lib/ciquantum/public/screen.css
203
207
  - lib/ciquantum/queue.rb
204
208
  - lib/ciquantum/server.rb
205
- - lib/ciquantum/unfuddle.rb
206
- - lib/ciquantum/unfuddle/changeset.rb
207
209
  - lib/ciquantum/utils/coverage_merger.rb
208
210
  - lib/ciquantum/utils/mailer.rb
209
211
  - lib/ciquantum/version.rb
@@ -1,25 +0,0 @@
1
- module CIQuantum
2
- class Unfuddle < Struct.new(:config)
3
-
4
- def self.config_name
5
- 'unfuddle'
6
- end
7
-
8
- def self.from_config config
9
- self.new config[config_name]
10
- end
11
-
12
- def commit_url commit
13
- "http://#{config.user}.unfuddle.com/a#/repositories/#{config.project}/commit?commit=#{commit.sha}"
14
- end
15
-
16
- def url
17
- "https://#{config.user}.unfuddle.com/a#/repositories/#{config.project}/browse"
18
- end
19
-
20
- def [] command
21
- return @config[command]
22
- end
23
-
24
- end
25
- end
@@ -1,44 +0,0 @@
1
- require 'active_support/core_ext'
2
-
3
- module CIQuantum
4
- class Unfuddle
5
- class ChangesetError < StandardError ; end
6
-
7
- class Changeset
8
- FIELDS = %w(repository_id revision message committer_name committer_date).freeze
9
-
10
- attr_reader :author
11
- attr_reader :message
12
- attr_reader :date
13
- attr_reader :commit
14
- attr_reader :repo
15
- attr_reader :xml
16
-
17
- def initialize(xml)
18
- xml = xml.to_s.strip
19
- raise ChangesetError, 'Changeset XML required!' if xml.empty?
20
-
21
- begin
22
- @data = Hash.from_xml(xml)
23
- rescue REXML::ParseException
24
- raise ChangesetError, 'Invalid XML data!'
25
- end
26
-
27
- raise ChangesetError, 'Invalid changeset!' unless @data.key?('changeset')
28
-
29
- @xml = xml
30
- @data = @data['changeset']
31
-
32
- unless (FIELDS & @data.keys).size == FIELDS.size
33
- raise ChangesetError, 'Invalid changeset!'
34
- end
35
-
36
- @commit = @data['revision']
37
- @author = @data['committer_name']
38
- @message = @data['message']
39
- @date = @data['committer_date']
40
- @repo = @data['repository_id']
41
- end
42
- end
43
- end
44
- end