stylo 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,29 +2,32 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'cucumber'
4
4
  require 'cucumber/rake/task'
5
+ require 'bundler'
5
6
 
6
- begin
7
- require 'jeweler'
8
- Jeweler::Tasks.new do |gem|
9
- gem.name = "stylo"
10
- gem.summary = %Q{Server side stylesheet combining for readonly hosting environments}
11
- gem.description = %Q{Server side stylesheet combining for readonly hosting environments}
12
- gem.email = "michael@guerillatactics.co.uk"
13
- gem.homepage = "http://github.com/mwagg/stylo"
14
- gem.authors = ["mwagg"]
15
- gem.add_development_dependency "rspec", ">= 0"
16
- gem.add_development_dependency "cucumber", ">= 0"
17
- gem.add_development_dependency "rack-test", ">= 0"
18
- gem.add_development_dependency "sinatra", ">= 0"
19
- gem.add_development_dependency "rails", ">= 3.0.0"
20
- gem.add_runtime_dependency "haml", ">= 3.0.21"
21
- gem.version = "0.7.0"
22
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
- end
24
- Jeweler::GemcutterTasks.new
25
- rescue LoadError
26
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
27
- end
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ #begin
10
+ # require 'jeweler'
11
+ # Jeweler::Tasks.new do |gem|
12
+ # gem.name = "stylo"
13
+ # gem.summary = %Q{Server side stylesheet combining for readonly hosting environments}
14
+ # gem.description = %Q{Server side stylesheet combining for readonly hosting environments}
15
+ # gem.email = "michael@guerillatactics.co.uk"
16
+ # gem.homepage = "http://github.com/mwagg/stylo"
17
+ # gem.authors = ["mwagg"]
18
+ # gem.add_development_dependency "rspec", ">= 0"
19
+ # gem.add_development_dependency "cucumber", ">= 0"
20
+ # gem.add_development_dependency "rack-test", ">= 0"
21
+ # gem.add_development_dependency "sinatra", ">= 0"
22
+ # gem.add_development_dependency "rails", ">= 3.0.0"
23
+ # gem.add_runtime_dependency "haml", ">= 3.0.21"
24
+ # gem.version = "0.7.0"
25
+ # # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
26
+ # end
27
+ # Jeweler::GemcutterTasks.new
28
+ #rescue LoadError
29
+ # puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
30
+ #end
28
31
 
29
32
  require 'rspec/core/rake_task'
30
33
  desc "Run all examples"
data/TODO CHANGED
@@ -1,4 +1,3 @@
1
1
  make configuration nicer and more flexible
2
- add minification for javascript
3
2
  add minification for css
4
- make it so sass is not used if the sass gem is not available (without making the pipeline configuration messy)
3
+ set etags
@@ -1,4 +1,6 @@
1
1
  Feature: Javascript serving
2
+ Background:
3
+ Given javascript minifying is disabled
2
4
 
3
5
  Scenario: Simple javascript serving
4
6
  Given "child.js" is located at "javascripts" in the asset location
@@ -26,7 +28,7 @@ Feature: Javascript serving
26
28
  Then the response body should look like "grand_parent_with_parent_with_child.js"
27
29
 
28
30
  Scenario: Minifying javascript
29
- Given javascript compression is enabled
31
+ Given javascript minifying is enabled
30
32
  And "child.js" is located at "javascripts" in the asset location
31
33
  When a request is made for "javascripts/child.js"
32
34
  Then the response body should look like "child-min.js"
@@ -4,10 +4,10 @@ Feature: Response headers
4
4
  Given "child.js" is located at "javascripts" in the asset location
5
5
  When a request is made for "javascripts/child.js"
6
6
  Then the response code should be "200"
7
- And the "Content-Length" header should be "40"
7
+ And the "Content-Length" header should be "34"
8
8
  And the "Content-Type" header should be "text/javascript"
9
9
 
10
10
  Scenario: Content should be cached
11
11
  Given "child.js" is located at "javascripts" in the asset location
12
12
  When a request is made for "javascripts/child.js"
