engine-assets 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{engine-assets}
8
- s.version = "0.3.3"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Corey Innis"]
12
- s.date = %q{2009-11-17}
12
+ s.date = %q{2009-11-18}
13
13
  s.description = %q{A Rails Engine, which enables Rails Engines to provide assets (javascript, css and images)}
14
14
  s.email = %q{support@coolerator.net}
15
15
  s.extra_rdoc_files = [
@@ -31,14 +31,10 @@ Gem::Specification.new do |s|
31
31
  "engine-assets.gemspec",
32
32
  "lib/engine-assets.rb",
33
33
  "lib/engine_assets/extensions/rails/assets.rb",
34
- "lib/engine_assets/extensions/rails/plugins.rb",
35
- "lib/engine_assets/extensions/rails/routes.rb",
36
34
  "lib/engine_assets/public_locator.rb",
37
35
  "rails/init.rb",
38
36
  "spec/controllers/javascripts_controller_spec.rb",
39
37
  "spec/controllers/stylesheets_controller_spec.rb",
40
- "spec/lib/engine_assets/extensions/rails/plugins_spec.rb",
41
- "spec/lib/engine_assets/extensions/rails/routes_spec.rb",
42
38
  "spec/lib/engine_assets/public_locator_spec.rb",
43
39
  "spec/routing/javascripts_routing_spec.rb",
44
40
  "spec/routing/stylesheets_routing_spec.rb",
@@ -64,8 +60,6 @@ Gem::Specification.new do |s|
64
60
  s.test_files = [
65
61
  "spec/controllers/javascripts_controller_spec.rb",
66
62
  "spec/controllers/stylesheets_controller_spec.rb",
67
- "spec/lib/engine_assets/extensions/rails/plugins_spec.rb",
68
- "spec/lib/engine_assets/extensions/rails/routes_spec.rb",
69
63
  "spec/lib/engine_assets/public_locator_spec.rb",
70
64
  "spec/routing/javascripts_routing_spec.rb",
71
65
  "spec/routing/stylesheets_routing_spec.rb",
data/lib/engine-assets.rb CHANGED
@@ -2,5 +2,3 @@ module EngineAssets ; end
2
2
 
3
3
  require 'engine_assets/public_locator'
4
4
  require 'engine_assets/extensions/rails/assets'
5
- require 'engine_assets/extensions/rails/plugins'
6
- require 'engine_assets/extensions/rails/routes'
@@ -1,7 +1,14 @@
1
1
  class EngineAssets::PublicLocator
2
2
  class << self
3
- def paths
3
+ attr_reader :paths
4
+
5
+ def register(full_path)
4
6
  @paths ||= []
7
+
8
+ public_path = File.join(full_path, 'public')
9
+ File.open(public_path) {}
10
+
11
+ paths << public_path
5
12
  end
6
13
 
7
14
  def locate(file_path)
@@ -11,5 +18,12 @@ class EngineAssets::PublicLocator
11
18
  end
12
19
  nil
13
20
  end
21
+
22
+
23
+ private
24
+
25
+ def clear
26
+ @paths = []
27
+ end
14
28
  end
15
29
  end
@@ -5,11 +5,36 @@ describe EngineAssets::PublicLocator do
5
5
 
6
6
  before do
7
7
  @base_path = File.join('fixtures', 'public')
8
- @full_path = File.join(basedir, 'spec', 'support', base_path)
8
+ @full_path = File.join(basedir, 'spec', 'support', 'fixtures')
9
9
  @find_path = '/javascripts/dual.js'
10
10
  @miss_path = '/javascripts/miss.js'
11
11
 
12
- EngineAssets::PublicLocator.paths << base_path
12
+ EngineAssets::PublicLocator.send(:clear)
13
+ EngineAssets::PublicLocator.register(full_path)
14
+ end
15
+
16
+ describe "#register" do
17
+ context "when the suggest path does not exist" do
18
+ it "raises an exception" do
19
+ lambda {
20
+ EngineAssets::PublicLocator.register('bogus')
21
+ }.should raise_error(Errno::ENOENT)
22
+ end
23
+ end
24
+
25
+ context "when the suggest path does not contain a 'public' directory" do
26
+ it "raises an exception" do
27
+ lambda {
28
+ EngineAssets::PublicLocator.register(File.dirname(__FILE__))
29
+ }.should raise_error(Errno::ENOENT)
30
+ end
31
+ end
32
+
33
+ context "when the suggest path is valid" do
34
+ it "adds the path" do
35
+ EngineAssets::PublicLocator.paths.should == ["#{full_path}/public"]
36
+ end
37
+ end
13
38
  end
14
39
 
15
40
  describe "#locate" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'config/routes'
2
3
 
3
4
  describe "A controller routed as an AssetsController", :shared => true do
4
5
  attr_reader :prefix, :format
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engine-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Innis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-17 00:00:00 -05:00
12
+ date: 2009-11-18 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,14 +46,10 @@ files:
46
46
  - engine-assets.gemspec
47
47
  - lib/engine-assets.rb
48
48
  - lib/engine_assets/extensions/rails/assets.rb
49
- - lib/engine_assets/extensions/rails/plugins.rb
50
- - lib/engine_assets/extensions/rails/routes.rb
51
49
  - lib/engine_assets/public_locator.rb
52
50
  - rails/init.rb
53
51
  - spec/controllers/javascripts_controller_spec.rb
54
52
  - spec/controllers/stylesheets_controller_spec.rb
55
- - spec/lib/engine_assets/extensions/rails/plugins_spec.rb
56
- - spec/lib/engine_assets/extensions/rails/routes_spec.rb
57
53
  - spec/lib/engine_assets/public_locator_spec.rb
58
54
  - spec/routing/javascripts_routing_spec.rb
59
55
  - spec/routing/stylesheets_routing_spec.rb
@@ -101,8 +97,6 @@ summary: Rails Engines with assets.
101
97
  test_files:
102
98
  - spec/controllers/javascripts_controller_spec.rb
103
99
  - spec/controllers/stylesheets_controller_spec.rb
104
- - spec/lib/engine_assets/extensions/rails/plugins_spec.rb
105
- - spec/lib/engine_assets/extensions/rails/routes_spec.rb
106
100
  - spec/lib/engine_assets/public_locator_spec.rb
107
101
  - spec/routing/javascripts_routing_spec.rb
108
102
  - spec/routing/stylesheets_routing_spec.rb
@@ -1,12 +0,0 @@
1
- class Rails::Plugin
2
- class Loader
3
- def register_plugin_as_loaded_with_engine_assets(plugin)
4
- register_plugin_as_loaded_without_engine_assets(plugin)
5
-
6
- if(plugin.engine? && File.exist?(public_dir = File.join(plugin.directory, 'public')))
7
- EngineAssets::PublicLocator.paths << public_dir
8
- end
9
- end
10
- alias_method_chain :register_plugin_as_loaded, :engine_assets
11
- end
12
- end
@@ -1,16 +0,0 @@
1
- if defined?(ActionController::Routing::RouteSet)
2
- class ActionController::Routing::RouteSet
3
- def load_routes_with_assets!
4
- lib_path = File.dirname(__FILE__)
5
- engine_routes = File.join(lib_path, *%w[.. .. .. .. config routes.rb])
6
-
7
- unless configuration_files.include?(engine_routes)
8
- add_configuration_file(engine_routes)
9
- end
10
-
11
- load_routes_without_assets!
12
- end
13
-
14
- alias_method_chain :load_routes!, :assets
15
- end
16
- end
@@ -1,52 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Rails::Plugin::Loader do
4
- attr_reader :loader, :plugin, :directory
5
-
6
- before do
7
- @loader = Rails::Plugin::Loader.new(OpenStruct.new({ :loaded_plugins => [] }))
8
- end
9
-
10
- describe "#register_plugin_as_loaded" do
11
- before do
12
- paths = []
13
- stub(EngineAssets::PublicLocator).paths { paths }
14
- end
15
-
16
- context "given a plugin which is an engine and contains a 'public' directory" do
17
- before do
18
- @directory = File.join(basedir, 'spec', 'support', 'fixtures')
19
- @plugin = OpenStruct.new({ :engine? => true, :directory => directory })
20
- end
21
-
22
- it "registers the plugin with the EngineAssets::PublicLocator" do
23
- loader.send(:register_plugin_as_loaded, plugin)
24
- EngineAssets::PublicLocator.paths.should == [ "#{directory}/public" ]
25
- end
26
- end
27
-
28
- context "given a plugin which is an engine and does NOT contain a 'public' directory" do
29
- before do
30
- @directory = basedir
31
- @plugin = OpenStruct.new({ :engine? => true, :directory => directory })
32
- end
33
-
34
- it "does not register the plugin with the EngineAssets::PublicLocator" do
35
- loader.send(:register_plugin_as_loaded, plugin)
36
- EngineAssets::PublicLocator.paths.should == []
37
- end
38
- end
39
-
40
- context "given a plugin which is NOT an engine" do
41
- before do
42
- @directory = File.join(basedir, 'spec', 'support', 'fixtures')
43
- @plugin = OpenStruct.new({ :engine? => false, :directory => directory })
44
- end
45
-
46
- it "does not register the plugin with the EngineAssets::PublicLocator" do
47
- loader.send(:register_plugin_as_loaded, plugin)
48
- EngineAssets::PublicLocator.paths.should == []
49
- end
50
- end
51
- end
52
- end
@@ -1,28 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe ActionController::Routing::RouteSet do
4
- describe "#load_routes!" do
5
- class TestRouteSet < ActionController::Routing::RouteSet
6
- attr_reader :configuration_files
7
-
8
- def initialize
9
- @configuration_files = []
10
- end
11
-
12
- def add_configuration_file(routes)
13
- configuration_files << routes
14
- end
15
- end
16
-
17
- attr_reader :routeset
18
-
19
- before do
20
- @routeset = TestRouteSet.new
21
- end
22
-
23
- it "adds the engine-assets routes configuration" do
24
- routeset.load_routes!
25
- routeset.configuration_files[0].should =~ /engine[-_ ]assets.*\/config\/routes\.rb/
26
- end
27
- end
28
- end