polisher 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README +243 -0
  2. data/app/controllers/application_controller.rb +12 -0
  3. data/app/controllers/callback_controller.rb +47 -0
  4. data/app/controllers/manage_controller.rb +112 -0
  5. data/app/helpers/application_helper.rb +3 -0
  6. data/app/models/artifact.rb +21 -0
  7. data/app/models/event_handler.rb +61 -0
  8. data/app/models/gem_search_criteria.rb +24 -0
  9. data/app/models/gem_source.rb +43 -0
  10. data/app/models/managed_gem.rb +47 -0
  11. data/app/views/callback/gem_updated.rhtml +0 -0
  12. data/app/views/layouts/_header.rhtml +8 -0
  13. data/app/views/layouts/index.rhtml +27 -0
  14. data/app/views/manage/create_event_handler.rhtml +15 -0
  15. data/app/views/manage/create_gem.rhtml +15 -0
  16. data/app/views/manage/create_gem_source.rhtml +15 -0
  17. data/app/views/manage/delete_event_handler.rhtml +15 -0
  18. data/app/views/manage/delete_gem.rhtml +15 -0
  19. data/app/views/manage/delete_gem_source.rhtml +15 -0
  20. data/app/views/manage/list.rhtml +66 -0
  21. data/app/views/manage/new_event_handler.rhtml +38 -0
  22. data/app/views/manage/new_gem.rhtml +21 -0
  23. data/app/views/manage/new_gem_search_criteria.rhtml +3 -0
  24. data/app/views/manage/new_gem_source.rhtml +10 -0
  25. data/config/boot.rb +110 -0
  26. data/config/database.yml +48 -0
  27. data/config/environment.rb +44 -0
  28. data/config/environments/development.rb +17 -0
  29. data/config/environments/production.rb +28 -0
  30. data/config/environments/test.rb +28 -0
  31. data/config/initializers/backtrace_silencers.rb +7 -0
  32. data/config/initializers/inflections.rb +10 -0
  33. data/config/initializers/mime_types.rb +5 -0
  34. data/config/initializers/new_rails_defaults.rb +21 -0
  35. data/config/initializers/session_store.rb +15 -0
  36. data/config/locales/en.yml +5 -0
  37. data/config/polisher.yml +10 -0
  38. data/config/routes.rb +44 -0
  39. data/db/migrate/001_create_gem_sources.rb +34 -0
  40. data/db/migrate/002_create_managed_gems.rb +32 -0
  41. data/db/migrate/003_create_gem_search_criterias.rb +33 -0
  42. data/db/migrate/004_create_event_handlers.rb +32 -0
  43. data/db/migrate/005_create_artifacts.rb +32 -0
  44. data/db/schema.rb +42 -0
  45. data/db/seeds.rb +7 -0
  46. data/lib/email_adapter.rb +46 -0
  47. data/lib/gem2rpm.rb +189 -0
  48. data/lib/gem_api_adapter.rb +87 -0
  49. data/lib/rpm_adapter.rb +39 -0
  50. data/public/404.html +30 -0
  51. data/public/422.html +30 -0
  52. data/public/500.html +30 -0
  53. data/public/dispatch.cgi +10 -0
  54. data/public/dispatch.fcgi +24 -0
  55. data/public/dispatch.rb +29 -0
  56. data/public/favicon.ico +0 -0
  57. data/public/images/rails.png +0 -0
  58. data/public/javascripts/application.js +2 -0
  59. data/public/javascripts/controls.js +963 -0
  60. data/public/javascripts/dragdrop.js +973 -0
  61. data/public/javascripts/effects.js +1128 -0
  62. data/public/javascripts/jquery-1.2.6.min.js +32 -0
  63. data/public/javascripts/prototype.js +4320 -0
  64. data/public/robots.txt +5 -0
  65. data/public/stylesheets/style.css +68 -0
  66. data/script/about +4 -0
  67. data/script/console +3 -0
  68. data/script/dbconsole +3 -0
  69. data/script/destroy +3 -0
  70. data/script/generate +3 -0
  71. data/script/performance/benchmarker +3 -0
  72. data/script/performance/profiler +3 -0
  73. data/script/plugin +3 -0
  74. data/script/runner +3 -0
  75. data/script/server +3 -0
  76. data/tmp/gems/README +1 -0
  77. data/tmp/rpms/README +1 -0
  78. metadata +141 -0
