closure 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/docs/closure/Closure/BeanShell.html +1 -1
  3. data/docs/closure/Closure/Compiler/Compilation.html +1 -1
  4. data/docs/closure/Closure/Compiler/Error.html +1 -1
  5. data/docs/closure/Closure/Compiler.html +1 -1
  6. data/docs/closure/Closure/FileResponse.html +1 -1
  7. data/docs/closure/Closure/Goog.html +6 -6
  8. data/docs/closure/Closure/Middleware.html +1 -1
  9. data/docs/closure/Closure/Script/NotFound.html +1 -1
  10. data/docs/closure/Closure/Script/RenderStackOverflow.html +1 -1
  11. data/docs/closure/Closure/Script.html +1 -1
  12. data/docs/closure/Closure/Server.html +1 -1
  13. data/docs/closure/Closure/ShowExceptions.html +9 -9
  14. data/docs/closure/Closure/Sources.html +1 -1
  15. data/docs/closure/Closure/Templates/Error.html +1 -1
  16. data/docs/closure/Closure/Templates.html +1 -1
  17. data/docs/closure/Closure.html +1 -1
  18. data/docs/closure/_index.html +1 -1
  19. data/docs/closure/file.LICENSE.html +1 -1
  20. data/docs/closure/file.README.html +1 -1
  21. data/docs/closure/index.html +1 -1
  22. data/docs/closure/top-level-namespace.html +1 -1
  23. data/lib/closure/beanshell.rb +17 -17
  24. data/lib/closure/compiler.rb +10 -10
  25. data/lib/closure/goog.rb +58 -59
  26. data/lib/closure/script.rb +20 -21
  27. data/lib/closure/show_exceptions.rb +0 -3
  28. data/lib/closure/templates.rb +13 -13
  29. data/lib/closure/version.rb +1 -1
  30. data/lib/closure.rb +12 -12
  31. metadata +3 -8
  32. data/scripts/modules/compiler_build.js +0 -6
  33. data/scripts/modules/compiler_build.map +0 -24
  34. data/scripts/modules/compiler_build_api.js +0 -1
  35. data/scripts/modules/compiler_build_app.js +0 -78
  36. data/scripts/modules/compiler_build_settings.js +0 -2
@@ -15,7 +15,7 @@
15
15
  require 'pathname'
16
16
 
17
17
  class Closure
18
-
18
+
19
19
  # A Closure::Script instance is the context in which scripts are rendered.
20
20
  # It inherits everything from Rack::Request and supplies a Response instance
21
21
  # you can use for redirects, cookies, and other controller actions.
@@ -26,9 +26,9 @@ class Closure
26
26
 
27
27
  class RenderStackOverflow < StandardError
28
28
  end
29
-
29
+
30
30
  ENV_ERROR_CONTENT_TYPE = 'closure.error.content_type'
31
-
31
+
32
32
  def initialize(env, sources, filename)
33
33
  super(env)
34
34
  @render_stack = []
@@ -43,7 +43,7 @@ class Closure
43
43
  # Make errors appear from the render instead of the engine.call
44
44
  e.set_backtrace e.backtrace[1..-1]
45
45
  env[ENV_ERROR_CONTENT_TYPE] = @response.finish[1]["Content-Type"] rescue nil
46
- raise e
46
+ raise e
47
47
  end
48
48
  @response.status = 404
49
49
  @response.write "404 Not Found\n"
@@ -53,9 +53,9 @@ class Closure
53
53
  env[ENV_ERROR_CONTENT_TYPE] = @response.finish[1]["Content-Type"] rescue nil
54
54
  raise e
55
55
  end
56
-
56
+
57
57
  # After rendering, #finish will be sent to the client.
58
- # If you replace the response or add to the response#body,
58
+ # If you replace the response or add to the response#body,
59
59
  # the script engine rendering will not be added.
60
60
  # @return [Rack::Response]
61
61
  attr_accessor :response
@@ -67,10 +67,10 @@ class Closure
67
67
  # An array of filenames representing the current render stack.
68
68
  # @example
69
69
  # <%= if render_stack.size == 1
70
- # render 'html_version'
70
+ # render 'html_version'
71
71
  # else
72
72
  # render 'included_version'
73
- # end
73
+ # end
74
74
  # %>
75
75
  # @return [<Array>]
76
76
  attr_reader :render_stack
@@ -84,7 +84,7 @@ class Closure
84
84
  if render_stack.size > 100
85
85
  # Since nobody sane should recurse through here, this mainly
86
86
  # finds a render self that you might get after a copy and paste
87
- raise RenderStackOverflow
87
+ raise RenderStackOverflow
88
88
  elsif render_stack.size > 0
89
89
  # Hooray for relative paths and easily movable files
90
90
  filename = File.expand_path(filename, File.dirname(render_stack.last))
@@ -93,16 +93,16 @@ class Closure
93
93
  filename = File.expand_path(filename)
94
94
  raise NotFound if File.basename(filename) =~ /^_/
95
95
  end
96
- ext = File.extname(filename)
96
+ fext = File.extname(filename)
97
97
  files1 = [filename]
