rails-sandbox-assets 0.0.3 → 0.0.4

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.
@@ -3,6 +3,7 @@ require "sandbox_assets/test_asset"
3
3
  module SandboxAssets
4
4
  class BaseController < ActionController::Base
5
5
  before_filter :find_tests
6
+ before_filter :find_stylesheets
6
7
  before_filter :extract_template_from_params
7
8
  before_filter :render_template
8
9
 
@@ -17,6 +18,10 @@ module SandboxAssets
17
18
  @tests = TestAsset.find_tests(params)
18
19
  end
19
20
 
21
+ def find_stylesheets
22
+ @stylesheets = TestAsset.find_stylesheets(params)
23
+ end
24
+
20
25
  def extract_template_from_params
21
26
  @template ||= params[:template] unless cfg.disable_template_param
22
27
  end
@@ -4,6 +4,9 @@
4
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
5
 
6
6
  <title>Test runner</title>
7
+ <% @stylesheets.each do |css| -%>
8
+ <%= stylesheet_link_tag css %>
9
+ <% end -%>
7
10
  <% @tests.each do |test| -%>
8
11
  <%= javascript_include_tag test %>
9
12
  <% end -%>
@@ -12,9 +15,16 @@
12
15
  <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
16
  <ul>
14
17
  <% @tests.each do |test| -%>
15
- <li><%= link_to test, asset_path(test) %></li>
18
+ <li><%= link_to test, javascript_path(test) %></li>
16
19
  <% end -%>
17
20
  </ul>
21
+ <p>And those stylesheets will be also included:</p>
22
+ <ul>
23
+
24
+ <% @stylesheets.each do |css| -%>
25
+ <li><%= link_to css, stylesheet_path(css) %></li>
26
+ <% end -%>
27
+ </ul>
18
28
 
19
29
  <p>Here is the source for this file (<%= __FILE__ %>):</p>
20
30
  <pre style="background-color: lightgreen; color: black"><%= IO.read __FILE__ %></pre>
@@ -1,7 +1,8 @@
1
1
  module SandboxAssets
2
2
  class Settings
3
3
  attr_reader :options
4
- attr_accessor :tests_roots, :assets_paths, :tests_patterns, :port,
4
+ attr_accessor :tests_roots, :assets_paths, :port,
5
+ :tests_patterns, :stylesheets_patterns,
5
6
  :template, :disable_template_param
6
7
 
7
8
  def initialize
@@ -10,6 +11,7 @@ module SandboxAssets
10
11
  %w(test/assets/javascripts test/assets/stylesheets
11
12
  spec/assets/javascripts spec/assets/stylesheets)
12
13
  @tests_patterns = %w(**/*_{test,spec}.{js,coffee}*)
14
+ @stylesheets_patterns = %w(**/*_{test,spec}.{css,scss,sass,less}*)
13
15
  @port = 5000
14
16
  @disable_template_param = false
15
17
  @options = {}
@@ -2,23 +2,36 @@ module SandboxAssets
2
2
  class TestAsset
3
3
  class << self
4
4
  def find_tests(params)
5
- return all unless path = params[:path]
6
- all.find_all {|fn| fn.start_with? path }
5
+ find params, all(config.tests_patterns, /(\.js|\.coffee).*/)
7
6
  end
8
7
 
9
- def all
10
- config = Engine.config.sandbox_assets
8
+ def find_stylesheets(params)
9
+ find params, all(config.stylesheets_patterns, /(\.css|\.scss|\.sass|\.less).*/)
10
+ end
11
+
12
+ protected
13
+
14
+ def find(params, file_list)
15
+ return file_list unless path = params[:path]
16
+ file_list.find_all {|fn| fn.start_with? path }
17
+ end
18
+
19
+ def all(patterns, remove_regexp)
11
20
  files = []
12
21
  config.tests_roots.each do |root|
13
- config.tests_patterns.each do |pattern|
22
+ patterns.each do |pattern|
14
23
  test_dir = Rails.root.join root
15
24
  files.concat Dir[test_dir.join pattern].sort.map { |fn|
16
- fn.sub(test_dir.to_s, '').sub(/(\.js|\.coffee).*/, '')[1..-1]
25
+ fn.sub(test_dir.to_s, '').sub(remove_regexp, '')[1..-1]
17
26
  }
18
27
  end
19
28
  end
20
29
  files
21
30
  end
31
+
32
+ def config
33
+ @@config ||= Engine.config.sandbox_assets
34
+ end
22
35
  end
23
36
  end
24
37
  end
@@ -1,3 +1,3 @@
1
1
  module SandboxAssets
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-sandbox-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -65,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
65
  version: '0'
66
66
  segments:
67
67
  - 0
68
- hash: -177298000205036705
68
+ hash: -2556634665115716922
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  segments:
76
76
  - 0
77
- hash: -177298000205036705
77
+ hash: -2556634665115716922
78
78
  requirements: []
79
79
  rubyforge_project:
80
80
  rubygems_version: 1.8.21