13
- Then the "Cache-Control" header should be "public, max-age=86400"
13
+ Then the "Cache-Control" header should be "public, max-age=86400"
@@ -34,13 +34,21 @@ Then /^the response should be from a call back into rack$/ do
34
34
  end
35
35
 
36
36
  When /^javascript combining is disabled$/ do
37
- Stylo::Config.javascript_combining_enabled = false
37
+ Stylo::Config.options[:js_combining_enabled] = false
38
38
  end
39
39
 
40
40
  When /^css combining is disabled$/ do
41
- Stylo::Config.css_combining_enabled = false
41
+ Stylo::Config.options[:css_combining_enabled] = false
42
42
  end
43
43
 
44
- Given /^javascript compression is enabled$/ do
45
- Stylo::Config.javascript_minifying_enabled = true
44
+ #Given /^javascript compression is enabled$/ do
45
+ # Stylo::Config.options[:javascript_minifying_enabled] = true
46
+ #end
47
+
48
+ Given /^javascript minifying is disabled$/ do
49
+ Stylo::Config.options[:js_minifying_enabled] = false
50
+ end
51
+
52
+ Given /^javascript minifying is enabled$/ do
53
+ Stylo::Config.options[:js_minifying_enabled] = true
46
54
  end
@@ -19,10 +19,11 @@ World do
19
19
  end
20
20
  end
21
21
 
22
- reset_paths
22
+ true
23
23
  end
24
24
 
25
25
  Before do
26
26
  Stylo::Config.reset_to_default
27
+ reset_paths
27
28
  end
28
29
 
@@ -1,9 +1,9 @@
1
1
  module Stylo
2
2
  class AssetLoader
3
3
  def self.load_content(path)
4
- path = File.join(Stylo::Config.asset_location, path)
4
+ path = File.join(Stylo::Config.options[:asset_location], path)
5
5
 
6
6
  File.read(path) if File.exist?(path)
7
7
  end
8
8
  end
9
- end
9
+ end
data/lib/stylo/config.rb CHANGED
@@ -1,23 +1,30 @@
1
1
  module Stylo
2
2
  class Config
3
3
  class << self
4
- attr_accessor :asset_location, :css_combining_enabled, :javascript_combining_enabled, :javascript_minifying_enabled
4
+ def options
5
+ @options ||= defaults.clone
6
+ end
7
+
8
+ def defaults
9
+ {
10
+ :css_combining_enabled => true,
11
+ :js_combining_enabled => true,
12
+ :js_minifying_enabled => true
13
+ }
14
+ end
5
15
 
6
16
  def pipeline
7
17
  [Stylo::PipelineSteps::Stylesheet.new,
8
18
  Stylo::PipelineSteps::Javascript.new,
9
- Stylo::PipelineSteps::Sass.new,
10
19
  Stylo::PipelineSteps::JavascriptMinifying.new,
11
20
  Stylo::PipelineSteps::Caching.new]
12
21
  end
13
22
 
14
23
  def reset_to_default
15
- self.css_combining_enabled = true
16
- self.javascript_combining_enabled = true
17
- self.javascript_minifying_enabled = false
24
+ @options = defaults.clone
18
25
  end
19
26
  end
20
27
 
21
28
  reset_to_default
22
29
  end
23
- end
30
+ end
@@ -4,10 +4,12 @@ module Stylo
4
4
  REQUIRE_PATTERN = /\/\/\/require "(.*)";/
5
5
 
6
6
  def call(response)
7
+ raise 'You must set the asset location (Stylo::Config.options[:asset_location]) before stylo can be used.' if !Config.options[:asset_location]
8
+
7
9
  return if response.has_content? || response.extension != '.js'
8
10
  return unless content = AssetLoader.load_content(response.path)
9
11
 
10
- if Config.javascript_combining_enabled
12
+ if Config.options[:js_combining_enabled]
11
13
  content = Combiner.new(REQUIRE_PATTERN).process(File.dirname(response.path), content)
12
14
  end
13
15
 
