stasis 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,10 +1,12 @@
1
+ .bundle
1
2
  .DS_Store
2
3
  *.gem
3
- coverage
4
4
  docs
5
5
  dump.rdb
6
+ Gemfile.lock
6
7
  pkg
7
8
  site/.sass-cache
8
9
  site/public
10
+ spec/fixtures/project/.sass-cache
9
11
  spec/fixtures/project/public
10
12
  tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Rakefile CHANGED
@@ -1,94 +1,9 @@
1
- require File.dirname(__FILE__) + '/lib/stasis/gems'
1
+ require 'bundler'
2
+ require 'bundler/gem_tasks'
2
3
 
3
- Stasis::Gems.activate %w(rake rocco rspec)
4
+ Bundler.setup(:development)
4
5
 
5
- require 'rake'
6
6
  require 'rocco/tasks'
7
- require 'spec/rake/spectask'
8
-
9
- def gemspec
10
- @gemspec ||= begin
11
- file = File.expand_path('../stasis.gemspec', __FILE__)
12
- eval(File.read(file), binding, file)
13
- end
14
- end
15
-
16
- if defined?(Spec::Rake::SpecTask)
17
- desc "Run specs"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_files = FileList['spec/**/*_spec.rb']
20
- t.spec_opts = %w(-fs --color)
21
- t.warning = true
22
- end
23
- task :spec
24
- task :default => :spec
25
- end
26
-
27
- desc "Build gem(s)"
28
- task :gem do
29
- old_gemset = ENV['GEMSET']
30
- root = File.expand_path('../', __FILE__)
31
- pkg = "#{root}/pkg"
32
- system "rm -Rf #{pkg}"
33
- Stasis::Gems.gemset_names.each do |gemset|
34
- ENV['GEMSET'] = gemset.to_s
35
- system "cd #{root} && gem build stasis.gemspec"
36
- system "mkdir -p #{pkg} && mv *.gem pkg"
37
- end
38
- ENV['GEMSET'] = old_gemset
39
- end
40
-
41
- namespace :gem do
42
- desc "Install gem(s)"
43
- task :install do
44
- Rake::Task['gem'].invoke
45
- Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
46
- system "gem install #{pkg} --no-ri --no-rdoc"
47
- end
48
- end
49
-
50
- desc "Push gem(s)"
51
- task :push do
52
- Rake::Task['gem'].invoke
53
- Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
54
- system "gem push #{pkg}"
55
- end
56
- end
57
- end
58
-
59
- namespace :gems do
60
- desc "Install gem dependencies (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
61
- task :install do
62
- dev = ENV['DEV'] == '1'
63
- docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
64
- gemset = ENV['GEMSET']
65
- sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
66
-
67
- Stasis::Gems.gemset = gemset if gemset
68
-
69
- if dev
70
- gems = Stasis::Gems.gemspec.development_dependencies
71
- else
72
- gems = Stasis::Gems.gemspec.dependencies
73
- end
74
-
75
- gems.each do |name|
76
- name = name.to_s
77
- version = Stasis::Gems.versions[name]
78
- if Gem.source_index.find_name(name, version).empty?
79
- version = version ? "-v #{version}" : ''
80
- system "#{sudo} gem install #{name} #{version} #{docs}"
81
- else
82
- puts "already installed: #{name} #{version}"
83
- end
84
- end
85
- end
86
- end
87
-
88
- desc "Validate the gemspec"
89
- task :gemspec do
90
- gemspec.validate
91
- end
92
7
 
93
8
  desc "Build web site"
94
9
  task :site do
data/bin/stasis CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../lib/stasis")
4
4
 
5
- Stasis::Gems.activate %w(slop)
5
+ gem "slop", "~> 2.1.0"
6
6
  require 'slop'
7
7
 
8
8
  slop = Slop.parse :help => true do
data/lib/stasis.rb CHANGED
@@ -3,12 +3,7 @@
3
3
  ### Prerequisites
4
4
 
5
5
  require 'fileutils'
6
-
7
- # `Stasis::Gems` handles loading of rubygems and gems listed in [config/gemsets.yml][ge].
8
- #
9
- # [ge]: https://github.com/winton/stasis/blob/master/config/gemsets.yml
10
-
11
- require File.dirname(__FILE__) + '/stasis/gems'
6
+ require 'rubygems'
12
7
 
13
8
  # [Slim][sl] ships with its own [Tilt][ti] integration. If the user has [Slim][sl]
14
9
  # installed, require it, otherwise don't worry about it.
@@ -23,7 +18,7 @@ end
23
18
 
24
19
  # Activate the [Tilt][ti] gem.
25
20
 
