with_embedded_assets 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/.gitignore +17 -0
- data/.yardopts +1 -0
- data/CHANGELOG +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +621 -0
- data/LICENSE/embed-assets-rails +23 -0
- data/README.md +125 -0
- data/Rakefile +11 -0
- data/lib/with_embedded_assets.rb +25 -0
- data/lib/with_embedded_assets/mixin.rb +21 -0
- data/lib/with_embedded_assets/processor.rb +84 -0
- data/lib/with_embedded_assets/railtie.rb +19 -0
- data/lib/with_embedded_assets/version.rb +4 -0
- data/lib/with_embedded_assets/view_helpers.rb +47 -0
- data/test/fixtures/images/ruby.jpg +0 -0
- data/test/fixtures/images/ruby.jpg.license +10 -0
- data/test/fixtures/javascripts/another_test.js +1 -0
- data/test/fixtures/javascripts/test.js +3 -0
- data/test/fixtures/stylesheets/simple.css +3 -0
- data/test/fixtures/stylesheets/test.css +3 -0
- data/test/fixtures/stylesheets/test_embedded.css +3 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/main_module_test.rb +19 -0
- data/test/unit/mixin_test.rb +31 -0
- data/test/unit/sprockets_processor_test.rb +21 -0
- data/test/unit/view_helpers_test.rb +73 -0
- data/with_embedded_assets.gemspec +23 -0
- metadata +107 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__)+ '/../test_helper')
|
|
2
|
+
|
|
3
|
+
class MixinTest < ActiveSupport::TestCase
|
|
4
|
+
include WithEmbeddedAssets::Mixin
|
|
5
|
+
|
|
6
|
+
def teardown
|
|
7
|
+
WithEmbeddedAssets.enabled = false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "embedding assets with helper method" do
|
|
11
|
+
WithEmbeddedAssets.enabled = false
|
|
12
|
+
expected_css = File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read }
|
|
13
|
+
result_css = nil
|
|
14
|
+
with_embedded_assets do
|
|
15
|
+
result_css = WithEmbeddedAssets::Processor.new("#{FIXTURE_PATH}/stylesheets/test.css").render
|
|
16
|
+
end
|
|
17
|
+
assert_equal expected_css, result_css
|
|
18
|
+
assert !WithEmbeddedAssets.enabled?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "embedding assets with helper method keeps original state" do
|
|
22
|
+
WithEmbeddedAssets.enabled = true
|
|
23
|
+
expected_css = File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read }
|
|
24
|
+
result_css = nil
|
|
25
|
+
with_embedded_assets do
|
|
26
|
+
result_css = WithEmbeddedAssets::Processor.new("#{FIXTURE_PATH}/stylesheets/test.css").render
|
|
27
|
+
end
|
|
28
|
+
assert_equal expected_css, result_css
|
|
29
|
+
assert WithEmbeddedAssets.enabled?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__)+ '/../test_helper')
|
|
2
|
+
|
|
3
|
+
class SprocketsProcessorTest < ActiveSupport::TestCase
|
|
4
|
+
def teardown
|
|
5
|
+
WithEmbeddedAssets.enabled = false
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "embedding assets" do
|
|
9
|
+
WithEmbeddedAssets.enabled = true
|
|
10
|
+
expected_css = File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read }
|
|
11
|
+
result_css = WithEmbeddedAssets::Processor.new("#{FIXTURE_PATH}/stylesheets/test.css").render
|
|
12
|
+
assert_equal expected_css, result_css
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "embedding assets disabled" do
|
|
16
|
+
WithEmbeddedAssets.enabled = false
|
|
17
|
+
expected_css = File.open("#{FIXTURE_PATH}/stylesheets/test.css", 'r') {|f| f.read }
|
|
18
|
+
result_css = WithEmbeddedAssets::Processor.new("#{FIXTURE_PATH}/stylesheets/test.css").render
|
|
19
|
+
assert_equal expected_css, result_css
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__)+ '/../test_helper')
|
|
2
|
+
|
|
3
|
+
class ViewHelpersTest < ActionView::TestCase
|
|
4
|
+
include WithEmbeddedAssets::ViewHelpers
|
|
5
|
+
|
|
6
|
+
def teardown
|
|
7
|
+
WithEmbeddedAssets.enabled = false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "javascript_include_tag with embedding enabled" do
|
|
11
|
+
WithEmbeddedAssets.enabled = true
|
|
12
|
+
expected_result = "<script type=\"text/javascript\">" +
|
|
13
|
+
File.open("#{FIXTURE_PATH}/javascripts/test.js", 'r') {|f| f.read } +
|
|
14
|
+
";\n</script>"
|
|
15
|
+
assert_equal expected_result, javascript_include_tag(:test)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
test "javascript_include_tag with embedding enabled passing parameters" do
|
|
19
|
+
WithEmbeddedAssets.enabled = true
|
|
20
|
+
expected_result = "<script data-test=\"foobar\" type=\"text/javascript\">" +
|
|
21
|
+
File.open("#{FIXTURE_PATH}/javascripts/test.js", 'r') {|f| f.read } +
|
|
22
|
+
";\n</script>"
|
|
23
|
+
assert_equal expected_result, javascript_include_tag(:test, :"data-test" => "foobar")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test "javascript_include_tag with multiple assets and embedding enabled" do
|
|
27
|
+
WithEmbeddedAssets.enabled = true
|
|
28
|
+
expected_result = "<script type=\"text/javascript\">" +
|
|
29
|
+
File.open("#{FIXTURE_PATH}/javascripts/test.js", 'r') {|f| f.read } +
|
|
30
|
+
";\n\n" +
|
|
31
|
+
File.open("#{FIXTURE_PATH}/javascripts/another_test.js", 'r') {|f| f.read } +
|
|
32
|
+
"</script>"
|
|
33
|
+
assert_equal expected_result, javascript_include_tag(:test, :another_test)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
test "javascript_include_tag with embedding disabled" do
|
|
37
|
+
WithEmbeddedAssets.enabled = false
|
|
38
|
+
expected_result = "<script src=\"/javascripts/test.js\" type=\"text/javascript\"></script>"
|
|
39
|
+
assert_equal expected_result, javascript_include_tag("test")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "stylesheet_link_tag with embedding enabled" do
|
|
43
|
+
WithEmbeddedAssets.enabled = true
|
|
44
|
+
expected_result = "<style media=\"screen\" type=\"text/css\">" +
|
|
45
|
+
File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read } +
|
|
46
|
+
"</style>"
|
|
47
|
+
assert_equal expected_result, stylesheet_link_tag(:test)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
test "stylesheet_link_tag with embedding enabled passing parameters" do
|
|
51
|
+
WithEmbeddedAssets.enabled = true
|
|
52
|
+
expected_result = "<style media=\"print\" type=\"text/css\">" +
|
|
53
|
+
File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read } +
|
|
54
|
+
"</style>"
|
|
55
|
+
assert_equal expected_result, stylesheet_link_tag(:test, :media => "print")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test "stylesheet_link_tag with multiple assets and embedding enabled" do
|
|
59
|
+
WithEmbeddedAssets.enabled = true
|
|
60
|
+
expected_result = "<style media=\"screen\" type=\"text/css\">" +
|
|
61
|
+
File.open("#{FIXTURE_PATH}/stylesheets/test_embedded.css", 'r') {|f| f.read } +
|
|
62
|
+
"\n" +
|
|
63
|
+
File.open("#{FIXTURE_PATH}/stylesheets/simple.css", 'r') {|f| f.read } +
|
|
64
|
+
"</style>"
|
|
65
|
+
assert_equal expected_result, stylesheet_link_tag(:test, :simple)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
test "stylesheet_link_tag with embedding disabled" do
|
|
69
|
+
WithEmbeddedAssets.enabled = false
|
|
70
|
+
expected_result = "<link href=\"/stylesheets/test.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
|
71
|
+
assert_equal expected_result, stylesheet_link_tag("test")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'with_embedded_assets/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "with_embedded_assets"
|
|
8
|
+
gem.version = WithEmbeddedAssets::VERSION
|
|
9
|
+
gem.authors = ["O.S. Systems Softwares LTDA."]
|
|
10
|
+
gem.email = ["contato@ossystems.com.br"]
|
|
11
|
+
gem.description = %q{Embeds assets from Rails directly into HTML}
|
|
12
|
+
gem.summary = <<-SUMMARY
|
|
13
|
+
This gem changes the behaviour of the Ruby on Rails asset pipeline to
|
|
14
|
+
directly embedding CSS, JS and images files to the generated HTML.
|
|
15
|
+
SUMMARY
|
|
16
|
+
gem.homepage = "https://github.com/OSSystems/with_embedded_assets"
|
|
17
|
+
|
|
18
|
+
gem.files = `git ls-files`.split($/)
|
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test)/})
|
|
20
|
+
gem.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
gem.add_dependency 'rails', '~> 3.2'
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: with_embedded_assets
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- O.S. Systems Softwares LTDA.
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rails
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '3.2'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '3.2'
|
|
30
|
+
description: Embeds assets from Rails directly into HTML
|
|
31
|
+
email:
|
|
32
|
+
- contato@ossystems.com.br
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- .gitignore
|
|
38
|
+
- .yardopts
|
|
39
|
+
- CHANGELOG
|
|
40
|
+
- Gemfile
|
|
41
|
+
- LICENSE.txt
|
|
42
|
+
- LICENSE/embed-assets-rails
|
|
43
|
+
- README.md
|
|
44
|
+
- Rakefile
|
|
45
|
+
- lib/with_embedded_assets.rb
|
|
46
|
+
- lib/with_embedded_assets/mixin.rb
|
|
47
|
+
- lib/with_embedded_assets/processor.rb
|
|
48
|
+
- lib/with_embedded_assets/railtie.rb
|
|
49
|
+
- lib/with_embedded_assets/version.rb
|
|
50
|
+
- lib/with_embedded_assets/view_helpers.rb
|
|
51
|
+
- test/fixtures/images/ruby.jpg
|
|
52
|
+
- test/fixtures/images/ruby.jpg.license
|
|
53
|
+
- test/fixtures/javascripts/another_test.js
|
|
54
|
+
- test/fixtures/javascripts/test.js
|
|
55
|
+
- test/fixtures/stylesheets/simple.css
|
|
56
|
+
- test/fixtures/stylesheets/test.css
|
|
57
|
+
- test/fixtures/stylesheets/test_embedded.css
|
|
58
|
+
- test/test_helper.rb
|
|
59
|
+
- test/unit/main_module_test.rb
|
|
60
|
+
- test/unit/mixin_test.rb
|
|
61
|
+
- test/unit/sprockets_processor_test.rb
|
|
62
|
+
- test/unit/view_helpers_test.rb
|
|
63
|
+
- with_embedded_assets.gemspec
|
|
64
|
+
homepage: https://github.com/OSSystems/with_embedded_assets
|
|
65
|
+
licenses: []
|
|
66
|
+
post_install_message:
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
none: false
|
|
72
|
+
requirements:
|
|
73
|
+
- - ! '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
segments:
|
|
77
|
+
- 0
|
|
78
|
+
hash: -469914585714644634
|
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
|
+
none: false
|
|
81
|
+
requirements:
|
|
82
|
+
- - ! '>='
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '0'
|
|
85
|
+
segments:
|
|
86
|
+
- 0
|
|
87
|
+
hash: -469914585714644634
|
|
88
|
+
requirements: []
|
|
89
|
+
rubyforge_project:
|
|
90
|
+
rubygems_version: 1.8.24
|
|
91
|
+
signing_key:
|
|
92
|
+
specification_version: 3
|
|
93
|
+
summary: This gem changes the behaviour of the Ruby on Rails asset pipeline to directly
|
|
94
|
+
embedding CSS, JS and images files to the generated HTML.
|
|
95
|
+
test_files:
|
|
96
|
+
- test/fixtures/images/ruby.jpg
|
|
97
|
+
- test/fixtures/images/ruby.jpg.license
|
|
98
|
+
- test/fixtures/javascripts/another_test.js
|
|
99
|
+
- test/fixtures/javascripts/test.js
|
|
100
|
+
- test/fixtures/stylesheets/simple.css
|
|
101
|
+
- test/fixtures/stylesheets/test.css
|
|
102
|
+
- test/fixtures/stylesheets/test_embedded.css
|
|
103
|
+
- test/test_helper.rb
|
|
104
|
+
- test/unit/main_module_test.rb
|
|
105
|
+
- test/unit/mixin_test.rb
|
|
106
|
+
- test/unit/sprockets_processor_test.rb
|
|
107
|
+
- test/unit/view_helpers_test.rb
|