rails-sandbox-assets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/app/controllers/sandbox_assets/base_controller.rb +10 -0
- data/app/controllers/sandbox_assets/test_runner_controller.rb +5 -0
- data/app/views/sandbox_assets/test_runner/index.html.erb +22 -0
- data/config/routes.rb +6 -0
- data/lib/rails-sandbox-assets.rb +1 -0
- data/lib/sandbox_assets.rb +5 -0
- data/lib/sandbox_assets/engine.rb +13 -0
- data/lib/sandbox_assets/settings.rb +15 -0
- data/lib/sandbox_assets/test_asset.rb +24 -0
- data/lib/sandbox_assets/version.rb +3 -0
- data/lib/tasks/sandbox_assets.rake +10 -0
- data/rails-sandbox-assets.gemspec +19 -0
- metadata +84 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Rodrigo Rosenfeld Rosas
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Rails::Sandbox::Assets
|
2
|
+
|
3
|
+
Customize your test runner while taking advantage of the Rails asset pipeline.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rails-sandbox-assets'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
$ rake sandbox_assets:serve
|
18
|
+
|
19
|
+
Follow the instructions in http://localhost:5000 for how to override the void bundled test-runner.
|
20
|
+
|
21
|
+
## Settings
|
22
|
+
|
23
|
+
TODO: Talk about the engine config options
|
24
|
+
|
25
|
+
## Examples
|
26
|
+
|
27
|
+
TODO: Add some examples, like Jasmine and Mocha/Chai.js.
|
28
|
+
|
29
|
+
TODO: Also release some other gems for those frameworks on top of this one.
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
5
|
+
|
6
|
+
<title>Test runner</title>
|
7
|
+
<% @tests.each do |test| -%>
|
8
|
+
<%= javascript_include_tag test %>
|
9
|
+
<% end -%>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<p>Override this test runner with your own at app/views/sandbox_assets/test_runner/index.html.erb. The test list to include are available at @tests:</p>
|
13
|
+
<ul>
|
14
|
+
<% @tests.each do |test| -%>
|
15
|
+
<li><%= link_to test, asset_path(test) %></li>
|
16
|
+
<% end -%>
|
17
|
+
</ul>
|
18
|
+
|
19
|
+
<p>Here is the source for this file (<%= __FILE__ %>):</p>
|
20
|
+
<pre style="background-color: lightgreen; color: black"><%= IO.read __FILE__ %></pre>
|
21
|
+
</body>
|
22
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "sandbox_assets"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'sandbox_assets/settings'
|
2
|
+
|
3
|
+
module SandboxAssets
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
config.autoload_paths << File.expand_path("../lib/", __FILE__)
|
6
|
+
config.sandbox_assets = Settings.new
|
7
|
+
|
8
|
+
initializer "sandbox_assets" do |app|
|
9
|
+
config = app.config.sandbox_assets
|
10
|
+
app.config.assets.paths.concat config.assets_paths
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SandboxAssets
|
2
|
+
class Settings
|
3
|
+
attr_reader :options
|
4
|
+
attr_accessor :tests_roots, :assets_paths, :tests_patterns, :port
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@tests_roots = %w(test/javascripts specs/javascripts)
|
8
|
+
@assets_paths = @tests_roots +
|
9
|
+
%w(test/assets/javascripts test/assets/stylesheets)
|
10
|
+
@tests_patterns = %w(**/*_{test,spec}.{js,coffee}*)
|
11
|
+
@port = 5000
|
12
|
+
@options = {}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SandboxAssets
|
2
|
+
class TestAsset
|
3
|
+
class << self
|
4
|
+
def find_tests(params)
|
5
|
+
return all unless path = params[:path]
|
6
|
+
all.find_all {|fn| fn.start_with? path }
|
7
|
+
end
|
8
|
+
|
9
|
+
def all
|
10
|
+
config = Engine.config.sandbox_assets
|
11
|
+
files = []
|
12
|
+
config.tests_roots.each do |root|
|
13
|
+
config.tests_patterns.each do |pattern|
|
14
|
+
test_dir = Rails.root.join root
|
15
|
+
files.concat Dir[test_dir.join pattern].sort.map { |fn|
|
16
|
+
fn.sub(test_dir.to_s, '').sub(/(\.js|\.coffee).*/, '')[1..-1]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
files
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :sandbox_assets do
|
2
|
+
desc "Run Sandboxed Assets server"
|
3
|
+
task :serve => :environment do
|
4
|
+
app = SandboxAssets::Engine
|
5
|
+
port = app.config.sandbox_assets.port
|
6
|
+
|
7
|
+
puts "Your assets will be soon available at http://localhost:#{port}\n\n"
|
8
|
+
Rack::Server.start app: app, Port: port
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sandbox_assets/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Rodrigo Rosenfeld Rosas"]
|
6
|
+
gem.email = ["rr.rosas@gmail.com"]
|
7
|
+
gem.summary = %q{Allows assets to be served in a sandboxed application in a Rails project}
|
8
|
+
gem.description = %q{Override your test runner and run rake sandbox_assets:serve}
|
9
|
+
gem.homepage = "http://github.com/rosenfeld/rails-sandbox-assets"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rails-sandbox-assets"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = SandboxAssets::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'rails', '~> 3.1'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-sandbox-assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rodrigo Rosenfeld Rosas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
description: Override your test runner and run rake sandbox_assets:serve
|
31
|
+
email:
|
32
|
+
- rr.rosas@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- app/controllers/sandbox_assets/base_controller.rb
|
43
|
+
- app/controllers/sandbox_assets/test_runner_controller.rb
|
44
|
+
- app/views/sandbox_assets/test_runner/index.html.erb
|
45
|
+
- config/routes.rb
|
46
|
+
- lib/rails-sandbox-assets.rb
|
47
|
+
- lib/sandbox_assets.rb
|
48
|
+
- lib/sandbox_assets/engine.rb
|
49
|
+
- lib/sandbox_assets/settings.rb
|
50
|
+
- lib/sandbox_assets/test_asset.rb
|
51
|
+
- lib/sandbox_assets/version.rb
|
52
|
+
- lib/tasks/sandbox_assets.rake
|
53
|
+
- rails-sandbox-assets.gemspec
|
54
|
+
homepage: http://github.com/rosenfeld/rails-sandbox-assets
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
hash: -2162416191991109472
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
hash: -2162416191991109472
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.8.21
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Allows assets to be served in a sandboxed application in a Rails project
|
84
|
+
test_files: []
|