@@ -2,10 +2,10 @@ module Stylo
2
2
  module PipelineSteps
3
3
  class JavascriptMinifying
4
4
  def call(response)
5
- if Config.javascript_minifying_enabled and response.extension == '.js' and response.has_content?
5
+ if Config.options[:js_minifying_enabled] and response.extension == '.js' and response.has_content?
6
6
  response.set_body(JSMin.new(response.body).minify, :javascript)
7
7
  end
8
8
  end
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -4,10 +4,12 @@ module Stylo
4
4
 
5
5
  class Stylesheet
6
6
  def call(response)
7
+ raise 'You must set the asset location (Stylo::Config.options[:asset_location]) before stylo can be used.' if !Config.options[:asset_location]
8
+
7
9
  return if response.has_content? || response.extension != '.css'
8
10
  return unless content = AssetLoader.load_content(response.path)
9
11
 
10
- if Config.css_combining_enabled
12
+ if Config.options[:css_combining_enabled]
11
13
  content = Combiner.new(REQUIRE_PATTERN).process(File.dirname(response.path), content)
12
14
  end
13
15
 
data/lib/stylo/railtie.rb CHANGED
@@ -4,7 +4,7 @@ begin
4
4
  module Stylo
5
5
  class Railtie < Rails::Railtie
6
6
  initializer "stylo.initialize" do |app|
7
- Stylo::Config.asset_location ||= File.join(app.root, 'public')
7
+ Stylo::Config.options[:asset_location] ||= File.join(app.root, 'public')
8
8
  app.middleware.insert_before ActionDispatch::Static, Stylo::Rack
9
9
  end
10
10
  end
@@ -0,0 +1,3 @@
1
+ module Stylo
2
+ VERSION = "0.8.0"
3
+ end
data/lib/stylo.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
 
3
- Dir.glob(File.join(File.dirname(__FILE__), '**/*.rb')).each { |f| require f }
3
+ Dir.glob(File.join(File.dirname(__FILE__), '**/*.rb')).reject do |filename|
4
+ filename =~ /version.rb$/
5
+ end.each { |f| require f }
4
6
 
5
7
 
@@ -13,4 +13,4 @@ describe Stylo::AssetLoader do
13
13
  Stylo::AssetLoader.load_content('javascripts/i_exist.js').should == content
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Stylo::PipelineSteps::JavascriptMinifying do
4
4
  before(:each) do
5
- Stylo::Config.javascript_minifying_enabled = true
5
+ Stylo::Config.options[:javascript_minifying_enabled] = true
6
6
  end
7
7
 
8
8
  let(:step) { Stylo::PipelineSteps::JavascriptMinifying.new }
@@ -44,4 +44,4 @@ describe Stylo::PipelineSteps::JavascriptMinifying do
44
44
  response.body.should == minified_javascript
45
45
  end
46
46
  end
47
- end
47
+ end
@@ -52,7 +52,7 @@ describe Stylo::PipelineSteps::Javascript do
52
52
 
53
53
  describe "and combining is enabled" do
54
54
  before(:each) do
55
- Stylo::Config.javascript_combining_enabled = true
55
+ Stylo::Config.options[:javascript_combining_enabled] = true
56
56
  end
57
57
 
58
58
  it "should tell the combiner to process the javascript content" do
@@ -71,7 +71,7 @@ describe Stylo::PipelineSteps::Javascript do
71
71
 
72
72
  describe "and combining is disabled" do
73
73
  before(:each) do
74
- Stylo::Config.javascript_combining_enabled = false
74
+ Stylo::Config.options[:js_combining_enabled] = false
75
75
  end
76
76
 
77
77
  it "should set the body of the response to the javascript content" do
@@ -52,7 +52,7 @@ describe Stylo::PipelineSteps::Stylesheet do
52
52
 
53
53
  describe "and combining is enabled" do
54
54
  before(:each) do
55
- Stylo::Config.css_combining_enabled = true
55
+ Stylo::Config.options[:css_combining_enabled] = true
56
56
  end
57
57
 
