rack-opal 0.9.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/lib/rack/opal/compiler.rb +44 -0
- data/lib/rack/opal.rb +13 -0
- metadata +97 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'opal'
|
3
|
+
require 'opal/builder'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Rack
|
7
|
+
|
8
|
+
class OpalCompiler
|
9
|
+
|
10
|
+
def initialize(app, options = {})
|
11
|
+
@app = app
|
12
|
+
@source_dir = options[:source_dir]
|
13
|
+
@build_dir = options[:build_dir]
|
14
|
+
@files = Dir["#{@source_dir}/**/*.rb"]
|
15
|
+
@app_name = options[:app_name]
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
status, headers, response = @app.call(env)
|
20
|
+
if !headers['Content-Type'].nil? && headers['Content-Type'].match('text/html') then
|
21
|
+
build
|
22
|
+
end
|
23
|
+
[status, headers, response]
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def write_code(code, out)
|
29
|
+
FileUtils.mkdir_p ::File.dirname(out)
|
30
|
+
::File.open(out, 'w+') { |o| o.puts code }
|
31
|
+
end
|
32
|
+
|
33
|
+
def build
|
34
|
+
@files.collect! { | file |
|
35
|
+
file.gsub @source_dir, ""
|
36
|
+
}
|
37
|
+
out = ::File.join @build_dir, "#{@app_name}.js"
|
38
|
+
code = Opal.build_files(@files, @source_dir)
|
39
|
+
code ||= ""
|
40
|
+
write_code code, out
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/lib/rack/opal.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-opal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 59
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Anton Yakimov
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-11-08 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rack
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 1.0.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: opal
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 37
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 3
|
48
|
+
- 27
|
49
|
+
version: 0.3.27
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
description: Rack middleware for automagical Opal compilation
|
53
|
+
email: anton.jakimov@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files: []
|
59
|
+
|
60
|
+
files:
|
61
|
+
- lib/rack/opal.rb
|
62
|
+
- lib/rack/opal/compiler.rb
|
63
|
+
homepage: http://github.com/t0xa/rack-opal
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.24
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Rack middleware compiles all Opal ruby scripts in the predefined directory into a javascript file.
|
96
|
+
test_files: []
|
97
|
+
|