98
- files1 << filename + '.html' if ext == ''
99
- files1 << filename.sub(/.html$/,'') if ext == '.html'
98
+ files1 << filename + '.html' if fext == ''
99
+ files1 << filename.sub(/.html$/,'') if fext == '.html'
100
100
  files1.each do |filename1|
101
101
  Closure.config.engines.each do |ext, engine|
102
102
  files2 = [filename1+ext]
103
103
  files2 << filename1.gsub(/.html$/, ext) if File.extname(filename1) == '.html'
104
104
  unless filename1 =~ /^_/ or render_stack.empty?
105
- files2 = files2 + files2.collect {|f| "#{File.dirname(f)}/_#{File.basename(f)}"}
105
+ files2 = files2 + files2.collect {|f| "#{File.dirname(f)}/_#{File.basename(f)}"}
106
106
  end
107
107
  files2.each do |filename2|
108
108
  if File.file?(filename2) and File.readable?(filename2)
@@ -120,7 +120,7 @@ class Closure
120
120
  end
121
121
  raise NotFound
122
122
  end
123
-
123
+
124
124
  # Helper for finding files relative to Scripts.
125
125
  # @param [String] filename
126
126
  # @return [String] absolute filesystem path
@@ -133,12 +133,11 @@ class Closure
133
133
  # @param [String] filename
134
134
  # @return [String] absolute http path
135
135
  def expand_src(filename, dir=nil)
136
- found = false
137
136
  filename = expand_path filename, dir
138
137
  src = nil
139
- @goog.each do |dir, path|
140
- dir_range = (dir.length..-1)
141
- if filename.index(dir) == 0
138
+ @goog.each do |directory, path|
139
+ dir_range = (directory.length..-1)
140
+ if filename.index(directory) == 0
142
141
  src = "#{path}#{filename.slice(dir_range)}"
143
142
  break
144
143
  end
@@ -146,7 +145,7 @@ class Closure
146
145
  raise Errno::ENOENT unless src
147
146
  src
148
147
  end
149
-
148
+
150
149
  # Helper to locate a file as a file server path.
151
150
  # @param [String] filename
152
151
  # @return [String] relative http path
@@ -155,7 +154,7 @@ class Closure
155
154
  base = Pathname.new File.dirname path_info
156
155
  Pathname.new(file).relative_path_from(base).to_s
157
156
  end
158
-
157
+
159
158
  end
160
-
159
+
161
160
  end
@@ -39,7 +39,6 @@ class Closure
39
39
  body += '"Closure Compiler: %s\n", '
40
40
  body += "#{e.message.rstrip.dump}"
41
41
  body += ')}catch(err){}'
