sssmoke 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -4,36 +4,22 @@ Slap Ruby scripts on a web server in seconds.
4
4
 
5
5
  ## Installation
6
6
 
7
- $ gem install sssmoke
7
+ gem install sssmoke
8
8
 
9
9
  ## Usage
10
10
 
11
- Put erb templates in a directory (with extension _erb_).
12
-
13
- To put the whole directory on a web server, run:
11
+ Go to a folder containing erb templates, and:
14
12
 
15
13
  sssmoke
16
14
 
17
- Now open:
18
-
19
- http://localhost:<your web server's default port>/<name of erb script>
20
-
15
+ For example, a template named _foo.erb_ will be available at _http://localhost:4567/foo_. (The port number could be different if you use a web server other than WEBrick).
21
16
 
22
- ## Pro Usage for Powah Usah
17
+ ## Pro Usage for Powah Usahs
23
18
 
24
19
  If you want to sssmoke a directory other than the current directory:
25
20
 
26
21
  sssmoke <directory name>
27
22
 
28
- To expose a single template at the server's root:
23
+ To smoke a single erb template at _http://localhost:4567_:
29
24
 
30
25
  sssmoke <file name>
31
-
32
-
33
- ## Contributing
34
-
35
- 1. Fork it
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create new Pull Request
@@ -1,19 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require 'sinatra/base'
3
- require 'erb'
4
- require 'tilt'
5
2
 
6
- filename = ARGV[0] || "."
7
- if File.directory? filename
8
- Class.new(Sinatra::Base) do
9
- set :views, filename
10
- get('/') { erb :index }
11
- get('/:page') {|page| erb page.to_sym }
12
- run!
13
- end
14
- else
15
- Class.new(Sinatra::Base) do
16
- get('/') { Tilt::ERBTemplate.new(filename).render }
17
- run!
18
- end
19
- end
3
+ require "sssmoke"
@@ -1 +1,35 @@
1
- require "sssmoke/version"
1
+ require "sssmoke/version"
2
+
3
+ module Sssmoke
4
+ FOUR_O_FOUR = [404, "404 - Page not found"]
5
+ require 'sinatra/base'
6
+
7
+ class Base < Sinatra::Base
8
+ require 'erb'
9
+ require 'tilt'
10
+
11
+ def show(template)
12
+ template = "#{template}.erb" unless template.end_with? '.erb'
13
+ File.exist?(template) ? Tilt::ERBTemplate.new(template).render : FOUR_O_FOUR
14
+ end
15
+ end
16
+
17
+ def self.app
18
+ filename = ARGV.shift || "."
19
+
20
+ if File.directory? filename
21
+ Class.new(Sssmoke::Base) do
22
+ set :views, filename
23
+ get('/') { show 'index' }
24
+ get('/:template') {|template| show template }
25
+ end
26
+ else
27
+ Class.new(Sssmoke::Base) do
28
+ get('/') { show filename }
29
+ error(404) { FOUR_O_FOUR }
30
+ end
31
+ end
32
+ end
33
+
34
+ app.run!
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Sssmoke
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sssmoke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-15 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake