blossom 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/blossom.rb +68 -0
  2. metadata +132 -0
@@ -0,0 +1,68 @@
1
+ require "rubygems"
2
+
3
+ require "compass" # Load before sinatra.
4
+ require "sinatra/base"
5
+ require "haml" # Load after sinatra.
6
+ require "rack-strip-www"
7
+ require "hassle"
8
+
9
+ module Blossom ; end
10
+
11
+ def Blossom(root_file, index = :index)
12
+ Rack::Builder.app do
13
+ use RackStripWWW
14
+ use Hassle
15
+ run Blossom::Base(root_file, index)
16
+ end
17
+ end
18
+
19
+ def Blossom::Base(root_file, index = :index)
20
+ root = File.dirname(root_file)
21
+ Class.new(Sinatra::Base).tap do |app|
22
+ app.class_eval do
23
+ extend Blossom::Helpers
24
+
25
+ configure do
26
+ set :root, root
27
+ set :public, "#{root}/static"
28
+ set :views, root
29
+ set :index, index
30
+ set :haml, { :format => :html5, :attr_wrapper => '"' }
31
+
32
+ Compass.configuration.project_path = root
33
+ Compass.configuration.sass_dir = ""
34
+ Compass.configuration.images_dir = "static"
35
+ Compass.configuration.http_images_path = "/"
36
+
37
+ sass_options = Compass.sass_engine_options.merge \
38
+ :cache_location => "#{root}/tmp/sass-cache"
39
+
40
+ set :sass, sass_options
41
+ end
42
+
43
+ get "/" do
44
+ haml settings.index
45
+ end
46
+
47
+ get "/:name.css", :file_exists? => :sass do
48
+ content_type "text/css", :charset => "utf-8"
49
+ sass params[:name].to_sym
50
+ end
51
+
52
+ get "/:name", :file_exists? => :haml do
53
+ haml params[:name].to_sym
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ module Blossom::Helpers
60
+ def file_exists? suffix
61
+ condition do
62
+ basename = File.basename(request.path)
63
+ barename = basename.sub(/\.[^.]*$/, '')
64
+ name = "#{barename}.#{suffix}"
65
+ File.exist? File.join(settings.root, name)
66
+ end
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blossom
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Daniel Brockman
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-05 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: sinatra
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: haml
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 3
43
+ - 0
44
+ - 0
45
+ version: 3.0.0
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: compass
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 10
58
+ - 0
59
+ version: 0.10.0
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-strip-www
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ - 1
72
+ - 0
73
+ version: 0.1.0
74
+ type: :runtime
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: hassle
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ - 0
86
+ - 1
87
+ version: 0.0.1
88
+ type: :runtime
89
+ version_requirements: *id005
90
+ description:
91
+ email:
92
+ - daniel@brockman.se
93
+ executables: []
94
+
95
+ extensions: []
96
+
97
+ extra_rdoc_files: []
98
+
99
+ files:
100
+ - lib/blossom.rb
101
+ has_rdoc: true
102
+ homepage: http://github.com/dbrock/blossom
103
+ licenses: []
104
+
105
+ post_install_message:
106
+ rdoc_options: []
107
+
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project:
127
+ rubygems_version: 1.3.6
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Quick-start web development with Haml, Sass and Compass.
131
+ test_files: []
132
+