remi-staticify 0.1.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/README.rdoc +3 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/bin/staticify +95 -0
- metadata +75 -0
data/README.rdoc
ADDED
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.0
|
data/bin/staticify
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Simple script for staticifying your Rack applications
|
4
|
+
#
|
5
|
+
# Checks for config.ru / Rails by defualt, 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
|
+
|
30
|
+
USAGE
|
31
|
+
end
|
32
|
+
|
33
|
+
if ARGV.empty?
|
34
|
+
usage
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
#### ==== Option Parsing ==== ####
|
39
|
+
|
40
|
+
files_to_require = []
|
41
|
+
ruby_to_run = nil
|
42
|
+
path_to_cache_to = '.site'
|
43
|
+
|
44
|
+
opts = OptionParser.new do |opts|
|
45
|
+
opts.on('-r', '--require [file]') {|x| files_to_require << x }
|
46
|
+
opts.on('-a', '--app [ruby]') {|x| ruby_to_run = x }
|
47
|
+
opts.on('-d', '--dir [dir]') {|x| path_to_cache_to = x }
|
48
|
+
end
|
49
|
+
opts.parse! ARGV
|
50
|
+
|
51
|
+
app_directory = ARGV.shift
|
52
|
+
unless File.directory? app_directory
|
53
|
+
puts "App directory not found: #{ app_directory }\n\n"
|
54
|
+
usage
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
FileUtils.cd app_directory
|
58
|
+
|
59
|
+
files_to_require.each {|file| require file }
|
60
|
+
if ruby_to_run
|
61
|
+
begin
|
62
|
+
RackBox.app = eval(ruby_to_run)
|
63
|
+
rescue Exception => ex
|
64
|
+
puts "Tried running Ruby code to set Rack app: #{ ruby_to_run.inspect }"
|
65
|
+
raise ex
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
unless RackBox.app(:silent => true)
|
70
|
+
puts "Cannot find your Rack application\n\n"
|
71
|
+
usage
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
#### ==== Get Routes to Cache ==== ####
|
76
|
+
|
77
|
+
paths_to_cache = []
|
78
|
+
while path = gets
|
79
|
+
paths_to_cache << path.strip
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "Caching to #{ path_to_cache_to }"
|
83
|
+
|
84
|
+
puts "#{ paths_to_cache.length } paths to cache:"
|
85
|
+
|
86
|
+
#### ==== Cache the Routes ==== ####"
|
87
|
+
|
88
|
+
FileUtils.rm_rf path_to_cache_to
|
89
|
+
|
90
|
+
RackBox.app = Rack::Staticifier.new(RackBox.app, :root => path_to_cache_to)
|
91
|
+
|
92
|
+
paths_to_cache.each do |path|
|
93
|
+
response = RackBox.request path
|
94
|
+
puts " #{ response.status } #{ path }"
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remi-staticify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- remi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-15 00:00:00 -07:00
|
13
|
+
default_executable: staticify
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: remi-rackbox
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: remi-rack-staticifier
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
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: false
|
49
|
+
homepage: http://github.com/remi/staticify
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --charset=UTF-8
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.2.0
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Tool for staticly caching Ruby web applications
|
74
|
+
test_files: []
|
75
|
+
|