26
- Stasis::Gems.activate %w(tilt)
21
+ gem "tilt", "~> 1.3"
27
22
 
28
23
  # Add the project directory to the load paths.
29
24
 
@@ -147,15 +142,15 @@ class Stasis
147
142
  # If `only` parameters given...
148
143
  unless only.empty?
149
144
  # Skip iteration unless there is a match.
150
- next unless only.any? do |only|
145
+ next unless only.any? do |o|
151
146
  # Regular expression match.
152
- (only.is_a?(::Regexp) && @path =~ only) ||
147
+ (o.is_a?(::Regexp) && @path =~ o) ||
153
148
  (
154
- only.is_a?(::String) && (
149
+ o.is_a?(::String) && (
155
150
  # File match.
156
- @path == only ||
151
+ @path == o ||
157
152
  # Directory match.
158
- @path[0..only.length-1] == only
153
+ @path[0..o.length-1] == o
159
154
  )
160
155
  )
161
156
  end
@@ -223,7 +218,9 @@ class Stasis
223
218
  end
224
219
 
225
220
  # Create the directories leading up to the destination.
226
- FileUtils.mkdir_p(File.dirname(dest))
221
+ if render_options[:write] != false
222
+ FileUtils.mkdir_p(File.dirname(dest))
223
+ end
227
224
 
228
225
  # If markup was rendered...
229
226
  if view
@@ -1,4 +1,4 @@
1
- Stasis::Gems.activate %w(directory_watcher)
1
+ gem "directory_watcher", "~> 1.4.0"
2
2
  require 'directory_watcher'
3
3
 
4
4
  class Stasis
@@ -43,7 +43,7 @@ class Stasis
43
43
  puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Regenerating #{@options[:only] ? @options[:only].join(', ') : 'project'}..."
44
44
  begin
45
45
  @stasis = Stasis.new(*[ @dir, @options[:public], @options ].compact)
46
- @stasis.render(*@options[:only])
46
+ @stasis.render(*[ @options[:only] ].flatten.compact)
47
47
  rescue Exception => e
48
48
  puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Error: #{e.message}`"
49
49
  puts "\t#{e.backtrace.join("\n\t")}"
@@ -15,8 +15,20 @@ class Stasis
15
15
  def before_render
16
16
  @stasis.action._layout = nil
17
17
  matches = _match_key?(@layouts, @stasis.path)
18
- matches.each do |(within, layout)|
19
- @stasis.action._layout = layout if _within?(within)
18
+ # Find matching layout with same extension.
19
+ matches.each do |(within, layout, non_specific)|
20
+ if _within?(within) && File.extname(layout) == File.extname(@stasis.path)
21
+ @stasis.action._layout = layout
22
+ end
23
+ end
24
+ # If layout not found, try again without extension requirement for specific layout
25
+ # definitions only.
26
+ unless @stasis.action._layout
27
+ matches.each do |(within, layout, non_specific)|
28
+ if _within?(within) && !non_specific
29
+ @stasis.action._layout = layout
30
+ end
31
+ end
20
32
  end
21
33
  end
22
34
 
@@ -41,7 +53,7 @@ class Stasis
41
53
  path = @stasis.controller._resolve(path)
42
54
  layout = @stasis.controller._resolve(layout)
43
55
  if layout
44
- hash[path] = [ @stasis.path, layout ]
56
+ hash[path] = [ @stasis.path, layout, path == /.*/ ]
45
57
  @stasis.controller.ignore(layout)
46
58
  end
47
59
  hash
data/lib/stasis/server.rb CHANGED
@@ -1,4 +1,5 @@
1
- Stasis::Gems.activate %w(redis yajl-ruby)
1
+ gem "redis", "~> 2.2.1"
2
+ gem "yajl-ruby", "~> 0.8.2"
2
3
 
3
4
  require 'digest/sha1'
4
5
  require 'redis'
@@ -12,6 +13,7 @@ class Stasis
12
13
 
13
14
  redis = Redis.connect(:url => "redis://#{options[:server]}")
14
15
  stasis = Stasis.new(*[ root, options[:public], options ].compact)
16
+ retries = 0
15
17
 
16
18
  begin
17
19
  while true
@@ -65,6 +67,8 @@ class Stasis
65
67
  rescue Exception => e
66
68
  puts "\nError: #{e.message}"
67
69
  puts "\t#{e.backtrace.join("\n\t")}"
70
+ retries += 1
71
+ shut_down if retries >= 10
68
72
  retry
69
73
  end
70
74
  end
@@ -69,6 +69,8 @@ end
69
69
  layout 'does_not_exist.html.haml'
70
70
  layout 'index.html.haml' => 'does_not_exist.html.haml'
71
71
 
72
+ layout 'layout.html.erb'
73
+
72
74
  # Priority
73
75
 
74
76
  priority 'subdirectory/before_render_partial.html.haml' => 1
@@ -0,0 +1 @@
1
+ body { background: red }
@@ -0,0 +1 @@
1
+ erb template
@@ -0,0 +1,2 @@
1
+ erb layout
2
+ <%= yield %>
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'pp'
1
+ require "pp"
2
+ require "bundler"
2
3
 
3
- $root = File.expand_path('../../', __FILE__)
4
- require "#{$root}/lib/stasis/gems"
5
-
6
- Stasis::Gems.activate :rspec
4
+ Bundler.setup(:default)
5
+ Bundler.require(:development)
7
6
 
7
+ $root = File.expand_path('../../', __FILE__)
8
8
  require "#{$root}/lib/stasis"
9
9
 
10
10
  def generate(options={})
@@ -12,7 +12,7 @@ def generate(options={})
12
12
  $fixture = "#{$root}/spec/fixtures/project"
13
13
  unless $files
14
14
  $stasis ||= Stasis.new($fixture)
15
- $stasis.render(*options[:only])
15
+ $stasis.render(*[ options[:only] ].flatten.compact)
16
16
  generate_files
17
17
  end
18
18
  end
@@ -19,4 +19,10 @@ describe Stasis::Layout do
19
19
  $files['subdirectory/layout_controller.html'].should =~ /layout\nsubdirectory\npass/
20
20
  $files['subdirectory/layout_controller_from_root.html'].should =~ /layout\nroot\npass/
21
21
  end
22
+
23
+ it "should use layouts on matching extensions" do
24
+ $files['erb.html'].should =~ /erb layout/
25
+ $files['erb.html'].should =~ /erb template/
26
+ $files['css.css'].should_not =~ /erb layout/
27
+ end
22
28
  end
data/stasis.gemspec CHANGED
@@ -1,32 +1,31 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  root = File.expand_path('../', __FILE__)
3
3
  lib = "#{root}/lib"
4
+
4
5
  $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'stasis/gems'
7
- Stasis::Gems.gemset ||= ENV['GEMSET'] || :default
8
6
 
9
7
  Gem::Specification.new do |s|
10
- Stasis::Gems.gemspec.hash.each do |key, value|
11
- if key == 'name' && Stasis::Gems.gemset != :default
12
- s.name = "#{value}-#{Stasis::Gems.gemset}"
13
- elsif key == 'summary' && Stasis::Gems.gemset == :solo
14
- s.summary = value + " (no dependencies)"
15
- elsif !%w(dependencies development_dependencies).include?(key)
16
- s.send "#{key}=", value
17
- end
18
- end
19
-
20
- Stasis::Gems.dependencies.each do |g|
21
- s.add_dependency g.to_s, Stasis::Gems.versions[g]
22
- end
23
-
24
- Stasis::Gems.development_dependencies.each do |g|
25
- s.add_development_dependency g.to_s, Stasis::Gems.versions[g]
26
- end
8
+ s.name = "stasis"
9
+ s.version = '0.1.11'
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = [ 'Winton Welsh' ]
12
+ s.email = [ 'mail@wintoni.us' ]
13
+ s.homepage = "http://stasis.me"
14
+ s.summary = %q{Static sites made powerful}
15
+ s.description = %q{Stasis is a dynamic framework for static sites.}
27
16
 
28
17
  s.executables = `cd #{root} && git ls-files bin/*`.split("\n").collect { |f| File.basename(f) }
29
18
  s.files = `cd #{root} && git ls-files`.split("\n")
30
19
  s.require_paths = %w(lib)
31
20
  s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
21
+
22
+ s.add_development_dependency "haml"
23
+ s.add_development_dependency "rocco"
24
+ s.add_development_dependency "rspec", "~> 1.0"
25
+
26
+ s.add_dependency "directory_watcher", "~> 1.4.0"
27
+ s.add_dependency "redis", "~> 2.2.1"
28
+ s.add_dependency "slop", "~> 2.1.0"
29
+ s.add_dependency "tilt", "~> 1.3"
30
+ s.add_dependency "yajl-ruby", "~> 0.8.2"
32
31
  end
metadata CHANGED
@@ -1,110 +1,162 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: stasis
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 11
10
+ version: 0.1.11
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: 2011-09-22 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: directory_watcher
16
- requirement: &70220140230080 !ruby/object:Gem::Requirement
17
+
18
+ date: 2011-10-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
22
  none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 1.4.0
22
- type: :runtime
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ requirement: *id001
23
31
  prerelease: false
24
- version_requirements: *70220140230080
25
- - !ruby/object:Gem::Dependency
26
- name: redis
27
- requirement: &70220140229620 !ruby/object:Gem::Requirement
32
+ name: haml
33
+ type: :development
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
28
36
  none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 2.2.1
33
- type: :runtime
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ requirement: *id002
34
45
  prerelease: false
35
- version_requirements: *70220140229620
36
- - !ruby/object:Gem::Dependency
37
- name: slop
38
- requirement: &70220140229180 !ruby/object:Gem::Requirement
46
+ name: rocco
47
+ type: :development
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
50
  none: false
40
- requirements:
51
+ requirements:
41
52
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 2.1.0
44
- type: :runtime
53
+ - !ruby/object:Gem::Version
54
+ hash: 15
55
+ segments:
56
+ - 1
57
+ - 0
58
+ version: "1.0"
59
+ requirement: *id003
45
60
  prerelease: false
46
- version_requirements: *70220140229180
47
- - !ruby/object:Gem::Dependency
48
- name: tilt
49
- requirement: &70220140228740 !ruby/object:Gem::Requirement
61
+ name: rspec
62
+ type: :development
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
50
65
  none: false
51
- requirements:
66
+ requirements:
52
67
  - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '1.3'
55
- type: :runtime
68
+ - !ruby/object:Gem::Version
69
+ hash: 7
70
+ segments:
71
+ - 1
72
+ - 4
73
+ - 0
74
+ version: 1.4.0
75
+ requirement: *id004
56
76
  prerelease: false
57
- version_requirements: *70220140228740
58
- - !ruby/object:Gem::Dependency
59
- name: yajl-ruby
60
- requirement: &70220140228300 !ruby/object:Gem::Requirement
77
+ name: directory_watcher
78
+ type: :runtime
79
+ - !ruby/object:Gem::Dependency
80
+ version_requirements: &id005 !ruby/object:Gem::Requirement
61
81
  none: false
62
- requirements:
82
+ requirements:
63
83
  - - ~>
64
- - !ruby/object:Gem::Version
65
- version: 0.8.2
84
+ - !ruby/object:Gem::Version
85
+ hash: 5
86
+ segments:
87
+ - 2
88
+ - 2
89
+ - 1
90
+ version: 2.2.1
91
+ requirement: *id005
92
+ prerelease: false
93
+ name: redis
66
94
  type: :runtime
95
+ - !ruby/object:Gem::Dependency
96
+ version_requirements: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ hash: 11
102
+ segments:
103
+ - 2
104
+ - 1
105
+ - 0
106
+ version: 2.1.0
107
+ requirement: *id006
67
108
  prerelease: false
68
- version_requirements: *70220140228300
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: &70220140227720 !ruby/object:Gem::Requirement
109
+ name: slop
110
+ type: :runtime
111
+ - !ruby/object:Gem::Dependency
112
+ version_requirements: &id007 !ruby/object:Gem::Requirement
72
113
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: 0.8.7
77
- type: :development
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ hash: 9
118
+ segments:
119
+ - 1
120
+ - 3
121
+ version: "1.3"
122
+ requirement: *id007
78
123
  prerelease: false
79
- version_requirements: *70220140227720
80
- - !ruby/object:Gem::Dependency
81
- name: rspec
82
- requirement: &70220140227280 !ruby/object:Gem::Requirement
124
+ name: tilt
125
+ type: :runtime
126
+ - !ruby/object:Gem::Dependency
127
+ version_requirements: &id008 !ruby/object:Gem::Requirement
83
128
  none: false
84
- requirements:
129
+ requirements:
85
130
  - - ~>
86
- - !ruby/object:Gem::Version
87
- version: '1.0'
88
- type: :development
131
+ - !ruby/object:Gem::Version
132
+ hash: 59
133
+ segments:
134
+ - 0
135
+ - 8
136
+ - 2
137
+ version: 0.8.2
138
+ requirement: *id008
89
139
  prerelease: false
90
- version_requirements: *70220140227280
140
+ name: yajl-ruby
141
+ type: :runtime
91
142
  description: Stasis is a dynamic framework for static sites.
92
- email: mail@wintoni.us
93
- executables:
143
+ email:
144
+ - mail@wintoni.us
145
+ executables:
94
146
  - stasis
95
147
  extensions: []
148
+
96
149
  extra_rdoc_files: []
97
- files:
150
+
151
+ files:
98
152
  - .gitignore
153
+ - Gemfile
99
154
  - LICENSE
100
155
  - README.md
101
156
  - Rakefile
102
157
  - bin/stasis
103
- - config/gemsets.yml
104
- - config/gemspec.yml
105
158
  - lib/stasis.rb
106
159
  - lib/stasis/dev_mode.rb
107
- - lib/stasis/gems.rb
108
160
  - lib/stasis/options.rb
109
161
  - lib/stasis/plugin.rb
110
162
  - lib/stasis/plugins/before.rb
@@ -126,13 +178,14 @@ files:
126
178
  - site/stasis.css.scss
127
179
  - site/stasis.js.coffee
128
180
  - site/stasis.png
129
- - spec/fixtures/gemsets.yml
130
- - spec/fixtures/gemspec.yml
131
181
  - spec/fixtures/project/_partial.html.haml
132
182
  - spec/fixtures/project/before_render_partial.html.haml
133
183
  - spec/fixtures/project/before_render_text.html.haml
134
184
  - spec/fixtures/project/controller.rb
185
+ - spec/fixtures/project/css.css.scss
186
+ - spec/fixtures/project/erb.html.erb
135
187
  - spec/fixtures/project/index.html.haml
188
+ - spec/fixtures/project/layout.html.erb
136
189
  - spec/fixtures/project/layout.html.haml
137
190
  - spec/fixtures/project/layout_action.html.haml
138
191
  - spec/fixtures/project/layout_action_from_subdirectory.html.haml
@@ -155,7 +208,6 @@ files:
155
208
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
156
209
  - spec/fixtures/project/time.html.haml
157
210
  - spec/spec_helper.rb
158
- - spec/stasis/gems_spec.rb
159
211
  - spec/stasis/plugins/before_spec.rb
160
212
  - spec/stasis/plugins/helpers_spec.rb
161
213
  - spec/stasis/plugins/ignore_spec.rb
@@ -167,36 +219,46 @@ files:
167
219
  - stasis.gemspec
168
220
  homepage: http://stasis.me
169
221
  licenses: []
222
+
170
223
  post_install_message:
171
224
  rdoc_options: []
172
- require_paths:
225
+
226
+ require_paths:
173
227
  - lib
174
- required_ruby_version: !ruby/object:Gem::Requirement
228
+ required_ruby_version: !ruby/object:Gem::Requirement
175
229
  none: false
176
- requirements:
177
- - - ! '>='
178
- - !ruby/object:Gem::Version
179
- version: '0'
180
- required_rubygems_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ hash: 3
234
+ segments:
235
+ - 0
236
+ version: "0"
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
238
  none: false
182
- requirements:
183
- - - ! '>='
184
- - !ruby/object:Gem::Version
185
- version: '0'
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ hash: 3
243
+ segments:
244
+ - 0
245
+ version: "0"
186
246
  requirements: []
247
+
187
248
  rubyforge_project:
188
- rubygems_version: 1.8.6
249
+ rubygems_version: 1.8.10
189
250
  signing_key:
190
251
  specification_version: 3
191
252
  summary: Static sites made powerful
192
- test_files:
193
- - spec/fixtures/gemsets.yml
194
- - spec/fixtures/gemspec.yml
253
+ test_files:
195
254
  - spec/fixtures/project/_partial.html.haml
196
255
  - spec/fixtures/project/before_render_partial.html.haml
197
256
  - spec/fixtures/project/before_render_text.html.haml
198
257
  - spec/fixtures/project/controller.rb
258
+ - spec/fixtures/project/css.css.scss
259
+ - spec/fixtures/project/erb.html.erb
199
260
  - spec/fixtures/project/index.html.haml
261
+ - spec/fixtures/project/layout.html.erb
200
262
  - spec/fixtures/project/layout.html.haml
201
263
  - spec/fixtures/project/layout_action.html.haml
202
264
  - spec/fixtures/project/layout_action_from_subdirectory.html.haml
@@ -219,7 +281,6 @@ test_files:
219
281
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
220
282
  - spec/fixtures/project/time.html.haml
221
283
  - spec/spec_helper.rb
222
- - spec/stasis/gems_spec.rb
223
284
  - spec/stasis/plugins/before_spec.rb
224
285
  - spec/stasis/plugins/helpers_spec.rb
225
286
  - spec/stasis/plugins/ignore_spec.rb
data/config/gemsets.yml DELETED
@@ -1,9 +0,0 @@
1
- stasis:
2
- directory_watcher: '~>1.4.0'
3
- rake: '>=0.8.7'
4
- redis: '~>2.2.1'
5
- rocco: '~>0.8'
6
- rspec: '~>1.0'
7
- slop: '~>2.1.0'
8
- tilt: '~>1.3'
9
- yajl-ruby: '~>0.8.2'
data/config/gemspec.yml DELETED
@@ -1,17 +0,0 @@
1
- name: stasis
2
- version: 0.1.10
3
- authors:
4
- - Winton Welsh
5
- email: mail@wintoni.us
6
- homepage: http://stasis.me
7
- summary: Static sites made powerful
8
- description: Stasis is a dynamic framework for static sites.
9
- dependencies:
10
- - directory_watcher
11
- - redis
12
- - slop
13
- - tilt
14
- - yajl-ruby
15
- development_dependencies:
16
- - rake
17
- - rspec
data/lib/stasis/gems.rb DELETED
@@ -1,154 +0,0 @@
1
- unless defined?(Stasis::Gems)
2
-
3
- require 'yaml'
4
-
5
- class Stasis
6
- module Gems
7
- class <<self
8
-
9
- attr_accessor :config
10
- attr_reader :gemset, :gemsets, :versions
11
-
12
- class SimpleStruct
13
- attr_reader :hash
14
-
15
- def initialize(hash)
16
- @hash = hash
17
- @hash.each do |key, value|
18
- self.class.send(:define_method, key) { @hash[key] }
19
- self.class.send(:define_method, "#{key}=") { |v| @hash[key] = v }
20
- end
21
- end
22
- end
23
-
24
- Gems.config = SimpleStruct.new(
25
- :gemsets => [ "#{File.expand_path('../../../', __FILE__)}/config/gemsets.yml" ],
26
- :gemspec => "#{File.expand_path('../../../', __FILE__)}/config/gemspec.yml",
27
- :warn => true
28
- )
29
-
30
- def activate(*gems)
31
- begin
32
- require 'rubygems' unless defined?(::Gem)
33
- rescue LoadError
34
- puts "rubygems library could not be required" if @config.warn
35
- end
36
-
37
- self.gemset ||= gemset_from_loaded_specs
38
-
39
- gems.flatten.collect { |g| g.to_sym }.each do |name|
40
- version = @versions[name]
41
- vendor = File.expand_path("../../../vendor/#{name}/lib", __FILE__)
42
- if File.exists?(vendor)
43
- $:.unshift vendor
44
- elsif defined?(gem)
45
- gem name.to_s, version
46
- else
47
- puts "#{name} #{"(#{version})" if version} failed to activate" if @config.warn
48
- end
49
- end
50
- end
51
-
52
- def dependencies
53
- dependency_filter(@gemspec.dependencies, @gemset)
54
- end
55
-
56
- def development_dependencies
57
- dependency_filter(@gemspec.development_dependencies, @gemset)
58
- end
59
-
60
- def gemset=(gemset)
61
- if gemset
62
- @gemset = gemset.to_sym
63
-
64
- @gemsets = @config.gemsets.reverse.collect { |config|
65
- if config.is_a?(::String)
66
- YAML::load(File.read(config)) rescue {}
67
- elsif config.is_a?(::Hash)
68
- config
69
- end
70
- }.inject({}) do |hash, config|
71
- deep_merge(hash, symbolize_keys(config))
72
- end
73
-
74
- @versions = (@gemsets[gemspec.name.to_sym] || {}).inject({}) do |hash, (key, value)|
75
- if !value.is_a?(::Hash) && value
76
- hash[key] = value
77
- elsif key == @gemset
78
- (value || {}).each { |k, v| hash[k] = v }
79
- end
80
- hash
81
- end
82
- else
83
- @gemset = nil
84
- @gemsets = nil
85
- @versions = nil
86
- end
87
- end
88
-
89
- def gemset_names
90
- (
91
- [ :default ] +
92
- @gemsets[gemspec.name.to_sym].inject([]) { |array, (key, value)|
93
- array.push(key) if value.is_a?(::Hash) || value.nil?
94
- array
95
- }
96
- ).uniq
97
- end
98
-
99
- def gemspec(reload=false)
100
- if @gemspec && !reload
101
- @gemspec
102
- else
103
- data = YAML::load(File.read(@config.gemspec)) rescue {}
104
- @gemspec = SimpleStruct.new(data)
105
- end
106
- end
107
-
108
- private
109
-
110
- def deep_merge(first, second)
111
- merger = lambda do |key, v1, v2|
112
- Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
113
- end
114
- first.merge(second, &merger)
115
- end
116
-
117
- def dependency_filter(dependencies, match)
118
- (dependencies || []).inject([]) { |array, value|
119
- if value.is_a?(::Hash)
120
- array += value[match.to_s] if value[match.to_s]
121
- else
122
- array << value
123
- end
124
- array
125
- }.uniq.collect(&:to_sym)
126
- end
127
-
128
- def gemset_from_loaded_specs
129
- if defined?(Gem)
130
- Gem.loaded_specs.each do |name, spec|
131
- if name == gemspec.name
132
- return :default
133
- elsif name[0..gemspec.name.length] == "#{gemspec.name}-"
134
- return name[gemspec.name.length+1..-1].to_sym
135
- end
136
- end
137
- :default
138
- else
139
- :none
140
- end
141
- end
142
-
143
- def symbolize_keys(hash)
144
- return {} unless hash.is_a?(::Hash)
145
- hash.inject({}) do |options, (key, value)|
146
- value = symbolize_keys(value) if value.is_a?(::Hash)
147
- options[(key.to_sym rescue key) || key] = value
148
- options
149
- end
150
- end
151
- end
152
- end
153
- end
154
- end
@@ -1,9 +0,0 @@
1
- name:
2
- rake: =0.8.7
3
- default:
4
- mysql: =2.8.1
5
- rspec: =1.3.1
6
- rspec2:
7
- mysql2: =0.2.6
8
- rspec: =2.3.0
9
- solo: null
@@ -1,15 +0,0 @@
1
- name: name
2
- version: 0.1.0
3
- authors:
4
- - Author
5
- email: email@email.com
6
- homepage: http://github.com/author/name
7
- summary: Summary
8
- description: Description
9
- dependencies:
10
- - rake
11
- - default:
12
- - mysql
13
- - rspec2:
14
- - mysql2
15
- development_dependencies: null
@@ -1,249 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Stasis::Gems do
4
-
5
- before(:each) do
6
- @old_config = Stasis::Gems.config
7
-
8
- Stasis::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
9
- Stasis::Gems.config.gemsets = [
10
- "#{$root}/spec/fixtures/gemsets.yml"
11
- ]
12
- Stasis::Gems.config.warn = true
13
-
14
- Stasis::Gems.gemspec true
15
- Stasis::Gems.gemset = nil
16
- end
17
-
18
- after(:each) do
19
- Stasis::Gems.config = @old_config
20
- end
21
-
22
- describe :activate do
23
- it "should activate gems" do
24
- Stasis::Gems.stub!(:gem)
25
- Stasis::Gems.should_receive(:gem).with('rspec', '=1.3.1')
26
- Stasis::Gems.should_receive(:gem).with('rake', '=0.8.7')
27
- Stasis::Gems.activate :rspec, 'rake'
28
- end
29
- end
30
-
31
- describe :gemset= do
32
- before(:each) do
33
- Stasis::Gems.config.gemsets = [
34
- {
35
- :name => {
36
- :rake => '>0.8.6',
37
- :default => {
38
- :externals => '=1.0.2'
39
- }
40
- }
41
- },
42
- "#{$root}/spec/fixtures/gemsets.yml"
43
- ]
44
- end
45
-
46
- describe :default do
47
- before(:each) do
48
- Stasis::Gems.gemset = :default
49
- end
50
-
51
- it "should set @gemset" do
52
- Stasis::Gems.gemset.should == :default
53
- end
54
-
55
- it "should set @gemsets" do
56
- Stasis::Gems.gemsets.should == {
57
- :name => {
58
- :rake => ">0.8.6",
59
- :default => {
60
- :externals => '=1.0.2',
61
- :mysql => "=2.8.1",
62
- :rspec => "=1.3.1"
63
- },
64
- :rspec2 => {
65
- :mysql2 => "=0.2.6",
66
- :rspec => "=2.3.0"
67
- },
68
- :solo => nil
69
- }
70
- }
71
- end
72
-
73
- it "should set Gems.versions" do
74
- Stasis::Gems.versions.should == {
75
- :externals => "=1.0.2",
76
- :mysql => "=2.8.1",
77
- :rake => ">0.8.6",
78
- :rspec => "=1.3.1"
79
- }
80
- end
81
-
82
- it "should return proper values for Gems.dependencies" do
83
- Stasis::Gems.dependencies.should == [ :rake, :mysql ]
84
- Stasis::Gems.development_dependencies.should == []
85
- end
86
-
87
- it "should return proper values for Gems.gemset_names" do
88
- Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
89
- end
90
- end
91
-
92
- describe :rspec2 do
93
- before(:each) do
94
- Stasis::Gems.gemset = "rspec2"
95
- end
96
-
97
- it "should set @gemset" do
98
- Stasis::Gems.gemset.should == :rspec2
99
- end
100
-
101
- it "should set @gemsets" do
102
- Stasis::Gems.gemsets.should == {
103
- :name => {
104
- :rake => ">0.8.6",
105
- :default => {
106
- :externals => '=1.0.2',
107
- :mysql => "=2.8.1",
108
- :rspec => "=1.3.1"
109
- },
110
- :rspec2 => {
111
- :mysql2=>"=0.2.6",
112
- :rspec => "=2.3.0"
113
- },
114
- :solo => nil
115
- }
116
- }
117
- end
118
-
119
- it "should set Gems.versions" do
120
- Stasis::Gems.versions.should == {
121
- :mysql2 => "=0.2.6",
122
- :rake => ">0.8.6",
123
- :rspec => "=2.3.0"
124
- }
125
- end
126
-
127
- it "should return proper values for Gems.dependencies" do
128
- Stasis::Gems.dependencies.should == [ :rake, :mysql2 ]
129
- Stasis::Gems.development_dependencies.should == []
130
- end
131
-
132
- it "should return proper values for Gems.gemset_names" do
133
- Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
134
- end
135
- end
136
-
137
- describe :solo do
138
- before(:each) do
139
- Stasis::Gems.gemset = :solo
140
- end
141
-
142
- it "should set @gemset" do
143
- Stasis::Gems.gemset.should == :solo
144
- end
145
-
146
- it "should set @gemsets" do
147
- Stasis::Gems.gemsets.should == {
148
- :name => {
149
- :rake => ">0.8.6",
150
- :default => {
151
- :externals => '=1.0.2',
152
- :mysql => "=2.8.1",
153
- :rspec => "=1.3.1"
154
- },
155
- :rspec2 => {
156
- :mysql2=>"=0.2.6",
157
- :rspec => "=2.3.0"
158
- },
159
- :solo => nil
160
- }
161
- }
162
- end
163
-
164
- it "should set Gems.versions" do
165
- Stasis::Gems.versions.should == {:rake=>">0.8.6"}
166
- end
167
-
168
- it "should return proper values for Gems.dependencies" do
169
- Stasis::Gems.dependencies.should == [:rake]
170
- Stasis::Gems.development_dependencies.should == []
171
- end
172
-
173
- it "should return proper values for Gems.gemset_names" do
174
- Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
175
- end
176
- end
177
-
178
- describe :nil do
179
- before(:each) do
180
- Stasis::Gems.gemset = nil
181
- end
182
-
183
- it "should set everything to nil" do
184
- Stasis::Gems.gemset.should == nil
185
- Stasis::Gems.gemsets.should == nil
186
- Stasis::Gems.versions.should == nil
187
- end
188
- end
189
- end
190
-
191
- describe :gemset_from_loaded_specs do
192
- before(:each) do
193
- Gem.stub!(:loaded_specs)
194
- end
195
-
196
- it "should return the correct gemset for name gem" do
197
- Gem.should_receive(:loaded_specs).and_return({ "name" => nil })
198
- Stasis::Gems.send(:gemset_from_loaded_specs).should == :default
199
- end
200
-
201
- it "should return the correct gemset for name-rspec gem" do
202
- Gem.should_receive(:loaded_specs).and_return({ "name-rspec2" => nil })
203
- Stasis::Gems.send(:gemset_from_loaded_specs).should == :rspec2
204
- end
205
- end
206
-
207
- describe :reload_gemspec do
208
- it "should populate @gemspec" do
209
- Stasis::Gems.gemspec.hash.should == {
210
- "name" => "name",
211
- "version" => "0.1.0",
212
- "authors" => ["Author"],
213
- "email" => "email@email.com",
214
- "homepage" => "http://github.com/author/name",
215
- "summary" => "Summary",
216
- "description" => "Description",
217
- "dependencies" => [
218
- "rake",
219
- { "default" => [ "mysql" ] },
220
- { "rspec2" => [ "mysql2" ] }
221
- ],
222
- "development_dependencies" => nil
223
- }
224
- end
225
-
226
- it "should create methods from keys of @gemspec" do
227
- Stasis::Gems.gemspec.name.should == "name"
228
- Stasis::Gems.gemspec.version.should == "0.1.0"
229
- Stasis::Gems.gemspec.authors.should == ["Author"]
230
- Stasis::Gems.gemspec.email.should == "email@email.com"
231
- Stasis::Gems.gemspec.homepage.should == "http://github.com/author/name"
232
- Stasis::Gems.gemspec.summary.should == "Summary"
233
- Stasis::Gems.gemspec.description.should == "Description"
234
- Stasis::Gems.gemspec.dependencies.should == [
235
- "rake",
236
- { "default" => ["mysql"] },
237
- { "rspec2" => [ "mysql2" ] }
238
- ]
239
- Stasis::Gems.gemspec.development_dependencies.should == nil
240
- end
241
-
242
- it "should produce a valid gemspec" do
243
- Stasis::Gems.gemset = :default
244
- gemspec = File.expand_path("../../../stasis.gemspec", __FILE__)
245
- gemspec = eval(File.read(gemspec), binding, gemspec)
246
- gemspec.validate.should == true
247
- end
248
- end
249
- end