rails_autobots 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/rails_autobots/application.js +13 -0
- data/app/assets/stylesheets/rails_autobots/application.css +15 -0
- data/app/controllers/rails_autobots/application_controller.rb +4 -0
- data/app/controllers/rails_autobots/releases_controller.rb +10 -0
- data/app/helpers/rails_autobots/application_helper.rb +4 -0
- data/app/views/layouts/rails_autobots/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/lib/rails_autobots.rb +21 -0
- data/lib/rails_autobots/engine.rb +9 -0
- data/lib/rails_autobots/environment_rewriter.rb +11 -0
- data/lib/rails_autobots/rewrite_ruleset.rb +40 -0
- data/lib/rails_autobots/version.rb +3 -0
- data/lib/tasks/rails_autobots_tasks.rake +4 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3b2e085f61575d8de40aeec2525de7c64bfeac7d
|
4
|
+
data.tar.gz: 46d95d25feffe5162834ecc12a04bac8fb5b1b4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2b070215f26a9b54a24f9b24e9be423334219a25fdf52d5996b757b3ff4e2f12a539251dab143a461190345a55f90f953ad98e2ad4c3b83e8d9c758a344c749
|
7
|
+
data.tar.gz: 11f2b1ffd3d38f909f52fb4109dcb671a9cb153530cc70a19899b56ff30ca4f101b4118f0f4eb0d0e35572d61211ab6a9593c1523268718ce308cb0d5068acc5
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsAutobots'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class RailsAutobots::ReleasesController < RailsAutobots::ApplicationController
|
2
|
+
def show
|
3
|
+
if m = RailsAutobots.redis.get("index:current")
|
4
|
+
rewritten = RailsAutobots.apply_rewrite_rules_on(m)
|
5
|
+
render text: rewritten, status: 200
|
6
|
+
else
|
7
|
+
render text: "", status: 500
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RailsAutobots</title>
|
5
|
+
<%= stylesheet_link_tag "rails_autobots/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "rails_autobots/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails_autobots/engine"
|
2
|
+
require "rails_autobots/rewrite_ruleset"
|
3
|
+
|
4
|
+
module RailsAutobots
|
5
|
+
def self.redis=(r)
|
6
|
+
@redis = r
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.redis
|
10
|
+
@redis
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.apply_rewrite_rules_on(markup)
|
14
|
+
@ruleset.rewrite(markup)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.rewrite_environment_for(environment_name, &block)
|
18
|
+
@ruleset ||= RailsAutobots::RewriteRuleset.new
|
19
|
+
@ruleset.add(environment_name, block)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class RailsAutobots::EnvironmentRewriter
|
2
|
+
def initialize(environment_name, rewrite_function)
|
3
|
+
@environment_name, @rewrite_function = environment_name, rewrite_function
|
4
|
+
end
|
5
|
+
|
6
|
+
def process(environment_name, environment)
|
7
|
+
if @environment_name == environment_name
|
8
|
+
@rewrite_function.call(environment)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rails_autobots/environment_rewriter"
|
2
|
+
|
3
|
+
class RailsAutobots::RewriteRuleset
|
4
|
+
def initialize
|
5
|
+
@rulesets = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def add(environment_name, rewrite_function)
|
9
|
+
@rulesets << RailsAutobots::EnvironmentRewriter.new(environment_name, rewrite_function)
|
10
|
+
end
|
11
|
+
|
12
|
+
def rewrite(markup)
|
13
|
+
d = Nokogiri::HTML(markup)
|
14
|
+
environments = environment_nodes(d)
|
15
|
+
any_rewritten = false
|
16
|
+
|
17
|
+
environments.each do |e|
|
18
|
+
name = strip_environment_suffix(e["name"])
|
19
|
+
content = JSON.parse(CGI.unescape(e["content"]))
|
20
|
+
original_content = content.deep_dup
|
21
|
+
@rulesets.each { |r| r.process(name, content) }
|
22
|
+
|
23
|
+
if original_content != content
|
24
|
+
any_rewritten = true
|
25
|
+
e["content"] = CGI.escape(content.to_json)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
any_rewritten ? d.to_html : markup
|
30
|
+
end
|
31
|
+
|
32
|
+
def environment_nodes(d)
|
33
|
+
d.css("meta[name$='/config/environment']")
|
34
|
+
end
|
35
|
+
|
36
|
+
def strip_environment_suffix(s)
|
37
|
+
i = s.index("/")
|
38
|
+
s[0...i]
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_autobots
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Don Petersen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fakeredis
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
97
|
+
description: Rails engine to load Javascript apps deployed by grunt-autobots
|
98
|
+
email:
|
99
|
+
- don@donpetersen.net
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- MIT-LICENSE
|
105
|
+
- Rakefile
|
106
|
+
- app/assets/javascripts/rails_autobots/application.js
|
107
|
+
- app/assets/stylesheets/rails_autobots/application.css
|
108
|
+
- app/controllers/rails_autobots/application_controller.rb
|
109
|
+
- app/controllers/rails_autobots/releases_controller.rb
|
110
|
+
- app/helpers/rails_autobots/application_helper.rb
|
111
|
+
- app/views/layouts/rails_autobots/application.html.erb
|
112
|
+
- config/routes.rb
|
113
|
+
- lib/rails_autobots.rb
|
114
|
+
- lib/rails_autobots/engine.rb
|
115
|
+
- lib/rails_autobots/environment_rewriter.rb
|
116
|
+
- lib/rails_autobots/rewrite_ruleset.rb
|
117
|
+
- lib/rails_autobots/version.rb
|
118
|
+
- lib/tasks/rails_autobots_tasks.rake
|
119
|
+
homepage: https://github.com/g5/rails_autobots
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.2.2
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Rails engine to load Javascript apps deployed by grunt-autobots
|
143
|
+
test_files: []
|
144
|
+
has_rdoc:
|