eco_compress 0.0.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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +21 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +37 -0
  7. data/Rakefile +15 -0
  8. data/eco_compress.gemspec +26 -0
  9. data/lib/eco_compress/eco.rb +16 -0
  10. data/lib/eco_compress/version.rb +3 -0
  11. data/lib/eco_compress.rb +5 -0
  12. data/spec/eco_compress/eco_compile_spec.rb +16 -0
  13. data/spec/eco_compress/eco_render_spec.rb +57 -0
  14. data/spec/fixtures/capture.eco +10 -0
  15. data/spec/fixtures/capture.min.js +67 -0
  16. data/spec/fixtures/capture.min.out +1 -0
  17. data/spec/fixtures/capture.orig.js +67 -0
  18. data/spec/fixtures/capture.orig.out +9 -0
  19. data/spec/fixtures/hello.eco +2 -0
  20. data/spec/fixtures/hello.js +55 -0
  21. data/spec/fixtures/hello.min.js +55 -0
  22. data/spec/fixtures/hello.min.out +1 -0
  23. data/spec/fixtures/hello.orig.out +2 -0
  24. data/spec/fixtures/helpers.eco +6 -0
  25. data/spec/fixtures/helpers.min.js +79 -0
  26. data/spec/fixtures/helpers.orig.js +79 -0
  27. data/spec/fixtures/projects.eco +8 -0
  28. data/spec/fixtures/projects.min.js +65 -0
  29. data/spec/fixtures/projects.min.out.1 +1 -0
  30. data/spec/fixtures/projects.min.out.2 +1 -0
  31. data/spec/fixtures/projects.orig.js +65 -0
  32. data/spec/fixtures/projects.orig.out.1 +2 -0
  33. data/spec/fixtures/projects.orig.out.2 +5 -0
  34. data/spec/fixtures/with-comment.eco +3 -0
  35. data/spec/fixtures/with-comment.min.js +47 -0
  36. data/spec/fixtures/with-comment.min.out +1 -0
  37. data/spec/fixtures/with-comment.orig.js +47 -0
  38. data/spec/fixtures/with-comment.orig.out +3 -0
  39. data/spec/spec_helper.rb +20 -0
  40. metadata +153 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b88a13985293a493b7480c0c686f1b1c14b1b8ce