@@ -0,0 +1,24 @@
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 General Public License as published by
6
+ # the Free Software Foundation; version 2 of the License.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ # MA 02110-1301, USA. A copy of the GNU General Public License is
17
+ # also available at http://www.gnu.org/copyleft/gpl.html.
18
+
19
+ # Encapsulates gem search criteria, for on the fly lookups / matching
20
+ # and event handling
21
+ class GemSearchCriteria < ActiveRecord::Base
22
+ belongs_to :gem_source
23
+
24
+ end
@@ -0,0 +1,43 @@
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 General Public License as published by
6
+ # the Free Software Foundation; version 2 of the License.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ # MA 02110-1301, USA. A copy of the GNU General Public License is
17
+ # also available at http://www.gnu.org/copyleft/gpl.html.
18
+
19
+ # GemSource represents a remote endpoint which we will use
20
+ # the gem API to get gems from / subscribe to updates
21
+ class GemSource < ActiveRecord::Base
22
+ has_many :managed_gems
23
+ has_many :gem_search_criterias
24
+
25
+ alias :gems :managed_gems
26
+ alias :searches :gem_search_criterias
27
+
28
+ validates_presence_of :name
29
+ validates_presence_of :uri
30
+ validates_uniqueness_of :name
31
+ validates_uniqueness_of :uri
32
+
33
+ # FIXME validate format of uri
34
+
35
+ # FIXME should have additional validation method that contacts gem source uri and
36
+ # makes sure it satisfiest gem API requests
37
+
38
+ # remove trailing slash in uri if present
39
+ before_save :clean_uri
40
+ def clean_uri
41
+ self.uri = self.uri[0...self.uri.size-1] if self.uri[-1].chr == '/'
42
+ end
43
+ end
@@ -0,0 +1,47 @@
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 General Public License as published by
6
+ # the Free Software Foundation; version 2 of the License.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ # MA 02110-1301, USA. A copy of the GNU General Public License is
17
+ # also available at http://www.gnu.org/copyleft/gpl.html.
18
+
19
+ # Gem representation in polisher, associated w/ rubygem being
20
+ # managed, used to track updates and invoke handlers
21
+ class ManagedGem < ActiveRecord::Base
22
+ belongs_to :gem_source
23
+ has_many :event_handlers
24
+ alias :source :gem_source
25
+
26
+ validates_presence_of :name, :version, :gem_source_id
27
+ validates_uniqueness_of :name, :scope => :gem_source_id
28
+
29
+ # FIXME add validation to verify gem can be found in the associated gem source
30
+
31
+ # helper, get gem uri
32
+ def uri
33
+ gem_source.uri + "/gems/" + name + "-" + version + ".gem"
34
+ end
35
+
36
+ # subscribe to updates to this gem from the associated gem source
37
+ def subscribe(args = {})
38
+ callback_url = args[:callback_url]
39
+
40
+ logger.info ">> subscribting to updates to gem #{name} hosted at #{gem_source.uri}"
41
+ GemApiAdapter.subscribe(:api_uri => gem_source.uri,
42
+ :api_key => POLISHER_CONFIG["gem_api_key"],
43
+ :gem_name => name,
44
+ :callback_url => callback_url,
45
+ :logger => logger)
46
+ end
47
+ end
File without changes
@@ -0,0 +1,8 @@
1
+ <h3><%= link_to "ruby gem polisher", :controller => :manage, :action => :list %></h3>
2
+ <ul id="primary_nav">
3
+ <li><%= link_to "New Source", :action => "new_gem_source" %></li>
4
+ <li><%= link_to "New Gem", :action => "new_gem" %></li>
5
+ <li><%= link_to "New Search", :action => "new_gem_search_criteria" %></li>
6
+ <li><%= link_to "New Action", :action => "new_event_handler" %></li>
7
+ <!--<li><%= link_to "Log", :controller => "log", :action => "list" %></li>-->
8
+ </ul>
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
8
+ <title><%= yield :title -%></title>
9
+ <%= stylesheet_link_tag 'style' %>
10
+ <!--[if IE]>
11
+ <%= stylesheet_link_tag 'ie' %>
12
+ <![endif]-->
13
+ <%= javascript_include_tag "jquery-1.2.6.min.js" -%>
14
+ <%= yield :scripts -%>
15
+ </head>
16
+
17
+ <body>
18
+ <div id="header">
19
+ <%= render :partial => '/layouts/header' %>
20
+ </div>
21
+ <div id="main">
22
+ <%= yield %> <%# the rest of the center and right hand side %>
23
+ </div>
24
+ <div id="footer">
25
+ </div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error creating action <%= @error %>
4
+ <% else %>
5
+ Action <%= @event_handler.class %> successfully created
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error creating gem <%= @error %>
4
+ <% else %>
5
+ Gem <%= @gem.name %> successfully created
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error creating gem source <%= @error %>
4
+ <% else %>
5
+ Gem source <%= @gem_source.name %> successfully created
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error deleting action <%= @error %>
4
+ <% else %>
5
+ Action <%= @name %> successfully deleted
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error deleting gem <%= @error %>
4
+ <% else %>
5
+ Gem <%= @name %> successfully deleted
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <% if @error %>
3
+ Error deleting gem source <%= @error %>
4
+ <% else %>
5
+ Gem source <%= @name %> successfully deleted
6
+ <% end %>
7
+ </p>
8
+
9
+ <p>Returning to the <%= link_to "index", :controller => :manage, :action => :list %></p>
10
+
11
+ <script type="text/javascript">
12
+ setTimeout(function() {
13
+ window.location.href = "<%= url_for :controller => :manage, :action => :list %>"; },
14
+ 3000);
15
+ </script>
@@ -0,0 +1,66 @@
1
+ <ul>
2
+ <% @gem_sources.each { |gem_source| %>
3
+ <li>
4
+ <h4><%= "#{gem_source.name}: #{link_to(gem_source.uri, gem_source.uri)}" %></h4>
5
+ <%= link_to("(delete)", {:action => :delete_gem_source, :id => gem_source.id}, :class => "delete_gem_source_link") %>
6
+
7
+ <ul>
8
+ <li>
9
+ <h5>Saved Searches</h5>
10
+ <%= link_to("(new)", :action => :new_gem_search_criteria, :gem_source_id => gem_source.id) %>
11
+ <ul>
12
+ <% gem_source.searches.each { |search_criteria| %>
13
+ <li>
14
+ <%= "#{search_criteria.regex}" %> (<%= link_to("delete", :action => :delete_gem_search_criteria, :id => search_criteria.id) %>)
15
+ </li>
16
+ <% } %>
17
+ </ul>
18
+ </li>
19
+
20
+ <li>
21
+ <h5>Gems being tracked</h5>
22
+ <%= link_to("(new)", :action => :new_gem, :gem_source_id => gem_source.id) %>
23
+ <ul>
24
+ <% gem_source.gems.each { |gem| %>
25
+ <li>
26
+ <%= "#{gem.name}" %>
27
+ <%= link_to("(delete)", {:action => :delete_gem, :id => gem.id}, :class => "delete_gem_link") %>
28
+ <br/><h6>Actions</h6> <%= link_to("(new action)", :action => :new_event_handler, :gem_id => gem.id) %>
29
+ <ul>
30
+ <% gem.event_handlers.each { |eh| %>
31
+ <li>
32
+ <%= "On " + eh.event.humanize + ", " + eh.handler.humanize %>
33
+ <%= link_to("(delete)", {:action => :delete_event_handler, :id => eh.id}, :class => "delete_action_link") %>
34
+ </li>
35
+ <% } %>
36
+ </ul>
37
+ </li>
38
+ <% } %>
39
+ </ul>
40
+ </li>
41
+ </ul>
42
+
43
+ </li>
44
+ <% } %>
45
+ </ul>
46
+
47
+ <script type="text/javascript">
48
+ $('.delete_gem_source_link').bind('click', function(e){
49
+ c = confirm("delete gem source?")
50
+ if(!c){
51
+ return false;
52
+ }
53
+ });
54
+ $('.delete_gem_link').bind('click', function(e){
55
+ c = confirm("delete gem?")
56
+ if(!c){
57
+ return false;
58
+ }
59
+ });
60
+ $('.delete_action_link').bind('click', function(e){
61
+ c = confirm("delete action?")
62
+ if(!c){
63
+ return false;
64
+ }
65
+ });
66
+ </script>
@@ -0,0 +1,38 @@
1
+ <p>
2
+ <h4>New Action</h4>
3
+ <form method="post" id="new_event_handler_form" action="<%= url_for :action => :create_event_handler %>">
4
+ <table>
5
+ <tr>
6
+ <td>Select Gem:</td>
7
+ <td>
8
+ <select id="gem_source_id", name="gem_id">
9
+ <% @gems.each { |gem| %>
10
+ <option id="<%= gem.id %>" value="<%= gem.id %>" <% if gem.id == @gem_id.to_i %>selected<% end %>><%= gem.source.name + ": " + gem.name + "-" + gem.version %></option>
11
+ <% } %>
12
+ </select>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <td>On Event:</td>
17
+ <td>
18
+ <select id="gem_source_id", name="event">
19
+ <% @events.each { |event| %>
20
+ <option id="<%= event %>" value="<%= event %>"><%= event.to_s.humanize %></option>
21
+ <% } %>
22
+ </select>
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td>Run Handler:</td>
27
+ <td>
28
+ <select id="gem_source_id", name="handler">
29
+ <% @handlers.each { |handler| %>
30
+ <option id="<%= handler %>" value="<%= handler %>"><%= handler.to_s.humanize %></option>
31
+ <% } %>
32
+ </select>
33
+ </td>
34
+ </tr>
35
+ <tr><td><input type="submit" value="submit"></input></td></tr>
36
+ </table>
37
+ </form>
38
+ </p>
@@ -0,0 +1,21 @@
1
+ <p>
2
+ <h4>New Gem</h4>
3
+ <form method="post" id="new_gem_source_form" action="<%= url_for :action => :create_gem %>">
4
+ <table>
5
+ <tr>
6
+ <td>Select Source:</td>
7
+ <td>
8
+ <select id="gem_source_id", name="gem_source_id">
9
+ <% @gem_sources.each { |gs| %>
10
+ <option id="<%= gs.id %>" value="<%= gs.id %>" <% if gs.id == @gem_source_id.to_i %>selected<% end %>><%= gs.name %></option>
11
+ <% } %>
12
+ </select>
13
+ </td>
14
+ </tr>
15
+ <!-- FIXME at some point prepopulate a list of gems from source, allow user to select (as an alternative to specifying name) -->
16
+ <tr><td>Name:</td><td><input id="name" name="name" type="text"></input></td></tr>
17
+ <tr><td>Version:</td><td><input id="version" name="version" type="text"></input></td></tr>
18
+ <tr><td><input type="submit" value="submit"></input></td></tr>
19
+ </table>
20
+ </form>
21
+ </p>
@@ -0,0 +1,3 @@
1
+ <p>
2
+ Not yet implemented
3
+ </p>
@@ -0,0 +1,10 @@
1
+ <p>
2
+ <h4>New Gem Source</h4>
3
+ <form method="post" id="new_gem_source_form" action="<%= url_for :action => :create_gem_source %>">
4
+ <table>
5
+ <tr><td>Name:</td><td><input id="name" name="name" type="text"></input></td></tr>
6
+ <tr><td>Base URI:</td><td><input id="uri" name="uri" type="text"></input></td></tr>
7
+ <tr><td><input type="submit" value="submit"></input></td></tr>
8
+ </table>
9
+ </form>
10
+ </p>
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ min_version = '1.3.2'
86
+ require 'rubygems'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!