stasis 0.2.0.pre → 0.2.0

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.
data/bin/stasis CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../lib/stasis")
4
-
5
4
  gem "slop", "3.3.2"
6
5
  require 'slop'
7
6
 
@@ -9,10 +8,18 @@ slop = Slop.parse :help => true, :optional_arguments => true do
9
8
  on :d, :development, "Development mode", :as => Integer
10
9
  on :o, :only, "Only generate specific files (comma-separated)", :as => Array
11
10
  on :p, :public, "Public directory path"
11
+ on :m, :mime_types, "Additional Mime Types", :as => Array
12
12
  end
13
13
 
14
14
  exit if slop.help?
15
15
  options = slop.to_hash
16
+ options[:mime_types] = Hash[*options[:mime_types]]
17
+
18
+ # Autoload Gemfile if present in pwd
19
+ begin
20
+ require "bundler/setup"
21
+ Bundler.require
22
+ rescue; end
16
23
 
17
24
  if slop.development?
18
25
  require 'stasis/dev_mode'
@@ -61,6 +61,9 @@ class Stasis
61
61
  # `String` -- changes with each iteration of the main loop within `Stasis#render`.
62
62
  attr_accessor :path
63
63
 
64
+ # `String` -- changes with each iteration of the main loop within `Stasis#render`.
65
+ attr_accessor :dest
66
+
64
67
  # `Array` -- all paths in the project that Stasis will act upon.
65
68
  attr_accessor :paths
66
69
 
@@ -233,26 +236,26 @@ class Stasis
233
236
 
234
237
  # Add `destination` (as specified from `Stasis.new`) to front of relative
235
238
  # destination.
236
- dest = "#{destination}#{relative}"
239
+ @dest = "#{destination}#{relative}"
237
240
 
238
241
  # Cut off the extension if the extension is supported by [Tilt][ti].
239
- dest =
240
- if ext && File.extname(dest) == ".#{ext}"
241
- dest[0..-1*ext.length-2]
242
+ @dest =
243
+ if ext && File.extname(@dest) == ".#{ext}"
244
+ @dest[0..-1*ext.length-2]
242
245
  else
243
- dest
246
+ @dest
244
247
  end
245
248
 
246
249
  # Create the directories leading up to the destination.
247
250
  if render_options[:write] != false
248
- FileUtils.mkdir_p(File.dirname(dest))
251
+ FileUtils.mkdir_p(File.dirname(@dest))
249
252
  end
250
253
 
251
254
  # If markup was rendered...
252
255
  if @output
253
256
  # Write the rendered markup to the destination.
254
257
  if render_options[:write] != false
255
- File.open(dest, 'w') do |f|
258
+ File.open(@dest, 'w') do |f|
256
259
  f.write(@output)
257
260
  end
258
261
  end
@@ -264,10 +267,10 @@ class Stasis
264
267
  elsif File.exists?(@path)
265
268
  # Copy the file located at the path to the destination path.
266
269
  if render_options[:write] != false
267
- FileUtils.cp(@path, dest)
270
+ FileUtils.cp(@path, @dest)
268
271
  end
269
272
  end
270
-
273
+
271
274
  # Trigger all plugin `after_write` events. Only fires if view was created.
272
275
  trigger(:after_write)
273
276
  end
@@ -276,7 +279,7 @@ class Stasis
276
279
  trigger(:after_all)
277
280
 
278
281
  # Unset class-level instance variables.
279
- @action, @path, @output = nil, nil, nil
282
+ @action, @path, @dest, @output = nil, nil, nil, nil
280
283
 
281
284
  # Respond with collected render output if `collect` option given.
282
285
  collect if render_options[:collect]
@@ -42,8 +42,16 @@ class Stasis
42
42
 
43
43
  if @options[:development].is_a?(::Integer)
44
44
  mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
45
- mime_types.store 'js', 'application/javascript'
45
+
46
+ additional_mime_types = @options[:mime_types]
46
47
 
