sinatra-compass 0.4.0.a

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.
Files changed (3) hide show
  1. data/README.md +44 -0
  2. data/lib/sinatra/compass.rb +64 -0
  3. metadata +112 -0
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ Sinatra::Compass
2
+ ================
3
+
4
+ Integrates the Compass stylesheet framework with [Sinatra](http://sinatrarb.com).
5
+
6
+ BigBand
7
+ -------
8
+
9
+ Sinatra::Compass is part of the [BigBand](http://github.com/rkh/big_band) stack.
10
+ Check it out if you are looking for other fancy Sinatra extensions.
11
+
12
+ Usage
13
+ -----
14
+
15
+ Usage without doing something:
16
+
17
+ require "sinatra"
18
+ require "sinatra/compass"
19
+
20
+ If you create a directory called views/stylesheets and place your
21
+ sass files in there, there you go. Just call stylesheet(name) form
22
+ your view to get the correct stylesheet tag. The URL for your
23
+ stylesheets will be /stylesheets/:name.css.
24
+
25
+ Of course you can use any other setup. Say, you want to store your
26
+ stylesheets in views/css and want the URL to be /css/:name.css:
27
+
28
+ get_compass("css")
29
+
30
+ But what about more complex setups?
31
+
32
+ require "sinatra/base"
33
+ require "sinatra/compass"
34
+
35
+ class Foo < Sinatra::Base
36
+ register Sinatra::Compass
37
+ set :compass, :sass_dir => "/foo/bar/blah"
38
+ get_compass("/foo/:name.css") do
39
+ compass :one_stylesheet
40
+ end
41
+ end
42
+
43
+ Note that already generated routes will be deactivated by calling
44
+ get_compass again.
@@ -0,0 +1,64 @@
1
+ require "sinatra/base"
2
+ require "sinatra/sugar"
3
+ require "sinatra/advanced_routes"
4
+
5
+ module Sinatra
6
+ module Compass
7
+
8
+ module ClassMethods
9
+ attr_reader :compass_route
10
+ def get_compass(path, &block)
11
+ block ||= Proc.new do |file|
12
+ content_type 'text/css', :charset => 'utf-8'
13
+ compass :"#{path}/#{params[:name]}"
14
+ end
15
+ set :compass, :sass_dir => views / path unless compass[:sass_dir] && compass[:sass_dir].directory?
16
+ @compass_route.deactivate if @compass_route
17
+ @compass_route = get("/#{path}" / ":name.css", &block)
18
+ end
19
+ end
20
+
21
+ module InstanceMethods
22
+ def compass(file, options = {})
23
+ options.merge! ::Compass.sass_engine_options
24
+ sass file, options
25
+ end
26
+ def stylesheet(*args)
27
+ raise NotImplementedError, "yet to be implemented"
28
+ end
29
+ end
30
+
31
+ def self.registered(klass)
32
+ klass.register Sugar
33
+ klass.register AdvancedRoutes
34
+ klass.extend ClassMethods
35
+ klass.send :include, InstanceMethods
36
+ klass.set :compass,
37
+ :project_path => klass.root_path, :output_style => (klass.development? ? :expanded : :compressed),
38
+ :sass_dir => klass.views / "stylesheets", :line_comments => klass.development?
39
+ set_app_file(klass) if klass.app_file?
40
+ end
41
+
42
+ def self.set_app_file(klass)
43
+ klass.set :compass, :root_path => klass.root_path
44
+ klass.get_compass("stylesheets") if (klass.views / "stylesheets").directory?
45
+ end
46
+
47
+ def self.set_compass(klass)
48
+ ::Compass.configuration do |config|
49
+ config.sass_options ||= {}
50
+ klass.compass.each do |option, value|
51
+ if config.respond_to? option
52
+ config.send "#{option}=", value
53
+ else
54
+ config.sass_options.merge! option.to_sym => value
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ register Compass
63
+
64
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-compass
3
+ version: &id001 !ruby/object:Gem::Version
4
+ version: 0.4.0.a
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Haase
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-15 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: monkey-lib
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - *id001
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: sinatra-sugar
26
+ type: :runtime
27
+ version_requirement:
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "="
31
+ - *id001
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: sinatra-test-helper
35
+ type: :development
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "="
40
+ - *id001
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: sinatra
44
+ type: :runtime
45
+ version_requirement:
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.9.4
51
+ version:
52
+ - !ruby/object:Gem::Dependency
53
+ name: compass
54
+ type: :runtime
55
+ version_requirement:
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.8.17
61
+ version:
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ type: :development
65
+ version_requirement:
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.0
71
+ version:
72
+ description: Better Compass integration for Sinatra (part of BigBand).
73
+ email: konstantin.mailinglists@googlemail.com
74
+ executables: []
75
+
76
+ extensions: []
77
+
78
+ extra_rdoc_files: []
79
+
80
+ files:
81
+ - lib/sinatra/compass.rb
82
+ - README.md
83
+ has_rdoc: yard
84
+ homepage: http://github.com/rkh/sinatra-compass
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">"
101
+ - !ruby/object:Gem::Version
102
+ version: 1.3.1
103
+ version:
104
+ requirements: []
105
+
106
+ rubyforge_project:
107
+ rubygems_version: 1.3.5
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: Better Compass integration for Sinatra (part of BigBand).
111
+ test_files: []
112
+