58
58
  it "should tell the combiner to process the stylesheet content" do
@@ -71,7 +71,7 @@ describe Stylo::PipelineSteps::Stylesheet do
71
71
 
72
72
  describe "and combining is disabled" do
73
73
  before(:each) do
74
- Stylo::Config.css_combining_enabled = false
74
+ Stylo::Config.options[:css_combining_enabled] = false
75
75
  end
76
76
 
77
77
  it "should set the body of the response to the stylesheet content" do
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
+ require 'fileutils'
3
4
 
4
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -11,8 +12,8 @@ RSpec.configure do |config|
11
12
  config.include FileUtils
12
13
 
13
14
  config.before(:each) do
14
- reset_paths
15
15
  Stylo::Config.reset_to_default
16
+ reset_paths
16
17
  end
17
18
  end
18
19
 
@@ -25,6 +25,6 @@ module StyloSpecHelpers
25
25
  mkdir_p path
26
26
  end
27
27
 
28
- Stylo::Config.asset_location = temp_path()
28
+ Stylo::Config.options[:asset_location] = temp_path()
29
29
  end
30
30
  end
data/stylo.gemspec CHANGED
@@ -1,126 +1,29 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "stylo/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{stylo}
8
- s.version = "0.7.0"
6
+ s.name = "stylo"
7
+ s.version = Stylo::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Mike Wagg"]
10
+ s.email = ["michael@guerillatactics.co.uk"]
11
+ s.homepage = "http://rubygems.org/gems/stylo" # CHECK THIS
12
+ s.summary = %q{A javascript and css combining/minifying rack middleware}
13
+ s.description = %q{A rack middleware which does css and javascript combining
14
+ and minification for sites hosted in readonly filesystem environments
15
+ such as heroku.com}
9
16
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["mwagg"]
12
- s.date = %q{2010-11-11}
13
- s.description = %q{Server side stylesheet combining for readonly hosting environments}
14
- s.email = %q{michael@guerillatactics.co.uk}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc",
18
- "TODO"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "TODO",
27
- "cucumber.yml",
28
- "features/fixtures.rb",
29
- "features/fixtures/child-min.js",
30
- "features/fixtures/child.css",
31
- "features/fixtures/child.js",
32
- "features/fixtures/grand_parent.css",
33
- "features/fixtures/grand_parent.js",
34
- "features/fixtures/grand_parent_with_parent_with_child.css",
35
- "features/fixtures/grand_parent_with_parent_with_child.js",
36
- "features/fixtures/nested_folder_grand_parent.css",
37
- "features/fixtures/nested_folder_grand_parent_with_parent_with_child.css",
38
- "features/fixtures/parent.css",
39
- "features/fixtures/parent.js",
40
- "features/fixtures/parent_with_child.css",
41
- "features/fixtures/parent_with_child.js",
42
- "features/fixtures/processed_sass_child.css",
43
- "features/fixtures/processed_sass_which_uses_mixin.css",
44
- "features/fixtures/sass_child.scss",
45
- "features/fixtures/sass_mixins.scss",
46
- "features/fixtures/sass_which_uses_mixin.scss",
47
- "features/javascripts.feature",
48
- "features/response_headers.feature",
49
- "features/sass_integration.feature",
50
- "features/step_definitions/stylo_steps.rb",
51
- "features/stylesheets.feature",
52
- "features/stylo_cannot_serve_asset.feature",
53
- "features/support/env.rb",
54
- "lib/jsmin.rb",
55
- "lib/stylo.rb",
56
- "lib/stylo/asset_loader.rb",
57
- "lib/stylo/combiner.rb",
58
- "lib/stylo/config.rb",
59
- "lib/stylo/pipeline_steps/caching.rb",
60
- "lib/stylo/pipeline_steps/javascript.rb",
61
- "lib/stylo/pipeline_steps/javascript_minifying.rb",
62
- "lib/stylo/pipeline_steps/sass.rb",
63
- "lib/stylo/pipeline_steps/stylesheet.rb",
64
- "lib/stylo/processor.rb",
65
- "lib/stylo/rack.rb",
66
- "lib/stylo/railtie.rb",
67
- "lib/stylo/response.rb",
68
- "spec/asset_loader_spec.rb",
69
- "spec/combiner_spec.rb",
70
- "spec/pipeline_steps/caching_spec.rb",
71
- "spec/pipeline_steps/javascript_minifying_spec.rb",
72
- "spec/pipeline_steps/javascript_spec.rb",
73
- "spec/pipeline_steps/sass_spec.rb",
74
- "spec/pipeline_steps/stylesheet_spec.rb",
75
- "spec/rack_spec.rb",
76
- "spec/spec_helper.rb",
77
- "spec/stylo_spec_helpers.rb",
78
- "stylo.gemspec"
79
- ]
80
- s.homepage = %q{http://github.com/mwagg/stylo}
81
- s.rdoc_options = ["--charset=UTF-8"]
82
- s.require_paths = ["lib"]
83
- s.rubygems_version = %q{1.3.7}
84
- s.summary = %q{Server side stylesheet combining for readonly hosting environments}
85
- s.test_files = [
86
- "spec/asset_loader_spec.rb",
87
- "spec/combiner_spec.rb",
88
- "spec/pipeline_steps/caching_spec.rb",
89
- "spec/pipeline_steps/javascript_minifying_spec.rb",
90
- "spec/pipeline_steps/javascript_spec.rb",
91
- "spec/pipeline_steps/sass_spec.rb",
92
- "spec/pipeline_steps/stylesheet_spec.rb",
93
- "spec/rack_spec.rb",
94
- "spec/spec_helper.rb",
95
- "spec/stylo_spec_helpers.rb"
96
- ]
17
+ s.rubyforge_project = "stylo"
97
18
 
98
- if s.respond_to? :specification_version then
99
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
100
- s.specification_version = 3
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
101
23
 
102
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
103
- s.add_development_dependency(%q<rspec>, [">= 0"])
104
- s.add_development_dependency(%q<cucumber>, [">= 0"])
105
- s.add_development_dependency(%q<rack-test>, [">= 0"])
106
- s.add_development_dependency(%q<sinatra>, [">= 0"])
107
- s.add_development_dependency(%q<rails>, [">= 3.0.0"])
108
- s.add_runtime_dependency(%q<haml>, [">= 3.0.21"])
109
- else
110
- s.add_dependency(%q<rspec>, [">= 0"])
111
- s.add_dependency(%q<cucumber>, [">= 0"])
112
- s.add_dependency(%q<rack-test>, [">= 0"])
113
- s.add_dependency(%q<sinatra>, [">= 0"])
114
- s.add_dependency(%q<rails>, [">= 3.0.0"])
115
- s.add_dependency(%q<haml>, [">= 3.0.21"])
116
- end
117
- else
118
- s.add_dependency(%q<rspec>, [">= 0"])
119
- s.add_dependency(%q<cucumber>, [">= 0"])
120
- s.add_dependency(%q<rack-test>, [">= 0"])
121
- s.add_dependency(%q<sinatra>, [">= 0"])
122
- s.add_dependency(%q<rails>, [">= 3.0.0"])
123
- s.add_dependency(%q<haml>, [">= 3.0.21"])
124
- end
24
+ s.add_development_dependency('cucumber')
25
+ s.add_development_dependency('rspec', '>= 2.1.0')
26
+ s.add_development_dependency('bundler')
27
+ s.add_development_dependency('rack-test')
28
+ s.add_development_dependency('sinatra')
125
29
  end
126
-
metadata CHANGED
@@ -1,25 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
- - mwagg
13
+ - Mike Wagg
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-11 00:00:00 +00:00
18
+ date: 2010-11-19 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: cucumber
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -33,21 +33,23 @@ dependencies:
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: cucumber
36
+ name: rspec
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- hash: 3
43
+ hash: 11
44
44
  segments:
45
+ - 2
46
+ - 1
45
47
  - 0
46
- version: "0"
48
+ version: 2.1.0
47
49
  type: :development
48
50
  version_requirements: *id002
49
51
  - !ruby/object:Gem::Dependency
50
- name: rack-test
52
+ name: bundler
51
53
  prerelease: false
52
54
  requirement: &id003 !ruby/object:Gem::Requirement
53
55
  none: false
@@ -61,7 +63,7 @@ dependencies:
61
63
  type: :development
62
64
  version_requirements: *id003
63
65
  - !ruby/object:Gem::Dependency
64
- name: sinatra
66
+ name: rack-test
65
67
  prerelease: false
66
68
  requirement: &id004 !ruby/object:Gem::Requirement
67
69
  none: false
@@ -75,47 +77,31 @@ dependencies:
75
77
  type: :development
76
78
  version_requirements: *id004
77
79
  - !ruby/object:Gem::Dependency
78
- name: rails
80
+ name: sinatra
79
81
  prerelease: false
80
82
  requirement: &id005 !ruby/object:Gem::Requirement
81
83
  none: false
82
84
  requirements:
83
85
  - - ">="
84
86
  - !ruby/object:Gem::Version
85
- hash: 7
87
+ hash: 3
86
88
  segments:
87
- - 3
88
- - 0
89
89
  - 0
90
- version: 3.0.0
90
+ version: "0"
91
91
  type: :development
92
92
  version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
94
- name: haml
95
- prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 45
102
- segments:
103
- - 3
104
- - 0
105
- - 21
106
- version: 3.0.21
107
- type: :runtime
108
- version_requirements: *id006
109
- description: Server side stylesheet combining for readonly hosting environments
110
- email: michael@guerillatactics.co.uk
93
+ description: |-
94
+ A rack middleware which does css and javascript combining
95
+ and minification for sites hosted in readonly filesystem environments
96
+ such as heroku.com
97
+ email:
98
+ - michael@guerillatactics.co.uk
111
99
  executables: []
112
100
 
113
101
  extensions: []
114
102
 
115
- extra_rdoc_files:
116
- - LICENSE
117
- - README.rdoc
118
- - TODO
103
+ extra_rdoc_files: []
104
+
119
105
  files:
120
106
  - .document
121
107
  - .gitignore
@@ -140,12 +126,8 @@ files:
140
126
  - features/fixtures/parent_with_child.js
141
127
  - features/fixtures/processed_sass_child.css
142
128
  - features/fixtures/processed_sass_which_uses_mixin.css
143
- - features/fixtures/sass_child.scss
144
- - features/fixtures/sass_mixins.scss
145
- - features/fixtures/sass_which_uses_mixin.scss
146
129
  - features/javascripts.feature
147
130
  - features/response_headers.feature
148
- - features/sass_integration.feature
149
131
  - features/step_definitions/stylo_steps.rb
150
132
  - features/stylesheets.feature
151
133
  - features/stylo_cannot_serve_asset.feature
@@ -158,30 +140,29 @@ files:
158
140
  - lib/stylo/pipeline_steps/caching.rb
159
141
  - lib/stylo/pipeline_steps/javascript.rb
160
142
  - lib/stylo/pipeline_steps/javascript_minifying.rb
161
- - lib/stylo/pipeline_steps/sass.rb
162
143
  - lib/stylo/pipeline_steps/stylesheet.rb
163
144
  - lib/stylo/processor.rb
164
145
  - lib/stylo/rack.rb
165
146
  - lib/stylo/railtie.rb
166
147
  - lib/stylo/response.rb
148
+ - lib/stylo/version.rb
167
149
  - spec/asset_loader_spec.rb
168
150
  - spec/combiner_spec.rb
169
151
  - spec/pipeline_steps/caching_spec.rb
170
152
  - spec/pipeline_steps/javascript_minifying_spec.rb
171
153
  - spec/pipeline_steps/javascript_spec.rb
172
- - spec/pipeline_steps/sass_spec.rb
173
154
  - spec/pipeline_steps/stylesheet_spec.rb
174
155
  - spec/rack_spec.rb
175
156
  - spec/spec_helper.rb
176
157
  - spec/stylo_spec_helpers.rb
177
158
  - stylo.gemspec
178
159
  has_rdoc: true
179
- homepage: http://github.com/mwagg/stylo
160
+ homepage: http://rubygems.org/gems/stylo
180
161
  licenses: []
181
162
 
182
163
  post_install_message:
183
- rdoc_options:
184
- - --charset=UTF-8
164
+ rdoc_options: []
165
+
185
166
  require_paths:
186
167
  - lib
187
168
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -204,18 +185,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
185
  version: "0"
205
186
  requirements: []
206
187
 
207
- rubyforge_project:
188
+ rubyforge_project: stylo
208
189
  rubygems_version: 1.3.7
209
190
  signing_key:
210
191
  specification_version: 3
211
- summary: Server side stylesheet combining for readonly hosting environments
192
+ summary: A javascript and css combining/minifying rack middleware
212
193
  test_files:
194
+ - features/fixtures.rb
195
+ - features/fixtures/child-min.js
196
+ - features/fixtures/child.css
197
+ - features/fixtures/child.js
198
+ - features/fixtures/grand_parent.css
199
+ - features/fixtures/grand_parent.js
200
+ - features/fixtures/grand_parent_with_parent_with_child.css
201
+ - features/fixtures/grand_parent_with_parent_with_child.js
202
+ - features/fixtures/nested_folder_grand_parent.css
203
+ - features/fixtures/nested_folder_grand_parent_with_parent_with_child.css
204
+ - features/fixtures/parent.css
205
+ - features/fixtures/parent.js
206
+ - features/fixtures/parent_with_child.css
207
+ - features/fixtures/parent_with_child.js
208
+ - features/fixtures/processed_sass_child.css
209
+ - features/fixtures/processed_sass_which_uses_mixin.css
210
+ - features/javascripts.feature
211
+ - features/response_headers.feature
212
+ - features/step_definitions/stylo_steps.rb
213
+ - features/stylesheets.feature
214
+ - features/stylo_cannot_serve_asset.feature
215
+ - features/support/env.rb
213
216
  - spec/asset_loader_spec.rb
214
217
  - spec/combiner_spec.rb
215
218
  - spec/pipeline_steps/caching_spec.rb
216
219
  - spec/pipeline_steps/javascript_minifying_spec.rb
217
220
  - spec/pipeline_steps/javascript_spec.rb
218
- - spec/pipeline_steps/sass_spec.rb
219
221
  - spec/pipeline_steps/stylesheet_spec.rb
220
222
  - spec/rack_spec.rb
221
223
  - spec/spec_helper.rb
@@ -1,4 +0,0 @@
1
- $black: #000000;
2
- #child {
3
- background: $black;
4
- }
@@ -1,3 +0,0 @@
1
- @mixin black-border {
2
- border: solid 1px #000000;
3
- }
@@ -1,6 +0,0 @@
1
- @import "sass_mixins.scss";
2
-
3
- #element {
4
- @include black-border;
5
- background: #FFFFFF;
6
- }
@@ -1,13 +0,0 @@
1
- Feature: Sass integration
2
-
3
- Scenario: Simple sass stylesheet serving
4
- Given "sass_child.scss" is located at "stylesheets" in the asset location
5
- When a request is made for "stylesheets/sass_child.css"
6
- Then the response body should look like "processed_sass_child.css"
7
-
8
- Scenario: Combined sass stylesheet serving
9
- Given "sass_mixins.scss" is located at "stylesheets" in the asset location
10
- And "sass_which_uses_mixin.scss" is located at "stylesheets" in the asset location
11
- When a request is made for "stylesheets/sass_which_uses_mixin.css"
12
- Then the response body should look like "processed_sass_which_uses_mixin.css"
13
-
@@ -1,18 +0,0 @@
1
- require 'sass'
2
-
3
- module Stylo
4
- module PipelineSteps
5
- class Sass
6
- def call(response)
7
- return if response.has_content? || response.extension != '.css'
8
- content = AssetLoader.load_content(response.path.gsub('.css', '.scss'))
9
- return if content.nil?
10
-
11
- combined_content = Combiner.new(REQUIRE_PATTERN).process(File.dirname(response.path), content)
12
- processed_content = ::Sass::Engine.new(combined_content, {:syntax => :scss}).render
13
-
14
- response.set_body(processed_content, :css)
15
- end
16
- end
17
- end
18
- end
@@ -1,95 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Stylo::PipelineSteps::Sass do
4
- let(:step) { Stylo::PipelineSteps::Sass.new }
5
-
6
- describe "when the response has not already been set" do
7
- describe "and the request is not for a stylesheet" do
8
- it "should not set the response" do
9
- response = Stylo::Response.new('javascripts/test.js')
10
- Stylo::AssetLoader.stub(:load_content).with(response.path).and_return('some-content')
11
-
12
- step.call(response)
13
-
14
- response.has_content?.should be_false
15
- end
16
- end
17
-
18
- describe "and the request is for a stylesheet" do
19
- let(:requested_path) { 'stylesheets/test.css' }
20
- let(:sass_path) { 'stylesheets/test.scss' }
21
- let(:response) { Stylo::Response.new(requested_path) }
22
- let(:base_path) { File.dirname(response.path) }
23
-
24
- it "should ask the asset loader to load the sass stylesheet content" do
25
- Stylo::AssetLoader.should_receive(:load_content).with(sass_path).and_return(nil)
26
-
27
- step.call(response)
28
- end
29
-
30
- describe "and the asset does not exist" do
31
- it "should not set the response" do
32
- Stylo::AssetLoader.stub(:load_content).and_return(nil)
33
-
34
- step.call(response)
35
-
36
- response.has_content?.should be_false
37
- end
38
- end
39
-
40
- describe "and the asset exists" do
41
- let(:stylesheet_content) { "html { color: $color; }" }
42
- let(:combined_stylesheet_content) { "html { color: $red; }" }
43
- let(:processed_content) { "html { color: red; }" }
44
- let(:sass_engine) { mock(:sass_engine) }
45
- let(:combiner) { mock(:combiner) }
46
-
47
- before(:each) do
48
- Stylo::AssetLoader.stub(:load_content).and_return(stylesheet_content)
49
- Stylo::Combiner.stub(:new).with(/@import "(.*)";/).and_return(combiner)
50
- combiner.stub(:process).with(base_path, stylesheet_content).and_return(combined_stylesheet_content)
51
- ::Sass::Engine.stub(:new).with(combined_stylesheet_content, {:syntax => :scss}).and_return(sass_engine)
52
- sass_engine.stub(:render).and_return(processed_content)
53
- end
54
-
55
- it "should tell the combiner to process the stylesheet content" do
56
- Stylo::Combiner.should_receive(:new).with(/@import "(.*)";/).and_return(combiner)
57
- combiner.should_receive(:process).with(base_path, stylesheet_content).and_return(combined_stylesheet_content)
58
-
59
- step.call(response)
60
- end
61
-
62
- it "should run the combined content through sass" do
63
- ::Sass::Engine.should_receive(:new).with(combined_stylesheet_content, {:syntax => :scss}).and_return(sass_engine)
64
- sass_engine.should_receive(:render).and_return(processed_content)
65
-
66
- step.call(response)
67
- end
68
-
69
- it "should set the body of the response to the combined stylesheet content" do
70
- step.call(response)
71
-
72
- response.body.should == processed_content
73
- end
74
-
75
- it "should set the content type to text/css" do
76
- step.call(response)
77
-
78
- response.headers['Content-Type'].should == 'text/css'
79
- end
80
- end
81
- end
82
- end
83
-
84
- describe "when the response has already been set" do
85
- it "should not alter the response" do
86
- response = Stylo::Response.new('stylesheets/test.css')
87
- response.set_body('some-content', :css)
88
-
89
- step.call(response)
90
-
91
- response.body.should == 'some-content'
92
- end
93
- end
94
-
95
- end