48
+ additional_mime_types.each do |extension, mimetype|
49
+ mime_types.store extension, mimetype
50
+ puts "add mime type #{mimetype} with extension .#{extension}"
51
+ end
52
+
53
+ mime_types.store 'js', 'application/javascript'
54
+
47
55
  server = WEBrick::HTTPServer.new(
48
56
  :AccessLog => [ nil, nil ],
49
57
  :DocumentRoot => @stasis.destination,
@@ -20,9 +20,10 @@ class Stasis
20
20
  callback = options[:callback]
21
21
  locals = options[:locals]
22
22
  path = options[:path]
23
+ ext = File.extname(path.to_s)[1..-1]
23
24
  scope = options[:scope]
24
25
  text = options[:text]
25
- template_options = options[:template]
26
+ template_options = Options.get_template_option(ext).merge( options[:template] || {} )
26
27
 
27
28
  if @stasis.controller
28
29
  path = @stasis.controller._resolve(path)
@@ -40,7 +41,7 @@ class Stasis
40
41
  end
41
42
 
42
43
  output =
43
- if Tilt.mappings.keys.include?(File.extname(path)[1..-1])
44
+ if Tilt.mappings.keys.include?(ext)
44
45
  scope = options[:scope] ||= @stasis.action
45
46
  tilt = Tilt.new(path, nil, template_options)
46
47
  if block_given?
@@ -0,0 +1,3 @@
1
+ @mixin template-options($val){
2
+ pass: $val
3
+ }
@@ -3,12 +3,18 @@
3
3
 
4
4
  require "#{File.dirname(__FILE__)}/plugin"
5
5
 
6
+ Stasis::Options.set_template_option 'scss', { :load_paths => ["#{File.dirname(__FILE__)}/../mixins"] }
7
+
6
8
  # Before
7
9
 
8
10
  before 'index.html.haml' do
9
11
  @before_index_literal = :root
10
12
  end
11
13
 
14
+ before 'template_options.html.haml' do
15
+ @css = render 'template_options.css.scss'
16
+ end
17
+
12
18
  before 'no_controller/index.html.haml' do
13
19
  @before_index_literal = :no_controller
14
20
  end
@@ -0,0 +1,4 @@
1
+ @import "template_options";
2
+ div {
3
+ @include template-options(true);
4
+ }
@@ -36,4 +36,12 @@ describe Stasis::Render do
36
36
  it "should render locals into subdirectory/render_locals.html" do
37
37
  $files['subdirectory/render_locals.html'].should =~ /true/
38
38
  end
39
+
40
+ it "should respect Stasis::Options.set_template_option settings in template_options.css" do
41
+ $files['template_options.css'].should =~ /pass: true/
42
+ end
43
+
44
+ it "should respect Stasis::Options.set_template_option settings in before blocks template_options.html" do
45
+ $files['template_options.css'].should =~ /pass: true/
46
+ end
39
47
  end
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "stasis"
9
- s.version = '0.2.0.pre'
9
+ s.version = '0.2.0'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
metadata CHANGED
@@ -1,184 +1,179 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: stasis
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Winton Welsh
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-01-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: albino
16
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
22
31
  type: :development
32
+ requirement: *id001
23
33
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
34
+ - !ruby/object:Gem::Dependency
31
35
  name: coffee-script
32
- requirement: !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
33
37
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
38
45
  type: :development
46
+ requirement: *id002
39
47
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
48
+ - !ruby/object:Gem::Dependency
47
49
  name: haml
48
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
49
51
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
54
59
  type: :development
60
+ requirement: *id003
55
61
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
62
+ - !ruby/object:Gem::Dependency
63
63
  name: nokogiri
64
- requirement: !ruby/object:Gem::Requirement
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
65
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
70
73
  type: :development
74
+ requirement: *id004
71
75
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
76
+ - !ruby/object:Gem::Dependency
79
77
  name: rake
80
- requirement: !ruby/object:Gem::Requirement
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
81
79
  none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
86
87
  type: :development
88
+ requirement: *id005
87
89
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
90
+ - !ruby/object:Gem::Dependency
95
91
  name: rocco
96
- requirement: !ruby/object:Gem::Requirement
92
+ version_requirements: &id006 !ruby/object:Gem::Requirement
97
93
  none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
102
101
  type: :development
102
+ requirement: *id006
103
103
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
104
+ - !ruby/object:Gem::Dependency
111
105
  name: rspec
112
- requirement: !ruby/object:Gem::Requirement
106
+ version_requirements: &id007 !ruby/object:Gem::Requirement
113
107
  none: false
114
- requirements:
108
+ requirements:
115
109
  - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '1.0'
110
+ - !ruby/object:Gem::Version
111
+ hash: 15
112
+ segments:
113
+ - 1
114
+ - 0
115
+ version: "1.0"
118
116
  type: :development
117
+ requirement: *id007
119
118
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: '1.0'
126
- - !ruby/object:Gem::Dependency
119
+ - !ruby/object:Gem::Dependency
127
120
  name: directory_watcher
128
- requirement: !ruby/object:Gem::Requirement
121
+ version_requirements: &id008 !ruby/object:Gem::Requirement
129
122
  none: false
130
- requirements:
131
- - - '='
132
- - !ruby/object:Gem::Version
123
+ requirements:
124
+ - - "="
125
+ - !ruby/object:Gem::Version
126
+ hash: 5
127
+ segments:
128
+ - 1
129
+ - 4
130
+ - 1
133
131
  version: 1.4.1
134
132
  type: :runtime
133
+ requirement: *id008
135
134
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - '='
140
- - !ruby/object:Gem::Version
141
- version: 1.4.1
142
- - !ruby/object:Gem::Dependency
135
+ - !ruby/object:Gem::Dependency
143
136
  name: slop
144
- requirement: !ruby/object:Gem::Requirement
137
+ version_requirements: &id009 !ruby/object:Gem::Requirement
145
138
  none: false
146
- requirements:
147
- - - '='
148
- - !ruby/object:Gem::Version
139
+ requirements:
140
+ - - "="
141
+ - !ruby/object:Gem::Version
142
+ hash: 15
143
+ segments:
144
+ - 3
145
+ - 3
146
+ - 2
149
147
  version: 3.3.2
150
148
  type: :runtime
149
+ requirement: *id009
151
150
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - '='
156
- - !ruby/object:Gem::Version
157
- version: 3.3.2
158
- - !ruby/object:Gem::Dependency
151
+ - !ruby/object:Gem::Dependency
159
152
  name: tilt
160
- requirement: !ruby/object:Gem::Requirement
153
+ version_requirements: &id010 !ruby/object:Gem::Requirement
161
154
  none: false
162
- requirements:
163
- - - '='
164
- - !ruby/object:Gem::Version
155
+ requirements:
156
+ - - "="
157
+ - !ruby/object:Gem::Version
158
+ hash: 29
159
+ segments:
160
+ - 1
161
+ - 3
162
+ - 3
165
163
  version: 1.3.3
166
164
  type: :runtime
165
+ requirement: *id010
167
166
  prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - '='
172
- - !ruby/object:Gem::Version
173
- version: 1.3.3
174
167
  description: Stasis is a dynamic framework for static sites.
175
- email:
168
+ email:
176
169
  - mail@wintoni.us
177
- executables:
170
+ executables:
178
171
  - stasis
179
172
  extensions: []
173
+
180
174
  extra_rdoc_files: []
181
- files:
175
+
176
+ files:
182
177
  - .gitignore
183
178
  - .travis.yml
184
179
  - Gemfile
@@ -209,6 +204,7 @@ files:
209
204
  - site/stasis.css.scss
210
205
  - site/stasis.js.coffee
211
206
  - site/stasis.png
207
+ - spec/fixtures/mixins/template_options.scss
212
208
  - spec/fixtures/project/.dotfile
213
209
  - spec/fixtures/project/_locals.html.haml
214
210
  - spec/fixtures/project/_partial.html.haml
@@ -244,6 +240,8 @@ files:
244
240
  - spec/fixtures/project/subdirectory/layout_controller.html.haml
245
241
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
246
242
  - spec/fixtures/project/subdirectory/render_locals.html.haml
243
+ - spec/fixtures/project/template_options.css.scss
244
+ - spec/fixtures/project/template_options.html.haml
247
245
  - spec/fixtures/project/time.html.haml
248
246
  - spec/spec_helper.rb
249
247
  - spec/stasis/plugins/before_spec.rb
@@ -256,32 +254,39 @@ files:
256
254
  - stasis.gemspec
257
255
  homepage: http://stasis.me
258
256
  licenses: []
257
+
259
258
  post_install_message:
260
259
  rdoc_options: []
261
- require_paths:
260
+
261
+ require_paths:
262
262
  - lib
263
- required_ruby_version: !ruby/object:Gem::Requirement
263
+ required_ruby_version: !ruby/object:Gem::Requirement
264
264
  none: false
265
- requirements:
266
- - - ! '>='
267
- - !ruby/object:Gem::Version
268
- version: '0'
269
- segments:
265
+ requirements:
266
+ - - ">="
267
+ - !ruby/object:Gem::Version
268
+ hash: 3
269
+ segments:
270
270
  - 0
271
- hash: -658786105732867218
272
- required_rubygems_version: !ruby/object:Gem::Requirement
271
+ version: "0"
272
+ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  none: false
274
- requirements:
275
- - - ! '>'
276
- - !ruby/object:Gem::Version
277
- version: 1.3.1
274
+ requirements:
275
+ - - ">="
276
+ - !ruby/object:Gem::Version
277
+ hash: 3
278
+ segments:
279
+ - 0
280
+ version: "0"
278
281
  requirements: []
282
+
279
283
  rubyforge_project:
280
284
  rubygems_version: 1.8.24
281
285
  signing_key:
282
286
  specification_version: 3
283
287
  summary: Static sites made powerful
284
- test_files:
288
+ test_files:
289
+ - spec/fixtures/mixins/template_options.scss
285
290
  - spec/fixtures/project/.dotfile
286
291
  - spec/fixtures/project/_locals.html.haml
287
292
  - spec/fixtures/project/_partial.html.haml
@@ -317,6 +322,8 @@ test_files:
317
322
  - spec/fixtures/project/subdirectory/layout_controller.html.haml
318
323
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
319
324
  - spec/fixtures/project/subdirectory/render_locals.html.haml
325
+ - spec/fixtures/project/template_options.css.scss
326
+ - spec/fixtures/project/template_options.html.haml
320
327
  - spec/fixtures/project/time.html.haml
321
328
  - spec/spec_helper.rb
322
329
  - spec/stasis/plugins/before_spec.rb