rockets 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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +68 -0
- data/VERSION +1 -0
- data/bin/rocket_server +0 -0
- data/lib/rack/rockets.rb +21 -0
- data/lib/rack/rockets/abstract.rb +17 -0
- data/lib/rack/rockets/javascript.rb +5 -0
- data/lib/rack/rockets/options.rb +94 -0
- data/lib/rack/rockets/stylesheet.rb +5 -0
- data/test/rockets_test.rb +19 -0
- data/test/test_helper.rb +9 -0
- metadata +99 -0
data/.document
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 brianthecoder
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
= rockets
|
|
2
|
+
|
|
3
|
+
Description goes here.
|
|
4
|
+
|
|
5
|
+
== Note on Patches/Pull Requests
|
|
6
|
+
|
|
7
|
+
* Fork the project.
|
|
8
|
+
* Make your feature addition or bug fix.
|
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
|
10
|
+
future version unintentionally.
|
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
|
12
|
+
(if you want to have your own version, that is fine but
|
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
|
15
|
+
|
|
16
|
+
== Copyright
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2009 brianthecoder. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "rockets"
|
|
8
|
+
gem.summary = %Q{sprockets written in rack}
|
|
9
|
+
gem.description = %Q{Middle ware to process directives in your javascript and css (maybe other stuff later?) and then compile it to a single file, also plan on adding a caching layer via redis or memcache so its not so i/o bound}
|
|
10
|
+
gem.email = "wbsmith83@gmail.com"
|
|
11
|
+
gem.homepage = "http://github.com/BrianTheCoder/rockets"
|
|
12
|
+
gem.authors = ["brianthecoder"]
|
|
13
|
+
gem.files.include %w(lib/rack/rockets.rb lib/rack/rockets/abstract.rb lib/rack/rockets/javascript.rb lib/rack/rockets/options.rb lib/rack/rockets/stylesheet.rb)
|
|
14
|
+
gem.add_development_dependency "yard"
|
|
15
|
+
gem.add_dependency "extlib"
|
|
16
|
+
gem.add_dependency "mime-types", "1.16"
|
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
18
|
+
end
|
|
19
|
+
Jeweler::GemcutterTasks.new
|
|
20
|
+
rescue LoadError
|
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
|
26
|
+
test.libs << 'lib' << 'test'
|
|
27
|
+
test.pattern = 'test/**/*_test.rb'
|
|
28
|
+
test.verbose = true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
require 'rcov/rcovtask'
|
|
33
|
+
Rcov::RcovTask.new do |test|
|
|
34
|
+
test.libs << 'test'
|
|
35
|
+
test.pattern = 'test/**/*_test.rb'
|
|
36
|
+
test.verbose = true
|
|
37
|
+
end
|
|
38
|
+
rescue LoadError
|
|
39
|
+
task :rcov do
|
|
40
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
task :test => :check_dependencies
|
|
45
|
+
|
|
46
|
+
begin
|
|
47
|
+
require 'reek/rake_task'
|
|
48
|
+
Reek::RakeTask.new do |t|
|
|
49
|
+
t.fail_on_error = true
|
|
50
|
+
t.verbose = false
|
|
51
|
+
t.source_files = 'lib/**/*.rb'
|
|
52
|
+
end
|
|
53
|
+
rescue LoadError
|
|
54
|
+
task :reek do
|
|
55
|
+
abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
task :default => :test
|
|
60
|
+
|
|
61
|
+
begin
|
|
62
|
+
require 'yard'
|
|
63
|
+
YARD::Rake::YardocTask.new
|
|
64
|
+
rescue LoadError
|
|
65
|
+
task :yardoc do
|
|
66
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
|
67
|
+
end
|
|
68
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
data/bin/rocket_server
ADDED
|
File without changes
|
data/lib/rack/rockets.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'extlib'
|
|
2
|
+
require 'mime/types'
|
|
3
|
+
|
|
4
|
+
module Rack
|
|
5
|
+
# Automatically sets the ETag header on all String bodies
|
|
6
|
+
class Rockets
|
|
7
|
+
def initialize(app, options = {}, &block)
|
|
8
|
+
@app = app
|
|
9
|
+
|
|
10
|
+
instance_eval(&block) if block_given?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def root; @root ||= %x{pwd}.chomp end
|
|
14
|
+
|
|
15
|
+
def call(env)
|
|
16
|
+
status, headers, body = @app.call(env)
|
|
17
|
+
|
|
18
|
+
[status, headers, body]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Rack::Rockets
|
|
2
|
+
class AbstractProcessor
|
|
3
|
+
attr_accessor :path
|
|
4
|
+
def initialize(path, options = {}, &block)
|
|
5
|
+
self.path = path
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def call(env)
|
|
9
|
+
proccess
|
|
10
|
+
render
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def process; raise NotImplementedError, 'you must implement the process method' end
|
|
14
|
+
|
|
15
|
+
def render; raise NotImplementedError, 'you must implement the process method' end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
module Rack::Rockets
|
|
2
|
+
module Options
|
|
3
|
+
class << self
|
|
4
|
+
private
|
|
5
|
+
def option_accessor(key)
|
|
6
|
+
define_method(key) { || read_option(key) }
|
|
7
|
+
define_method("#{key}=") { |value| write_option(key, value) }
|
|
8
|
+
define_method("#{key}?") { || !! read_option(key) }
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Enable verbose trace logging. This option is currently enabled by
|
|
13
|
+
# default but is likely to be disabled in a future release.
|
|
14
|
+
option_accessor :verbose
|
|
15
|
+
|
|
16
|
+
# path to read the files from
|
|
17
|
+
option_accessor :read_path
|
|
18
|
+
|
|
19
|
+
# path to write the resulting files to
|
|
20
|
+
option_accessor :write_path
|
|
21
|
+
|
|
22
|
+
# store timestamps of files from when they were last served in order to have to keep from
|
|
23
|
+
# reading from the file every time will probably be tokyo, redis, memcached compliant
|
|
24
|
+
option_accessor :cache_store
|
|
25
|
+
|
|
26
|
+
# an array of the types you want to be processed, should be a symbol of the file extension
|
|
27
|
+
option_accessor :types
|
|
28
|
+
|
|
29
|
+
# The underlying options Hash. During initialization (or outside of a
|
|
30
|
+
# request), this is a default values Hash. During a request, this is the
|
|
31
|
+
# Rack environment Hash. The default values Hash is merged in underneath
|
|
32
|
+
# the Rack environment before each request is processed.
|
|
33
|
+
def options
|
|
34
|
+
@env || @default_options
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Set multiple options.
|
|
38
|
+
def options=(hash={})
|
|
39
|
+
hash.each { |key,value| write_option(key, value) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Set an option. When +option+ is a Symbol, it is set in the Rack
|
|
43
|
+
# Environment as "rack-cache.option". When +option+ is a String, it
|
|
44
|
+
# exactly as specified. The +option+ argument may also be a Hash in
|
|
45
|
+
# which case each key/value pair is merged into the environment as if
|
|
46
|
+
# the #set method were called on each.
|
|
47
|
+
def set(option, value=self, &block)
|
|
48
|
+
if block_given?
|
|
49
|
+
write_option option, block
|
|
50
|
+
elsif value == self
|
|
51
|
+
self.options = option.to_hash
|
|
52
|
+
else
|
|
53
|
+
write_option option, value
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
def read_option(key)
|
|
59
|
+
options[option_name(key)]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def write_option(key, value)
|
|
63
|
+
options[option_name(key)] = value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def option_name(key)
|
|
67
|
+
case key
|
|
68
|
+
when Symbol ; "rack-rockets.#{key}"
|
|
69
|
+
when String ; key
|
|
70
|
+
else raise ArgumentError
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
def initialize_options(options={})
|
|
76
|
+
@default_options = {
|
|
77
|
+
'rack-rockets.types' => %w(css js)
|
|
78
|
+
'rack-rockets.cache_store' => nil,
|
|
79
|
+
'rack-rockets.processors' => {
|
|
80
|
+
:js => Javascript,
|
|
81
|
+
:css => Stylesheet
|
|
82
|
+
},
|
|
83
|
+
'rack-rockets.read_path' => root / 'public',
|
|
84
|
+
'rack-rockets.write_path' => root / 'public'
|
|
85
|
+
}
|
|
86
|
+
self.options = options
|
|
87
|
+
|
|
88
|
+
options[:types].each do |format|
|
|
89
|
+
key = :"#{format}_path"
|
|
90
|
+
options[key] = opts[:read_path] / opts unless opts.has_key?(key)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rockets
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- brianthecoder
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-10-11 00:00:00 -05:00
|
|
13
|
+
default_executable: rocket_server
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: yard
|
|
17
|
+
type: :development
|
|
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: extlib
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: mime-types
|
|
37
|
+
type: :runtime
|
|
38
|
+
version_requirement:
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - "="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: "1.16"
|
|
44
|
+
version:
|
|
45
|
+
description: Middle ware to process directives in your javascript and css (maybe other stuff later?) and then compile it to a single file, also plan on adding a caching layer via redis or memcache so its not so i/o bound
|
|
46
|
+
email: wbsmith83@gmail.com
|
|
47
|
+
executables:
|
|
48
|
+
- rocket_server
|
|
49
|
+
extensions: []
|
|
50
|
+
|
|
51
|
+
extra_rdoc_files:
|
|
52
|
+
- LICENSE
|
|
53
|
+
- README.rdoc
|
|
54
|
+
files:
|
|
55
|
+
- .document
|
|
56
|
+
- .gitignore
|
|
57
|
+
- LICENSE
|
|
58
|
+
- README.rdoc
|
|
59
|
+
- Rakefile
|
|
60
|
+
- VERSION
|
|
61
|
+
- bin/rocket_server
|
|
62
|
+
- lib/rack/rockets.rb
|
|
63
|
+
- lib/rack/rockets/abstract.rb
|
|
64
|
+
- lib/rack/rockets/javascript.rb
|
|
65
|
+
- lib/rack/rockets/options.rb
|
|
66
|
+
- lib/rack/rockets/stylesheet.rb
|
|
67
|
+
- test/rockets_test.rb
|
|
68
|
+
- test/test_helper.rb
|
|
69
|
+
has_rdoc: true
|
|
70
|
+
homepage: http://github.com/BrianTheCoder/rockets
|
|
71
|
+
licenses: []
|
|
72
|
+
|
|
73
|
+
post_install_message:
|
|
74
|
+
rdoc_options:
|
|
75
|
+
- --charset=UTF-8
|
|
76
|
+
require_paths:
|
|
77
|
+
- lib
|
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: "0"
|
|
83
|
+
version:
|
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: "0"
|
|
89
|
+
version:
|
|
90
|
+
requirements: []
|
|
91
|
+
|
|
92
|
+
rubyforge_project:
|
|
93
|
+
rubygems_version: 1.3.5
|
|
94
|
+
signing_key:
|
|
95
|
+
specification_version: 3
|
|
96
|
+
summary: sprockets written in rack
|
|
97
|
+
test_files:
|
|
98
|
+
- test/rockets_test.rb
|
|
99
|
+
- test/test_helper.rb
|