sinatra-support 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,8 +1,14 @@
1
+ v1.1.0 - May 27, 2011
2
+ ---------------------
3
+
4
+ ### Added:
5
+ * `Sinatra::CompassSupport` to add support for the Compass CSS framework
6
+
1
7
  v1.0.4 - May 15, 2011
2
8
  ---------------------
3
9
 
4
10
  ### Added:
5
- * Implement Sinatra::MultiRender
11
+ * Implement `Sinatra::MultiRender`
6
12
 
7
13
  v1.0.3 - Mar 30, 2011
8
14
  ---------------------
@@ -12,6 +12,7 @@ module Sinatra
12
12
  autoload :IfHelpers, File.expand_path('../support/ifhelpers', __FILE__)
13
13
  autoload :I18nSupport, File.expand_path('../support/i18nsupport', __FILE__)
14
14
  autoload :MultiRender, File.expand_path('../support/multirender', __FILE__)
15
+ autoload :CompassSupport, File.expand_path('../support/compasssupport', __FILE__)
15
16
 
16
17
  module Support
17
18
  end
@@ -0,0 +1,91 @@
1
+ # Adds Compass support.
2
+ #
3
+ # CompassSupport lets you use the Compass CSS framework in your application.
4
+ # More information about Compass can be found in http://compass-style.org.
5
+ #
6
+ # == Usage
7
+ #
8
+ # require 'sinatra/support/compasssupport'
9
+ #
10
+ # class Main
11
+ # register Sinatra::CompassSupport
12
+ # end
13
+ #
14
+ # After this, anytime a +sass+ or +scss+ is rendered, you may use Compass's
15
+ # extensions by simply importing them (eg, +@import 'compass/layout'+).
16
+ #
17
+ # == Example
18
+ #
19
+ # All you need to use is in the section above. Here's a slightly
20
+ # more-complicated example:
21
+ #
22
+ # class Main
23
+ # # This line below is optional (it defaults to `config/compass.config`;
24
+ # # in fact, it doesn't need to exist):
25
+ # set :compass_config_file, File.join(root, 'config/compass.conf')
26
+ #
27
+ # register Sinatra::CompassSupport
28
+ #
29
+ # get '/' do
30
+ # scss :mysheet
31
+ # end
32
+ # end
33
+ #
34
+ # And in +views/mysheet.scss+:
35
+ #
36
+ # @import 'compass/css3';
37
+ #
38
+ # Then copy +compass.config+ into +config/compass.conf+ from
39
+ # https://github.com/chriseppstein/compass-sinatra/blob/master/config/compass.config
40
+ #
41
+ # == Caveats
42
+ #
43
+ # If you are getting errors about Sass functions, you may need to upgrade your
44
+ # HAML and Sass gems.
45
+ #
46
+ # If your project uses Bundler, you will need to add Compass to your Gemfile.
47
+ #
48
+ # # Gemfile
49
+ # gem "compass", "~> 0.11.1"
50
+ #
51
+ # If you are getting errors about US-ASCII encoding, you may have to change
52
+ # your application's default external encoding to +utf-8+.
53
+ #
54
+ # Encoding.default_external = 'utf-8'
55
+ #
56
+ module Sinatra::CompassSupport
57
+ def self.registered(app)
58
+ require 'compass'
59
+
60
+ add_compass_engine_options app
61
+ set_default_compass_config app
62
+ load_compass_config app
63
+ end
64
+
65
+ private
66
+ def self.set_default_compass_config(app)
67
+ unless app.respond_to?(:compass_config_file)
68
+ app.set :compass_config_file, File.join(*[app.root, 'config', 'compass.config'].compact)
69
+ end
70
+ end
71
+
72
+ def self.load_compass_config(app)
73
+ file = app.compass_config_file
74
+
75
+ Compass.add_project_configuration(file) if File.exists?(file)
76
+ end
77
+
78
+ def self.add_compass_engine_options(app)
79
+ options = Compass.sass_engine_options
80
+
81
+ # Add the compass CSS folders to the path
82
+ [:scss, :sass].each do |type|
83
+ hash = app.respond_to?(type) ? app.send(type) : Hash.new
84
+ hash[:load_paths] ||= Array.new
85
+ hash[:load_paths] += options[:load_paths]
86
+
87
+ app.set type, hash
88
+ end
89
+ end
90
+ end
91
+
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Support
3
- VERSION = "1.0.4"
3
+ VERSION = "1.1.0"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ Encoding.default_external = 'utf-8'
4
+
5
+ class CompassAppTest < Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ class App < Sinatra::Base
9
+ set :scss, { :style => :compressed }
10
+ register Sinatra::CompassSupport
11
+ get('/style.css') { scss "@import 'compass/css3'; body { @include opacity(0.5); }" }
12
+ end
13
+
14
+ def app
15
+ App.new
16
+ end
17
+
18
+ test "boogie" do
19
+ get '/style.css'
20
+
21
+ control = "body{-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)\";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);opacity:0.5}\n"
22
+
23
+ assert_equal control, last_response.body
24
+ end
25
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sinatra-support
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.4
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cyril David
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-15 00:00:00 +08:00
14
+ date: 2011-05-27 00:00:00 +08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
 
104
104
  files:
105
+ - lib/sinatra/support/compasssupport.rb
105
106
  - lib/sinatra/support/compat-1.8.6.rb
106
107
  - lib/sinatra/support/country.rb
107
108
  - lib/sinatra/support/countryhelpers.rb
@@ -125,6 +126,7 @@ files:
125
126
  - test/fixtures/multirender/views_2/contact.haml
126
127
  - test/fixtures/multirender/views_2/home.haml
127
128
  - test/helper.rb
129
+ - test/test_compass_app.rb
128
130
  - test/test_country.rb
129
131
  - test/test_date.rb
130
132
  - test/test_date_app.rb