42
- body
43
42
  [200,
44
43
  {"Content-Type" => "application/javascript",
45
44
  "Content-Length" => body.size.to_s},
@@ -50,7 +49,6 @@ class Closure
50
49
  body += '"Closure Templates: 1 error(s)\n$s", '
51
50
  body += "#{e.message.rstrip.dump}"
52
51
  body += ')}catch(err){}'
53
- body
54
52
  [200,
55
53
  {"Content-Type" => "application/javascript",
56
54
  "Content-Length" => body.size.to_s},
@@ -67,7 +65,6 @@ class Closure
67
65
  body += "#{e.message.rstrip.dump}, "
68
66
  body += "#{e.backtrace.join("\n").dump}"
69
67
  body += ')}catch(err){}'
70
- body
71
68
  [200,
72
69
  {"Content-Type" => "application/javascript",
73
70
  "Content-Length" => body.size.to_s},
@@ -15,12 +15,12 @@
15
15
  require 'thread'
16
16
 
17
17
  class Closure
18
-
18
+
19
19
  class Templates
20
-
20
+
21
21
  class Error < StandardError
22
22
  end
23
-
23
+
24
24
  # Compiles soy to javascript with SoyToJsSrcCompiler.jar.
25
25
  # Supports globbing on source filename arguments.
26
26
  # @example
@@ -49,7 +49,7 @@ class Closure
49
49
  args_index += 1
50
50
  end
51
51
  args_index += 1
52
- else
52
+ else
53
53
  arg = args[args_index]
54
54
  arg = File.expand_path(arg, base) if base
55
55
  if arg =~ /\*/
@@ -62,9 +62,9 @@ class Closure
62
62
  end
63
63
  # extract filenames
64
64
  mode = :start
65
- args.each do |arg|
66
- mode = :out and next if arg == '--outputPathFormat'
67
- files << arg if mode == :collect
65
+ args.each do |argument|
66
+ mode = :out and next if argument == '--outputPathFormat'
67
+ files << argument if mode == :collect
68
68
  mode = :collect if mode == :out
69
69
  end
70
70
  # detect source changes
@@ -81,15 +81,15 @@ class Closure
81
81
  mtimes.clear
82
82
  # compile as needed
83
83
  if !compiled
84
- out, err = Closure.run_java Closure.config.soy_js_jar, 'com.google.template.soy.SoyToJsSrcCompiler', args
84
+ _, err = Closure.run_java Closure.config.soy_js_jar, 'com.google.template.soy.SoyToJsSrcCompiler', args
85
85
  unless err.empty?
86
- raise Error, err
86
+ raise Error, err
87
87
  end
88
88
  end
89
89
  # success, keep the mtimes for next time
90
90
  mtimes.merge! new_mtimes
91
91
  end
92
-
92
+
93
93
  private
94
94
 
95
95
  # We are unable to determine an output file to compare mtimes against.
@@ -104,8 +104,8 @@ class Closure
104
104
  end
105
105
  mtimes[:mtimes]
106
106
  end
107
-
108
-
107
+
108
+
109
109
  end
110
-
110
+
111
111
  end
@@ -14,5 +14,5 @@
14
14
 
15
15
 
16
16
  class Closure
17
- VERSION = "1.5.0"
17
+ VERSION = "1.5.1"
18
18
  end
data/lib/closure.rb CHANGED
@@ -28,7 +28,7 @@ require 'tempfile'
28
28
  # run Rack::File.new './public'
29
29
 
30
30
  class Closure
31
-
31
+
32
32
  # Filesystem location of the Closure Script install.
33
33
  # Typically, where the gem was installed. This is mainly used
34
34
  # internally but may be useful for experimental configurations.
@@ -36,15 +36,15 @@ class Closure
36
36
  def self.base_path
37
37
  @@base_path ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
38
38
  end
39
-
39
+
40
40
 
41
41
  # Scripts that are distributed with the gem. These will help get you started quickly.
42
42
  BUILT_INS = {
43
43
  :soy => File.join(base_path, 'closure-templates'),
44
44
  :docs => File.join(base_path, 'docs')
45
45
  }
46
-
47
-
46
+
47
+
48
48
  # Easy config. This adds to the global instance of sources and
49
49
  # supports using the {BUILT_INS}.
50
50
  # @example
@@ -57,7 +57,7 @@ class Closure
57
57
  # @param (Symbol) built_in
58
58
  def self.add_source(directory, path=nil)
59
59
  if directory.kind_of? Symbol
60
- dir = BUILT_INS[directory]
60
+ dir = BUILT_INS[directory]
61
61
  raise "Unknown built-in: #{directory}" unless dir
62
62
  directory = dir
63
63
  end
@@ -73,8 +73,8 @@ class Closure
73
73
  def self.sources
74
74
  @@sources ||= Sources.new
75
75
  end
76
-
77
-
76
+
77
+
78
78
  # Execute jar in a REPL or with JRuby
79
79
  # @private - internal use only
80
80
  # @param (String) jar Path to .jar file
@@ -102,8 +102,8 @@ class Closure
102
102
  end
103
103
  [out, err]
104
104
  end
105
-
106
-
105
+
106
+
107
107
  # Set these before the rack server is called for the first time.
108
108
  # === Attributes:
109
109
  # - (String) *java* -- default: "java" -- Your Java executable. Not used under JRuby.
@@ -123,7 +123,7 @@ class Closure
123
123
  end
124
124
  @@config
125
125
  end
126
-
126
+
127
127
  # Run the welcome server. Handy for gem users.
128
128
  # @example
129
129
  # ruby -e "require 'rubygems'; gem 'closure'; require 'closure'; Closure.welcome"
@@ -139,7 +139,7 @@ class Closure
139
139
  print "Closure Script Welcome Server: http://localhost:#{port}/\n"
140
140
  server.start
141
141
  end
142
-
142
+
143
143
  end
144
144
 
145
- Dir.glob(File.expand_path('**/*.rb', File.dirname(__FILE__))).each {|f| require f}
145
+ Dir.glob(File.expand_path('**/*.rb', File.dirname(__FILE__))).each {|f| require f unless f == __FILE__}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Turnbull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-20 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -105,11 +105,6 @@ files:
105
105
  - scripts/modules/app.js
106
106
  - scripts/modules/app_init.js
107
107
  - scripts/modules/compiler.js.erb
108
- - scripts/modules/compiler_build.js
109
- - scripts/modules/compiler_build.map
110
- - scripts/modules/compiler_build_api.js
111
- - scripts/modules/compiler_build_app.js
112
- - scripts/modules/compiler_build_settings.js
113
108
  - scripts/modules/index.erb
114
109
  - scripts/modules/settings.js
115
110
  - scripts/modules/settings_init.js
@@ -117,7 +112,7 @@ files:
117
112
  - scripts/welcome.erb
118
113
  homepage: https://github.com/AE9RB/closure-script
119
114
  licenses:
120
- - https://opensource.org/licenses/Apache-2.0
115
+ - Apache-2.0
121
116
  metadata: {}
122
117
  post_install_message:
123
118
  rdoc_options: []
@@ -1,6 +0,0 @@
1
- var MODULE_INFO = {"app": [], "api": ["app"], "settings": ["app"]};
2
- var MODULE_URIS = {
3
- "app": ["/modules/compiler_build_app.js?1458503735"],
4
- "api": ["/modules/compiler_build_api.js?1458503735"],
5
- "settings": ["/modules/compiler_build_settings.js?1458503735"]
6
- };