polisher 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +84 -14
- data/Rakefile +21 -19
- data/TODO +5 -4
- data/bin/server +1 -0
- data/config/polisher.yml +0 -15
- data/db/connection.rb +13 -10
- data/db/migrations/{002_create_managed_gems.rb → 001_create_projects.rb} +4 -5
- data/db/migrations/{001_create_sources.rb → 002_create_sources.rb} +1 -3
- data/db/migrations/003_create_project_source_versions.rb +28 -0
- data/db/migrations/{003_create_events.rb → 004_create_events.rb} +2 -2
- data/db/migrations/005_create_project_dependencies.rb +28 -0
- data/db/models/event.rb +47 -21
- data/db/models/project.rb +110 -0
- data/db/models/project_dependency.rb +27 -0
- data/db/models/project_source_version.rb +31 -0
- data/db/models/source.rb +82 -16
- data/lib/common.rb +37 -5
- data/lib/dsl.rb +292 -0
- data/lib/event_handlers.rb +139 -73
- data/lib/gem_adapter.rb +94 -0
- data/polisher.rb +302 -50
- data/public/stylesheets/style.css +15 -31
- data/spec/common_spec.rb +28 -0
- data/spec/dsl_spec.rb +357 -0
- data/spec/event_handlers_spec.rb +166 -30
- data/spec/gem_adapter_spec.rb +89 -0
- data/spec/models_spec.rb +635 -107
- data/spec/polisher_spec.rb +496 -56
- data/views/layout.haml +3 -5
- data/views/projects/index.haml +42 -0
- data/views/projects/index.html.haml +38 -0
- data/views/result.haml +9 -0
- data/views/sources/index.haml +24 -41
- data/views/sources/index.html.haml +26 -0
- metadata +131 -12
- data/db/models/managed_gem.rb +0 -111
- data/public/javascripts/jquery-1.2.6.min.js +0 -32
- data/public/javascripts/polisher.js +0 -15
- data/views/gems/index.haml +0 -106
data/views/layout.haml
CHANGED
@@ -4,18 +4,16 @@
|
|
4
4
|
%html
|
5
5
|
%head
|
6
6
|
%link{:rel => "stylesheet", :type => "text/css", :href => '/stylesheets/style.css', :media => 'all'}
|
7
|
-
%script{ :type => "text/javascript", :src => '/javascripts/jquery-1.2.6.min.js' }
|
8
|
-
%script{ :type => "text/javascript", :src => '/javascripts/polisher.js' }
|
9
7
|
%body
|
10
8
|
#header
|
11
9
|
%h3
|
12
|
-
|
10
|
+
Polisher
|
13
11
|
|
14
12
|
%ul{:id => "primary_nav"}
|
15
13
|
%li
|
16
|
-
%a{:href => url_for("/
|
14
|
+
%a{:href => url_for("/projects.html")}projects
|
17
15
|
%li
|
18
|
-
%a{:href => url_for("/sources")}sources
|
16
|
+
%a{:href => url_for("/sources.html")}sources
|
19
17
|
|
20
18
|
%div{:style => "clear: both;"}
|
21
19
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
- haml_tag(:projects) do
|
2
|
+
- @projects.each do |project|
|
3
|
+
- haml_tag(:project) do
|
4
|
+
- haml_tag(:id) do
|
5
|
+
= project.id
|
6
|
+
- haml_tag(:name) do
|
7
|
+
= project.name
|
8
|
+
- haml_tag(:versions) do
|
9
|
+
- project.versions.each do |version|
|
10
|
+
- haml_tag(:version) do
|
11
|
+
- haml_tag(:id) do
|
12
|
+
= version
|
13
|
+
- psources = project.project_source_versions_for_version(version)
|
14
|
+
- haml_tag(:sources) do
|
15
|
+
- psources.each do |ps|
|
16
|
+
- haml_tag(:source) do
|
17
|
+
- haml_tag(:uri) do
|
18
|
+
= ps.source.uri
|
19
|
+
- haml_tag(:version) do
|
20
|
+
= ps.source_version
|
21
|
+
- pevents = project.events_for_version(version)
|
22
|
+
- haml_tag(:events) do
|
23
|
+
- pevents.each do |event|
|
24
|
+
- haml_tag(:event) do
|
25
|
+
- haml_tag(:process) do
|
26
|
+
= event.process
|
27
|
+
- haml_tag(:process_options) do
|
28
|
+
= event.process_options
|
29
|
+
- haml_tag(:version_qualifier) do
|
30
|
+
= event.version_qualifier
|
31
|
+
- haml_tag(:version) do
|
32
|
+
= event.version
|
33
|
+
- pdependencies = project.dependencies_for_version(version)
|
34
|
+
- haml_tag(:dependencies) do
|
35
|
+
- pdependencies.each do |dep|
|
36
|
+
- haml_tag(:dependency) do
|
37
|
+
- haml_tag(:project_id) do
|
38
|
+
= dep.depends_on_project.id
|
39
|
+
- haml_tag(:project_name) do
|
40
|
+
= dep.depends_on_project.name
|
41
|
+
- haml_tag(:project_version) do
|
42
|
+
= dep.depends_on_project_version
|
@@ -0,0 +1,38 @@
|
|
1
|
+
%h1
|
2
|
+
Projects
|
3
|
+
|
4
|
+
%ul
|
5
|
+
- @projects.sort { |x,y| x.name <=> y.name }.each do |project|
|
6
|
+
%li
|
7
|
+
%h2
|
8
|
+
= project.name
|
9
|
+
%br/
|
10
|
+
%h3
|
11
|
+
sources
|
12
|
+
%ul
|
13
|
+
- project.versions.each do |version|
|
14
|
+
- pevents = project.events_for_version(version)
|
15
|
+
- psources = project.project_source_versions_for_version(version)
|
16
|
+
%li
|
17
|
+
%h4
|
18
|
+
= "version " + version
|
19
|
+
%br/
|
20
|
+
%ul
|
21
|
+
- psources.each do |ps|
|
22
|
+
%li
|
23
|
+
= ps.source.uri
|
24
|
+
= ps.source_version
|
25
|
+
%h3
|
26
|
+
events
|
27
|
+
%ul
|
28
|
+
- project.events.each do |event|
|
29
|
+
%li
|
30
|
+
= event.process.humanize
|
31
|
+
= (event.version != "" ? " on version #{event.version_qualifier} #{event.version}" : "")
|
32
|
+
= (event.process_options != "" ? " with options #{event.process_options}" : "")
|
33
|
+
%h3
|
34
|
+
dependencies
|
35
|
+
%ul
|
36
|
+
- project.project_dependencies.each do |dep|
|
37
|
+
%li
|
38
|
+
= "version " + dep.project_version.to_s + " depens on " + dep.depends_on_project.name + "(" + dep.depends_on_project_version.to_s + ")"
|
data/views/result.haml
ADDED
data/views/sources/index.haml
CHANGED
@@ -1,41 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
URI:
|
26
|
-
%td
|
27
|
-
%input{:type => "text", :id => "uri", :name => "uri"}
|
28
|
-
|
29
|
-
%tr
|
30
|
-
%td
|
31
|
-
%input{:type => "submit", :value => "submit"}
|
32
|
-
|
33
|
-
%script{:type => "text/javascript"}
|
34
|
-
:plain
|
35
|
-
$('.delete_source_link').bind('click', function(e){
|
36
|
-
c = confirm("delete source?")
|
37
|
-
if(c){
|
38
|
-
delete_request(this.href, function(result) { reload(); });
|
39
|
-
}
|
40
|
-
return false;
|
41
|
-
});
|
1
|
+
- haml_tag(:sources) do
|
2
|
+
- @sources.each do |source|
|
3
|
+
- haml_tag(:source) do
|
4
|
+
- haml_tag(:id) do
|
5
|
+
= source.id
|
6
|
+
- haml_tag(:name) do
|
7
|
+
= source.name
|
8
|
+
- haml_tag(:source_type) do
|
9
|
+
= source.source_type
|
10
|
+
- haml_tag(:uri) do
|
11
|
+
= source.uri
|
12
|
+
- haml_tag(:versions) do
|
13
|
+
- source.versions.each do |version|
|
14
|
+
- haml_tag(:version) do
|
15
|
+
- haml_tag(:id) do
|
16
|
+
= version
|
17
|
+
- sprojects = source.project_source_versions_for_version(version)
|
18
|
+
- haml_tag(:projects) do
|
19
|
+
- sprojects.each do |ps|
|
20
|
+
- haml_tag(:project) do
|
21
|
+
- haml_tag(:name) do
|
22
|
+
= ps.project.name
|
23
|
+
- haml_tag(:version) do
|
24
|
+
= ps.project_version
|
@@ -0,0 +1,26 @@
|
|
1
|
+
%h1
|
2
|
+
Sources
|
3
|
+
|
4
|
+
%ul
|
5
|
+
- @sources.sort { |x,y| x.name <=> y.name }.each do |source|
|
6
|
+
%li
|
7
|
+
%h2
|
8
|
+
= source.name
|
9
|
+
%br/
|
10
|
+
%h3
|
11
|
+
versions
|
12
|
+
%ul
|
13
|
+
- source.versions.each do |version|
|
14
|
+
- sprojects = source.project_source_versions_for_version(version)
|
15
|
+
%li
|
16
|
+
%h4
|
17
|
+
= version
|
18
|
+
%br/
|
19
|
+
%h5
|
20
|
+
projects
|
21
|
+
%ul
|
22
|
+
- sprojects.each do |ps|
|
23
|
+
%h6
|
24
|
+
= ps.project.name
|
25
|
+
= ps.project_version
|
26
|
+
%br/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.4"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohammed Morsi
|
@@ -11,9 +11,118 @@ cert_chain: []
|
|
11
11
|
|
12
12
|
date: 2010-03-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sinatra
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.4
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thin
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.7
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activerecord
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.3.5
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: haml
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.2.20
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: curb
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.6.7
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: libxml-ruby
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 1.1.3
|
74
|
+
version:
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rest-client
|
77
|
+
type: :runtime
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.4.2
|
84
|
+
version:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: json_pure
|
87
|
+
type: :runtime
|
88
|
+
version_requirement:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.2.0
|
94
|
+
version:
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: gem2rpm
|
97
|
+
type: :runtime
|
98
|
+
version_requirement:
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.6.0
|
104
|
+
version:
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rspec
|
107
|
+
type: :runtime
|
108
|
+
version_requirement:
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 1.3.0
|
114
|
+
version:
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rack-test
|
117
|
+
type: :runtime
|
118
|
+
version_requirement:
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.5.3
|
124
|
+
version:
|
125
|
+
description: Polisher provides simple REST and DSL interfaces allowing you to configure event workflows to be invoked on specific versions of project/source releases
|
17
126
|
email: mmorsi@redhat.com
|
18
127
|
executables: []
|
19
128
|
|
@@ -28,30 +137,40 @@ files:
|
|
28
137
|
- config.ru
|
29
138
|
- COPYING
|
30
139
|
- db/connection.rb
|
31
|
-
- db/migrations/
|
32
|
-
- db/migrations/
|
33
|
-
- db/migrations/
|
140
|
+
- db/migrations/002_create_sources.rb
|
141
|
+
- db/migrations/005_create_project_dependencies.rb
|
142
|
+
- db/migrations/004_create_events.rb
|
143
|
+
- db/migrations/003_create_project_source_versions.rb
|
144
|
+
- db/migrations/001_create_projects.rb
|
145
|
+
- db/models/project.rb
|
34
146
|
- db/models/event.rb
|
147
|
+
- db/models/project_dependency.rb
|
35
148
|
- db/models/source.rb
|
36
|
-
- db/models/
|
149
|
+
- db/models/project_source_version.rb
|
150
|
+
- lib/dsl.rb
|
37
151
|
- lib/common.rb
|
38
152
|
- lib/event_handlers.rb
|
39
153
|
- lib/sinatra/url_for.rb
|
154
|
+
- lib/gem_adapter.rb
|
40
155
|
- LICENSE
|
41
156
|
- polisher.rb
|
42
|
-
- public/javascripts/jquery-1.2.6.min.js
|
43
|
-
- public/javascripts/polisher.js
|
44
157
|
- public/stylesheets/style.css
|
45
158
|
- Rakefile
|
46
159
|
- README.rdoc
|
160
|
+
- spec/common_spec.rb
|
47
161
|
- spec/spec_helper.rb
|
48
162
|
- spec/polisher_spec.rb
|
163
|
+
- spec/gem_adapter_spec.rb
|
49
164
|
- spec/models_spec.rb
|
50
165
|
- spec/event_handlers_spec.rb
|
166
|
+
- spec/dsl_spec.rb
|
51
167
|
- TODO
|
52
168
|
- views/sources/index.haml
|
169
|
+
- views/sources/index.html.haml
|
170
|
+
- views/projects/index.haml
|
171
|
+
- views/projects/index.html.haml
|
53
172
|
- views/layout.haml
|
54
|
-
- views/
|
173
|
+
- views/result.haml
|
55
174
|
has_rdoc: true
|
56
175
|
homepage: http://github.com/movitto/polisher
|
57
176
|
licenses: []
|
@@ -79,6 +198,6 @@ rubyforge_project:
|
|
79
198
|
rubygems_version: 1.3.5
|
80
199
|
signing_key:
|
81
200
|
specification_version: 3
|
82
|
-
summary:
|
201
|
+
summary: A project release management tool
|
83
202
|
test_files: []
|
84
203
|
|
data/db/models/managed_gem.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
# Copyright (C) 2010 Red Hat, Inc.
|
2
|
-
# Written by Mohammed Morsi <mmorsi@redhat.com>
|
3
|
-
#
|
4
|
-
# This program is free software, you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU Affero General Public License
|
6
|
-
# as published by the Free Software Foundation, either version 3
|
7
|
-
# of the License, or (at your option) any later version.
|
8
|
-
#
|
9
|
-
# You should have received a copy of the the GNU Affero
|
10
|
-
# General Public License, along with Polisher. If not, see
|
11
|
-
# <http://www.gnu.org/licenses/>
|
12
|
-
|
13
|
-
require 'uri'
|
14
|
-
require 'json'
|
15
|
-
require 'net/http'
|
16
|
-
|
17
|
-
# Gem representation in polisher, associated w/ rubygem being
|
18
|
-
# managed, used to track updates and invoke handlers
|
19
|
-
class ManagedGem < ActiveRecord::Base
|
20
|
-
belongs_to :source
|
21
|
-
has_many :events
|
22
|
-
|
23
|
-
validates_presence_of :name, :source_id
|
24
|
-
validates_uniqueness_of :name, :scope => :source_id
|
25
|
-
|
26
|
-
# TODO add validation to verify gem can be found in the associated gem source
|
27
|
-
|
28
|
-
# helper, extract source uri from specified gem uri
|
29
|
-
def self.uri_to_source_uri(gem_uri)
|
30
|
-
uri = URI.parse(gem_uri)
|
31
|
-
return uri.scheme + "://" + uri.host
|
32
|
-
end
|
33
|
-
|
34
|
-
# subscribe to updates to this gem from the associated gem source
|
35
|
-
def subscribe(args = {})
|
36
|
-
callback_url = args[:callback_url]
|
37
|
-
api_key = POLISHER_CONFIG["gem_api_key"]
|
38
|
-
|
39
|
-
subscribe_path = '/api/v1/web_hooks'
|
40
|
-
headers = { 'Authorization' => api_key }
|
41
|
-
data = "gem_name=#{name}&url=#{callback_url}"
|
42
|
-
|
43
|
-
http = Net::HTTP.new(URI.parse(source.uri).host, 80)
|
44
|
-
res = http.post(subscribe_path, data, headers)
|
45
|
-
# TODO handle res = #<Net::HTTPNotFound:0x7f1df8319e40> This gem could not be found
|
46
|
-
end
|
47
|
-
|
48
|
-
# determine if we are subscribed to gem
|
49
|
-
def subscribed?
|
50
|
-
api_key = POLISHER_CONFIG["gem_api_key"]
|
51
|
-
|
52
|
-
subscribe_path = '/api/v1/web_hooks.json'
|
53
|
-
headers = { 'Authorization' => api_key }
|
54
|
-
|
55
|
-
http = Net::HTTP.new(URI.parse(source.uri).host, 80)
|
56
|
-
res = http.get(subscribe_path, headers).body
|
57
|
-
res = JSON.parse(res)
|
58
|
-
return res.has_key?(name)
|
59
|
-
end
|
60
|
-
|
61
|
-
# unsubscribe to updates to this gem from associated gem source
|
62
|
-
def unsubscribe(args = {})
|
63
|
-
return unless subscribed?
|
64
|
-
callback_url = args[:callback_url]
|
65
|
-
api_key = POLISHER_CONFIG["gem_api_key"]
|
66
|
-
|
67
|
-
subscribe_path = "/api/v1/web_hooks/remove?gem_name=#{name}&url=#{callback_url}"
|
68
|
-
headers = { 'Authorization' => api_key }
|
69
|
-
|
70
|
-
http = Net::HTTP.new(URI.parse(source.uri).host, 80)
|
71
|
-
res = http.delete(subscribe_path, headers)
|
72
|
-
end
|
73
|
-
|
74
|
-
# return hash of gem attributes/values retreived from remote source
|
75
|
-
def get_info
|
76
|
-
info = nil
|
77
|
-
source_uri = URI.parse(source.uri).host
|
78
|
-
get_path = "/api/v1/gems/#{name}.json"
|
79
|
-
Net::HTTP.start(source_uri, 80) { |http|
|
80
|
-
info = JSON.parse(http.get(get_path).body)
|
81
|
-
}
|
82
|
-
return info
|
83
|
-
end
|
84
|
-
|
85
|
-
def download_to(args = {})
|
86
|
-
path = args.has_key?(:path) ? args[:path] : nil
|
87
|
-
dir = args.has_key?(:dir) ? args[:dir] : nil
|
88
|
-
version = args.has_key?(:version) ? args[:version] : nil
|
89
|
-
|
90
|
-
info = get_info
|
91
|
-
gem_uri = info["gem_uri"]
|
92
|
-
version = info["version"] if version.nil?
|
93
|
-
path = dir + "/#{name}-#{version}.gem" if path.nil?
|
94
|
-
|
95
|
-
# handle redirects
|
96
|
-
found = false
|
97
|
-
until found # TODO should impose a max tries
|
98
|
-
uri = URI.parse(gem_uri)
|
99
|
-
http = Net::HTTP.new(uri.host, 80)
|
100
|
-
res = http.get(uri.path)
|
101
|
-
if res.code == "200"
|
102
|
-
File.write path, res.body
|
103
|
-
found = true
|
104
|
-
else
|
105
|
-
gem_uri = res.header['location']
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
return path
|
110
|
-
end
|
111
|
-
end
|