staticify 0.1.1
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.rdoc +50 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/bin/staticify +110 -0
- metadata +83 -0
data/README.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= Staticify
|
2
|
+
|
3
|
+
Staticify is a tool for creating static sites in Ruby.
|
4
|
+
|
5
|
+
There are lots of tools out there already for creating static sites, eg:
|
6
|
+
Jekyll:: http://jekyllrb.com
|
7
|
+
StaticMatic:: http://staticmatic.rubyforge.org
|
8
|
+
webgen:: http://webgen.rubyforge.org
|
9
|
+
Webby:: http://webby.rubyforge.org
|
10
|
+
|
11
|
+
The problem with these tools, in my opinion, is that they make you code
|
12
|
+
your sites in a certain way.
|
13
|
+
|
14
|
+
What if you want to code your blog in Rails or Sinatra or something?
|
15
|
+
|
16
|
+
Staticify is intended to solve this problem for you. If you want
|
17
|
+
to code your static site in any Rack-based web framework, go right ahead!
|
18
|
+
|
19
|
+
You can use Staticify to statically cache responses to your app.
|
20
|
+
|
21
|
+
== Installation
|
22
|
+
|
23
|
+
$ gem sources -a http://gems.github.com
|
24
|
+
$ sudo gem install remi-staticify
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
Simple script for staticifying your Rack applications
|
29
|
+
|
30
|
+
staticify == %{ For staticifying your Rack applications }
|
31
|
+
|
32
|
+
Usage:
|
33
|
+
echo 'paths' | staticify # print this usage information
|
34
|
+
echo 'paths' | staticify . # staticify Rack app in current directory
|
35
|
+
|
36
|
+
Note:
|
37
|
+
staticify expects to get the paths to hit via STDIN
|
38
|
+
|
39
|
+
Options:
|
40
|
+
-d, --dir some/directory # directory to save files to
|
41
|
+
-a, --app "MyApp.new" # ruby to eval to get Rack app
|
42
|
+
-r, --require file[.rb] # ruby file(s) to require
|
43
|
+
|
44
|
+
== Notes
|
45
|
+
|
46
|
+
Checks for config.ru / Rails by default, otherwise you can:
|
47
|
+
|
48
|
+
$ staticify -r myapp.rb --app 'lambda {|env| [200, {}, "hi!"] }' info
|
49
|
+
$ staticify -r myapp.rb,another-file.rb --app 'Sinatra::Application' get '/'
|
50
|
+
$ staticify -r myapp --app 'MyApp.new' '/'
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
puts "\nGem: staticify\n\n"
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'jeweler'
|
10
|
+
Jeweler::Tasks.new do |s|
|
11
|
+
s.name = 'staticify'
|
12
|
+
s.summary = 'Tool for staticly caching Ruby web applications'
|
13
|
+
s.email = 'remi@remitaylor.com'
|
14
|
+
s.homepage = 'http://github.com/remi/staticify'
|
15
|
+
s.description = 'Tool for staticly caching Ruby web applications (based on Rack::Staticifier)'
|
16
|
+
s.authors = %w( remi )
|
17
|
+
s.files = FileList['[A-Z]*', '{lib,spec,bin,examples}/**/*']
|
18
|
+
s.add_dependency 'remi-rackbox'
|
19
|
+
s.add_dependency 'remi-rack-staticifier'
|
20
|
+
# s.executables << 'staticify'
|
21
|
+
# s.rubyforge_project = 'gemname'
|
22
|
+
# s.extra_rdoc_files = %w( README.rdoc )
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new do |t|
|
29
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Run all examples with RCov"
|
33
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
34
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
35
|
+
t.rcov = true
|
36
|
+
end
|
37
|
+
|
38
|
+
# require 'hanna'
|
39
|
+
# require 'darkfish-rdoc'
|
40
|
+
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = 'staticify'
|
44
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
45
|
+
# rdoc.options += ["--template=#{`allison --path`}"] # sudo gem install allison
|
46
|
+
# rdoc.options += %w( -f darkfish ) # sudo gem install darkfish-rdoc
|
47
|
+
# rdoc.options += %w( -T hanna ) # sudo gem install mislav-hanna
|
48
|
+
rdoc.options += %w( -m README.rdoc ) # the initial page displayed
|
49
|
+
rdoc.rdoc_files.include('README.rdoc')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Confirm that gemspec is $SAFE'
|
54
|
+
task :safe do
|
55
|
+
require 'yaml'
|
56
|
+
require 'rubygems/specification'
|
57
|
+
data = File.read('staticify.gemspec')
|
58
|
+
spec = nil
|
59
|
+
if data !~ %r{!ruby/object:Gem::Specification}
|
60
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
61
|
+
else
|
62
|
+
spec = YAML.load(data)
|
63
|
+
end
|
64
|
+
spec.validate
|
65
|
+
puts spec
|
66
|
+
puts "OK"
|
67
|
+
end
|
68
|
+
|
69
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bin/staticify
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Simple script for staticifying your Rack applications
|
4
|
+
#
|
5
|
+
# Checks for config.ru / Rails by default, otherwise you can:
|
6
|
+
#
|
7
|
+
# $ staticify -r myapp.rb --app 'lambda {|env| [200, {}, "hi!"] }' info
|
8
|
+
# $ staticify -r myapp.rb,another-file.rb --app 'Sinatra::Application' get '/'
|
9
|
+
# $ staticify -r myapp --app 'MyApp.new' '/'
|
10
|
+
#
|
11
|
+
%w( rubygems rackbox optparse fileutils rack-staticifier ).each {|lib| require lib }
|
12
|
+
|
13
|
+
def usage
|
14
|
+
puts <<USAGE
|
15
|
+
|
16
|
+
staticify == %{ For staticifying your Rack applications }
|
17
|
+
|
18
|
+
Usage:
|
19
|
+
echo 'paths' | staticify # print this usage information
|
20
|
+
echo 'paths' | staticify . # staticify Rack app in current directory
|
21
|
+
|
22
|
+
Note:
|
23
|
+
staticify expects to get the paths to hit via STDIN
|
24
|
+
|
25
|
+
Options:
|
26
|
+
-d, --dir some/directory # directory to save files to
|
27
|
+
-a, --app "MyApp.new" # ruby to eval to get Rack app
|
28
|
+
-r, --require file[.rb] # ruby file(s) to require
|
29
|
+
-p, --paths "/,/foo,/bar" # specify paths (instead of STDIN)
|
30
|
+
-y, --dry-run # just print what we *would* do
|
31
|
+
-s, --save # don't delete dir before running
|
32
|
+
|
33
|
+
USAGE
|
34
|
+
end
|
35
|
+
|
36
|
+
if ARGV.empty?
|
37
|
+
usage
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
#### ==== Option Parsing ==== ####
|
42
|
+
|
43
|
+
files_to_require = []
|
44
|
+
ruby_to_run = nil
|
45
|
+
path_to_cache_to = '.site'
|
46
|
+
paths_to_cache = []
|
47
|
+
dry_run = false
|
48
|
+
overwrite_dir = true
|
49
|
+
|
50
|
+
opts = OptionParser.new do |opts|
|
51
|
+
opts.on('-r', '--require [file]') {|x| files_to_require << x }
|
52
|
+
opts.on('-a', '--app [ruby]') {|x| ruby_to_run = x }
|
53
|
+
opts.on('-d', '--dir [dir]') {|x| path_to_cache_to = x }
|
54
|
+
opts.on('-p', '--paths [paths]') {|x| paths_to_cache = x.split(',') }
|
55
|
+
opts.on('-y', '--dry-run') { dry_run = true }
|
56
|
+
opts.on('-s', '--save') { overwrite_dir = false }
|
57
|
+
end
|
58
|
+
opts.parse! ARGV
|
59
|
+
|
60
|
+
app_directory = ARGV.shift
|
61
|
+
unless File.directory? app_directory
|
62
|
+
puts "App directory not found: #{ app_directory }\n\n"
|
63
|
+
usage
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
FileUtils.cd app_directory
|
67
|
+
|
68
|
+
files_to_require.each {|file| require file }
|
69
|
+
if ruby_to_run
|
70
|
+
begin
|
71
|
+
RackBox.app = eval(ruby_to_run)
|
72
|
+
rescue Exception => ex
|
73
|
+
puts "Tried running Ruby code to set Rack app: #{ ruby_to_run.inspect }"
|
74
|
+
raise ex
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
unless RackBox.app(:silent => true)
|
79
|
+
puts "Cannot find your Rack application\n\n"
|
80
|
+
usage
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
|
84
|
+
#### ==== Get Routes to Cache ==== ####
|
85
|
+
|
86
|
+
if paths_to_cache.empty?
|
87
|
+
while path = gets
|
88
|
+
paths_to_cache << path.strip
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
puts "Caching to #{ path_to_cache_to }"
|
93
|
+
|
94
|
+
puts "#{ paths_to_cache.length } paths to cache:"
|
95
|
+
|
96
|
+
#### ==== Cache the Routes ==== ####"
|
97
|
+
|
98
|
+
puts "rm -rf #{ path_to_cache_to }" if overwrite_dir
|
99
|
+
FileUtils.rm_rf path_to_cache_to if overwrite_dir && !dry_run
|
100
|
+
|
101
|
+
RackBox.app = Rack::Staticifier.new(RackBox.app, :root => path_to_cache_to)
|
102
|
+
|
103
|
+
paths_to_cache.each do |path|
|
104
|
+
if dry_run
|
105
|
+
puts " #{ path }"
|
106
|
+
else
|
107
|
+
response = RackBox.request path
|
108
|
+
puts " #{ response.status } #{ path }"
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: staticify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- remi
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2009-06-15 00:00:00 -07:00
|
19
|
+
default_executable: staticify
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rack-staticifier
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Tool for staticly caching Ruby web applications (based on Rack::Staticifier)
|
36
|
+
email: remi@remitaylor.com
|
37
|
+
executables:
|
38
|
+
- staticify
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.rdoc
|
43
|
+
files:
|
44
|
+
- README.rdoc
|
45
|
+
- Rakefile
|
46
|
+
- VERSION
|
47
|
+
- bin/staticify
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/remi/staticify
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --charset=UTF-8
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Tool for staticly caching Ruby web applications
|
82
|
+
test_files: []
|
83
|
+
|