4
+ data.tar.gz: 06bd3be3fbc43ccb116bd6e512dd6f128e19ca5b
5
+ SHA512:
6
+ metadata.gz: 718a6b9552556493b3b24f382c3a62839cb347792dc182c4480a4840b5dd7bf7558a781b4159fdb6a85d1aeb71aa8cbf4bd6bea2a60afa075c00d891245c4fa6
7
+ data.tar.gz: 011bec893433f5508c3bb67296520dd3fd6c14f2a791e41e810ccea2470214d2c116d99351a24542053dc65f0d085b268e75c8d7183970a9ba146e91831283d3
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - rbx-18mode
6
+ - rbx-19mode
7
+ - ruby-head
8
+ - 1.8.7
9
+ - 2.0.0
10
+ - jruby-18mode
11
+ - jruby-19mode
12
+ - jruby-head
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: jruby-head
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "yard"
5
+ end
6
+
7
+ group :development, :test do
8
+ gem "guard"
9
+ gem "guard-rspec"
10
+ gem "simplecov"
11
+
12
+ if RUBY_PLATFORM =~ /darwin/
13
+ gem "ruby_gntp"
14
+ gem "rb-fsevent"
15
+ end
16
+ if RUBY_PLATFORM =~ /linux/
17
+ gem "libnotify"
18
+ gem "rb-inotify"
19
+ end
20
+ end
21
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) Tatsuo Kaniwa
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # EcoCompress
2
+
3
+ The content of JST template is out of JS compressor's work. EcoCompress overrides Eco.compile method to minify the Eco's template source itself.
4
+
5
+ To see more detail, see spec dir and compare minified files (e.g. *.min.out, *.min.js) to the original files (e.g. *.orig.out, *.orig.js).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'eco_compress'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install eco_compress
20
+
21
+ ## Usage
22
+
23
+ Add to Gemfile:
24
+
25
+ gem 'eco_compress'
26
+
27
+ Or require it
28
+
29
+ require 'eco_compress'
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ Bundler::GemHelper.install_tasks
6
+ rescue LoadError
7
+ puts 'although not required, bundler is recommened for running the tests'
8
+ end
9
+
10
+ task :default => :spec
11
+
12
+ require 'rspec/core/rake_task'
13
+ RSpec::Core::RakeTask.new do |t|
14
+ t.rspec_opts = ["--color", '--format doc']
15
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eco_compress/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eco_compress"
8
+ spec.version = EcoCompress::VERSION
9
+ spec.authors = ["Tatsuo Kaniwa"]
10
+ spec.email = ["tatsuo@kaniwa.biz"]
11
+ spec.description = %q{Mnify Eco tempalte}
12
+ spec.summary = %q{Mnify Eco tempalte}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "htmlcompressor"
22
+ spec.add_dependency "eco"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "execjs"
26
+ end
@@ -0,0 +1,16 @@
1
+ require "eco" unless defined?(Eco)
2
+ require "htmlcompressor" unless defined?(HtmlCompressor)
3
+
4
+ Eco.class_eval do
5
+ def self.compile(template)
6
+ begin
7
+ template = template.read if template.respond_to?(:read)
8
+ compressor = HtmlCompressor::Compressor.new
9
+ compressed = compressor.compress template
10
+ ::Eco::Source.context.call("eco.precompile", compressed)
11
+ rescue => e
12
+ template = template.read if template.respond_to?(:read)
13
+ ::Eco::Source.context.call("eco.precompile", template)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module EcoCompress
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "eco_compress/version"
2
+ require "eco_compress/eco"
3
+
4
+ module EcoCompress
5
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ describe "Eco.compile" do
4
+
5
+ files = %w(capture hello helpers projects with-comment)
6
+
7
+ files.each do |file|
8
+ describe "#{file}.eco" do
9
+ it "should equals to min.js file" do
10
+ result = Eco.compile File.read("./spec/fixtures/#{file}.eco")
11
+ result.should == File.read("./spec/fixtures/#{file}.min.js")
12
+ end
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+
3
+ describe "Eco.render" do
4
+
5
+ describe "capture.eco" do
6
+ it "should equals to min.out file" do
7
+ option = {
8
+ :items => [
9
+ {:name => "Foo", :price => 1000}
10
+ ]
11
+ }
12
+ result = Eco.render(File.read("./spec/fixtures/capture.eco"), option)
13
+ result.should == File.read("./spec/fixtures/capture.min.out")
14
+ end
15
+ end
16
+
17
+ describe "hello.eco" do
18
+ it "should equals to min.out file" do
19
+ option = {:name => "Sam"}
20
+ result = Eco.render(File.read("./spec/fixtures/hello.eco"), option)
21
+ result.should == File.read("./spec/fixtures/hello.min.out")
22
+ end
23
+ end
24
+
25
+ describe "projects.eco" do
26
+ describe "when projects is empty" do
27
+ it "should equals to min.out.1 file" do
28
+ option = {:projects => []}
29
+ result = Eco.render(File.read("./spec/fixtures/projects.eco"), option)
30
+ result.should == File.read("./spec/fixtures/projects.min.out.1")
31
+ end
32
+ end
33
+ describe "when projects is not empty" do
34
+ it "should equals to min.out.2 file" do
35
+ option = {
36
+ :projects => [
37
+ {
38
+ :url => "http://foo.bar/",
39
+ :name => "Foo",
40
+ :description => "Bar"
41
+ }
42
+ ]
43
+ }
44
+ result = Eco.render(File.read("./spec/fixtures/projects.eco"), option)
45
+ result.should == File.read("./spec/fixtures/projects.min.out.2")
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "with-comment.eco" do
51
+ it "should equals to min.out file" do
52
+ result = Eco.render(File.read("./spec/fixtures/with-comment.eco"))
53
+ result.should == File.read("./spec/fixtures/with-comment.min.out")
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,10 @@
1
+ <% renderItem = (item) -> %>
2
+ <div class="item">
3
+ <span class="name"><%= item.name %></span>
4
+ <span class="price">$<%= item.price %></span>
5
+ </div>
6
+ <% end %>
7
+
8
+ <% for item in @items: %>
9
+ <%= renderItem item %>
10
+ <% end %>
@@ -0,0 +1,67 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var item, renderItem, _i, _len, _ref;
41
+
42
+ renderItem = function(item) {
43
+ return __capture(function() {
44
+ __out.push(' <div class="item"> <span class="name">');
45
+ __out.push(__sanitize(item.name));
46
+ __out.push('</span> <span class="price">$');
47
+ __out.push(__sanitize(item.price));
48
+ return __out.push('</span> </div> ');
49
+ });
50
+ };
51
+
52
+ __out.push(' ');
53
+
54
+ _ref = this.items;
55
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
56
+ item = _ref[_i];
57
+ __out.push(' ');
58
+ __out.push(__sanitize(renderItem(item)));
59
+ __out.push(' ');
60
+ }
61
+
62
+ }).call(this);
63
+
64
+ }).call(__obj);
65
+ __obj.safe = __objSafe, __obj.escape = __escape;
66
+ return __out.join('');
67
+ }
@@ -0,0 +1 @@
1
+ <div class="item"> <span class="name">Foo</span> <span class="price">$1000</span> </div>
@@ -0,0 +1,67 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var item, renderItem, _i, _len, _ref;
41
+
42
+ renderItem = function(item) {
43
+ return __capture(function() {
44
+ __out.push('\n <div class="item">\n <span class="name">');
45
+ __out.push(__sanitize(item.name));
46
+ __out.push('</span>\n <span class="price">$');
47
+ __out.push(__sanitize(item.price));
48
+ return __out.push('</span>\n </div>\n');
49
+ });
50
+ };
51
+
52
+ __out.push('\n\n');
53
+
54
+ _ref = this.items;
55
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
56
+ item = _ref[_i];
57
+ __out.push('\n ');
58
+ __out.push(__sanitize(renderItem(item)));
59
+ __out.push('\n');
60
+ }
61
+
62
+ }).call(this);
63
+
64
+ }).call(__obj);
65
+ __obj.safe = __objSafe, __obj.escape = __escape;
66
+ return __out.join('');
67
+ }
@@ -0,0 +1,9 @@
1
+
2
+
3
+
4
+
5
+ <div class="item">
6
+ <span class="name">Foo</span>
7
+ <span class="price">$1000</span>
8
+ </div>
9
+
@@ -0,0 +1,2 @@
1
+ Hello, <%= @name %>.
2
+ I'M SHOUTING AT YOU, <%= @name.toUpperCase() %>!
@@ -0,0 +1,55 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ __out.push('Hello, ');
41
+
42
+ __out.push(__sanitize(this.name));
43
+
44
+ __out.push('.\nI\'M SHOUTING AT YOU, ');
45
+
46
+ __out.push(__sanitize(this.name.toUpperCase()));
47
+
48
+ __out.push('!');
49
+
50
+ }).call(this);
51
+
52
+ }).call(__obj);
53
+ __obj.safe = __objSafe, __obj.escape = __escape;
54
+ return __out.join('');
55
+ }
@@ -0,0 +1,55 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ __out.push('Hello, ');
41
+
42
+ __out.push(__sanitize(this.name));
43
+
44
+ __out.push('. I\'M SHOUTING AT YOU, ');
45
+
46
+ __out.push(__sanitize(this.name.toUpperCase()));
47
+
48
+ __out.push('!');
49
+
50
+ }).call(this);
51
+
52
+ }).call(__obj);
53
+ __obj.safe = __objSafe, __obj.escape = __escape;
54
+ return __out.join('');
55
+ }
@@ -0,0 +1 @@
1
+ Hello, Sam. I'M SHOUTING AT YOU, SAM!
@@ -0,0 +1,2 @@
1
+ Hello, Sam.
2
+ I'M SHOUTING AT YOU, SAM!
@@ -0,0 +1,6 @@
1
+ <% for item in @items: %>
2
+ <%= @contentTag "div", class: "item", => %>
3
+ <%= @contentTag "span", class: "price", -> %>$<%= item.price %><% end %>
4
+ <%= @contentTag "span", class: "name", -> %><%= item.name %><% end %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1,79 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var item, _i, _len, _ref,
41
+ _this = this;
42
+
43
+ _ref = this.items;
44
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
45
+ item = _ref[_i];
46
+ __out.push(' ');
47
+ __out.push(__sanitize(this.contentTag("div", {
48
+ "class": "item"
49
+ }, function() {
50
+ return __capture(function() {
51
+ __out.push(' ');
52
+ __out.push(__sanitize(_this.contentTag("span", {
53
+ "class": "price"
54
+ }, function() {
55
+ return __capture(function() {
56
+ __out.push('$');
57
+ return __out.push(__sanitize(item.price));
58
+ });
59
+ })));
60
+ __out.push(' ');
61
+ __out.push(__sanitize(_this.contentTag("span", {
62
+ "class": "name"
63
+ }, function() {
64
+ return __capture(function() {
65
+ return __out.push(__sanitize(item.name));
66
+ });
67
+ })));
68
+ return __out.push(' ');
69
+ });
70
+ })));
71
+ __out.push(' ');
72
+ }
73
+
74
+ }).call(this);
75
+
76
+ }).call(__obj);
77
+ __obj.safe = __objSafe, __obj.escape = __escape;
78
+ return __out.join('');
79
+ }
@@ -0,0 +1,79 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var item, _i, _len, _ref,
41
+ _this = this;
42
+
43
+ _ref = this.items;
44
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
45
+ item = _ref[_i];
46
+ __out.push('\n ');
47
+ __out.push(__sanitize(this.contentTag("div", {
48
+ "class": "item"
49
+ }, function() {
50
+ return __capture(function() {
51
+ __out.push('\n ');
52
+ __out.push(__sanitize(_this.contentTag("span", {
53
+ "class": "price"
54
+ }, function() {
55
+ return __capture(function() {
56
+ __out.push('$');
57
+ return __out.push(__sanitize(item.price));
58
+ });
59
+ })));
60
+ __out.push('\n ');
61
+ __out.push(__sanitize(_this.contentTag("span", {
62
+ "class": "name"
63
+ }, function() {
64
+ return __capture(function() {
65
+ return __out.push(__sanitize(item.name));
66
+ });
67
+ })));
68
+ return __out.push('\n ');
69
+ });
70
+ })));
71
+ __out.push('\n');
72
+ }
73
+
74
+ }).call(this);
75
+
76
+ }).call(__obj);
77
+ __obj.safe = __objSafe, __obj.escape = __escape;
78
+ return __out.join('');
79
+ }
@@ -0,0 +1,8 @@
1
+ <% if @projects.length: %>
2
+ <% for project in @projects: %>
3
+ <a href="<%= project.url %>"><%= project.name %></a>
4
+ <%- project.description %>
5
+ <% end %>
6
+ <% else: %>
7
+ No projects
8
+ <% end %>
@@ -0,0 +1,65 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var project, _i, _len, _ref;
41
+
42
+ if (this.projects.length) {
43
+ __out.push(' ');
44
+ _ref = this.projects;
45
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
46
+ project = _ref[_i];
47
+ __out.push(' <a href="');
48
+ __out.push(__sanitize(project.url));
49
+ __out.push('">');
50
+ __out.push(__sanitize(project.name));
51
+ __out.push('</a> ');
52
+ __out.push(project.description);
53
+ __out.push(' ');
54
+ }
55
+ __out.push(' ');
56
+ } else {
57
+ __out.push(' No projects ');
58
+ }
59
+
60
+ }).call(this);
61
+
62
+ }).call(__obj);
63
+ __obj.safe = __objSafe, __obj.escape = __escape;
64
+ return __out.join('');
65
+ }
@@ -0,0 +1 @@
1
+ No projects
@@ -0,0 +1 @@
1
+ <a href="http://foo.bar/">Foo</a> Bar
@@ -0,0 +1,65 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ var project, _i, _len, _ref;
41
+
42
+ if (this.projects.length) {
43
+ __out.push('\n ');
44
+ _ref = this.projects;
45
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
46
+ project = _ref[_i];
47
+ __out.push('\n <a href="');
48
+ __out.push(__sanitize(project.url));
49
+ __out.push('">');
50
+ __out.push(__sanitize(project.name));
51
+ __out.push('</a>\n ');
52
+ __out.push(project.description);
53
+ __out.push('\n ');
54
+ }
55
+ __out.push('\n');
56
+ } else {
57
+ __out.push('\n No projects\n');
58
+ }
59
+
60
+ }).call(this);
61
+
62
+ }).call(__obj);
63
+ __obj.safe = __objSafe, __obj.escape = __escape;
64
+ return __out.join('');
65
+ }
@@ -0,0 +1,2 @@
1
+
2
+ No projects
@@ -0,0 +1,5 @@
1
+
2
+
3
+ <a href="http://foo.bar/">Foo</a>
4
+ Bar
5
+
@@ -0,0 +1,3 @@
1
+ <!--This is a comment. Comments are not displayed in the browser-->
2
+
3
+ <p>This is a paragraph.</p>
@@ -0,0 +1,47 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ __out.push('<p>This is a paragraph.</p>');
41
+
42
+ }).call(this);
43
+
44
+ }).call(__obj);
45
+ __obj.safe = __objSafe, __obj.escape = __escape;
46
+ return __out.join('');
47
+ }
@@ -0,0 +1 @@
1
+ <p>This is a paragraph.</p>
@@ -0,0 +1,47 @@
1
+ function(__obj) {
2
+ if (!__obj) __obj = {};
3
+ var __out = [], __capture = function(callback) {
4
+ var out = __out, result;
5
+ __out = [];
6
+ callback.call(this);
7
+ result = __out.join('');
8
+ __out = out;
9
+ return __safe(result);
10
+ }, __sanitize = function(value) {
11
+ if (value && value.ecoSafe) {
12
+ return value;
13
+ } else if (typeof value !== 'undefined' && value != null) {
14
+ return __escape(value);
15
+ } else {
16
+ return '';
17
+ }
18
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
19
+ __safe = __obj.safe = function(value) {
20
+ if (value && value.ecoSafe) {
21
+ return value;
22
+ } else {
23
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
24
+ var result = new String(value);
25
+ result.ecoSafe = true;
26
+ return result;
27
+ }
28
+ };
29
+ if (!__escape) {
30
+ __escape = __obj.escape = function(value) {
31
+ return ('' + value)
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;')
35
+ .replace(/"/g, '&quot;');
36
+ };
37
+ }
38
+ (function() {
39
+ (function() {
40
+ __out.push('<!--This is a comment. Comments are not displayed in the browser-->\n\n<p>This is a paragraph.</p>');
41
+
42
+ }).call(this);
43
+
44
+ }).call(__obj);
45
+ __obj.safe = __objSafe, __obj.escape = __escape;
46
+ return __out.join('');
47
+ }
@@ -0,0 +1,3 @@
1
+ <!--This is a comment. Comments are not displayed in the browser-->
2
+
3
+ <p>This is a paragraph.</p>
@@ -0,0 +1,20 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "Although not required, bundler is recommended for running the tests."
5
+ end
6
+ # load the library
7
+ require "simplecov"
8
+ SimpleCov.start :test_frameworks do
9
+ add_filter "/vendor/bundle/"
10
+ end
11
+ require "rspec"
12
+ require "eco"
13
+ require "eco_compress"
14
+
15
+ RSpec.configure do |config|
16
+ config.mock_with :rspec
17
+ config.treat_symbols_as_metadata_keys_with_true_values = true
18
+ config.filter_run :focus => true
19
+ config.run_all_when_everything_filtered = true
20
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eco_compress
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tatsuo Kaniwa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: htmlcompressor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: eco
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: execjs
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Mnify Eco tempalte
84
+ email:
85
+ - tatsuo@kaniwa.biz
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - eco_compress.gemspec
97
+ - lib/eco_compress.rb
98
+ - lib/eco_compress/eco.rb
99
+ - lib/eco_compress/version.rb
100
+ - spec/eco_compress/eco_compile_spec.rb
101
+ - spec/eco_compress/eco_render_spec.rb
102
+ - spec/fixtures/capture.eco
103
+ - spec/fixtures/capture.min.js
104
+ - spec/fixtures/capture.min.out
105
+ - spec/fixtures/capture.orig.js
106
+ - spec/fixtures/capture.orig.out
107
+ - spec/fixtures/hello.eco
108
+ - spec/fixtures/hello.js
109
+ - spec/fixtures/hello.min.js
110
+ - spec/fixtures/hello.min.out
111
+ - spec/fixtures/hello.orig.out
112
+ - spec/fixtures/helpers.eco
113
+ - spec/fixtures/helpers.min.js
114
+ - spec/fixtures/helpers.orig.js
115
+ - spec/fixtures/projects.eco
116
+ - spec/fixtures/projects.min.js
117
+ - spec/fixtures/projects.min.out.1
118
+ - spec/fixtures/projects.min.out.2
119
+ - spec/fixtures/projects.orig.js
120
+ - spec/fixtures/projects.orig.out.1
121
+ - spec/fixtures/projects.orig.out.2
122
+ - spec/fixtures/with-comment.eco
123
+ - spec/fixtures/with-comment.min.js
124
+ - spec/fixtures/with-comment.min.out
125
+ - spec/fixtures/with-comment.orig.js
126
+ - spec/fixtures/with-comment.orig.out
127
+ - spec/spec_helper.rb
128
+ homepage: ''
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.0.3
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Mnify Eco tempalte
152
+ test_files: []
153
+ has_rdoc: