eldr-assets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e12dfb210e7bfbef31b22d66f049e7686703be0a
4
+ data.tar.gz: 2bb13a7cbfc08fc3858076d34e6fb0788948f5f1
5
+ SHA512:
6
+ metadata.gz: 9c7f41d7a502cffa8ba660eaab816baef452fa66635f7ec43d15da22b7d1ae3bf4a349cd5d9f419da9f619b2918cd3c0e883747efeae482cb58a167ef4434463
7
+ data.tar.gz: 4287abc784aeb8a1f0d9310c99376eb83f1e4a99b8d4e287524bb8d2443cff3a0a40f29262c7a5d67fc7d8d635b4f03673797335829c549d642eafd1708209ea
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --require ./spec/spec_helper
@@ -0,0 +1,22 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/AndOr:
4
+ Enabled: false
5
+
6
+ Metrics/AbcSize:
7
+ Max: 40
8
+
9
+ Metrics/MethodLength:
10
+ Max: 20
11
+
12
+ Metrics/ClassLength:
13
+ Max: 130
14
+
15
+ Metrics/LineLength:
16
+ Max: 120
17
+
18
+ AllCops:
19
+ Exclude:
20
+ - 'spec/**/*'
21
+ - 'Gemfile'
22
+ - 'eldr-assets.gemspec'
@@ -0,0 +1,38 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-01-25 12:16:39 -0800 using RuboCop version 0.28.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Lint/UselessAssignment:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 7
15
+
16
+ # Offense count: 3
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: Exclude.
22
+ Style/FileName:
23
+ Enabled: false
24
+
25
+ # Offense count: 1
26
+ # Cop supports --auto-correct.
27
+ Style/MethodCallParentheses:
28
+ Enabled: false
29
+
30
+ # Offense count: 5
31
+ # Cop supports --auto-correct.
32
+ Style/RedundantSelf:
33
+ Enabled: false
34
+
35
+ # Offense count: 2
36
+ # Cop supports --auto-correct.
37
+ Style/SpaceAfterComma:
38
+ Enabled: false
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eldr-assets (0.0.1)
5
+ eldr-rendering (~> 0.0.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (4.2.0)
11
+ i18n (~> 0.7)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ ast (2.0.0)
17
+ astrolabe (1.3.0)
18
+ parser (>= 2.2.0.pre.3, < 3.0)
19
+ diff-lcs (1.2.5)
20
+ eldr (0.0.3)
21
+ fast_blank (= 0.0.2)
22
+ mustermann (= 0.4.0)
23
+ rack (~> 1.5)
24
+ eldr-rendering (0.0.1)
25
+ activesupport (~> 4.2)
26
+ eldr (~> 0.0)
27
+ tilt (~> 1.4)
28
+ fast_blank (0.0.2)
29
+ i18n (0.7.0)
30
+ json (1.8.2)
31
+ mini_portile (0.6.2)
32
+ minitest (5.5.1)
33
+ mustermann (0.4.0)
34
+ tool (~> 0.2)
35
+ nokogiri (1.6.5)
36
+ mini_portile (~> 0.6.0)
37
+ parser (2.2.0.2)
38
+ ast (>= 1.1, < 3.0)
39
+ powerpack (0.0.9)
40
+ rack (1.6.0)
41
+ rack-test (0.6.3)
42
+ rack (>= 1.0)
43
+ rainbow (2.0.0)
44
+ rake (10.4.2)
45
+ rspec (3.1.0)
46
+ rspec-core (~> 3.1.0)
47
+ rspec-expectations (~> 3.1.0)
48
+ rspec-mocks (~> 3.1.0)
49
+ rspec-core (3.1.7)
50
+ rspec-support (~> 3.1.0)
51
+ rspec-expectations (3.1.2)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.1.0)
54
+ rspec-html-matchers (0.6.1)
55
+ nokogiri (~> 1)
56
+ rspec (~> 3)
57
+ rspec-mocks (3.1.3)
58
+ rspec-support (~> 3.1.0)
59
+ rspec-support (3.1.2)
60
+ rubocop (0.28.0)
61
+ astrolabe (~> 1.3)
62
+ parser (>= 2.2.0.pre.7, < 3.0)
63
+ powerpack (~> 0.0.6)
64
+ rainbow (>= 1.99.1, < 3.0)
65
+ ruby-progressbar (~> 1.4)
66
+ ruby-progressbar (1.7.1)
67
+ slim (3.0.1)
68
+ temple (~> 0.7.3)
69
+ tilt (>= 1.3.3, < 2.1)
70
+ temple (0.7.5)
71
+ thread_safe (0.3.4)
72
+ tilt (1.4.1)
73
+ tool (0.2.3)
74
+ tzinfo (1.2.2)
75
+ thread_safe (~> 0.1)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ bundler (~> 1.7)
82
+ eldr-assets!
83
+ rack-test (= 0.6.3)
84
+ rake (= 10.4.2)
85
+ rspec (= 3.1.0)
86
+ rspec-html-matchers (= 0.6.1)
87
+ rubocop (= 0.28.0)
88
+ slim (= 3.0.1)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 K-2052
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.
@@ -0,0 +1,65 @@
1
+ # Eldr::Assets [![Build Status](https://travis-ci.org/eldr-rb/eldr-assets.svg)](https://travis-ci.org/eldr-rb/eldr-assets) [![Code Climate](https://codeclimate.com/github/eldr-rb/eldr-assets/badges/gpa.svg)](https://codeclimate.com/github/eldr-rb/eldr-assets) [![Coverage Status](https://coveralls.io/repos/eldr-rb/eldr-assets/badge.svg?branch=master)](https://coveralls.io/r/eldr-rb/eldr-assets?branch=master) [![Dependency Status](https://gemnasium.com/eldr-rb/eldr-assets.svg)](https://gemnasium.com/eldr-rb/eldr-assets) [![Inline docs](https://inch-ci.org/github/eldr-rb/eldr-assets.svg?branch=master)](http://inch-ci.org/github/eldr-rb/eldr-assets) [![Gratipay](https://img.shields.io/gratipay/k2052.svg)](https://www.gratipay.com/k2052)
2
+
3
+ Asset tag helpers for [Eldr](https://github.com/eldr-rb/eldr) and Rack Apps
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'eldr-assets'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install eldr-assets
20
+
21
+ ## Usage
22
+
23
+ Include it, call `render()`, and then call the helpers in your template:
24
+
25
+ App:
26
+
27
+ ```ruby
28
+ class App < Eldr::App
29
+ include Eldr::Assets
30
+ set :view_dir, File.join(__dir__, 'views')
31
+ set :assets_path, File.join(__dir__, 'assets')
32
+
33
+ get '/' do
34
+ render 'index'
35
+ end
36
+ end
37
+ ```
38
+
39
+ Then in your view do:
40
+
41
+ ```ruby
42
+ html
43
+ head
44
+ == js 'app'
45
+ == css3 'app'
46
+ ```
47
+
48
+ See [examples/app.ru](https://github.com/eldr-rb/eldr-assets/tree/master/examples/app.ru) for an example app.
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork. it
53
+ 2. Create. your feature branch (git checkout -b cat-evolver)
54
+ 3. Commit. your changes (git commit -am 'Add Cat Evolution')
55
+ 4. Test. your changes (always be testing)
56
+ 5. Push. to the branch (git push origin cat-evolver)
57
+ 6. Pull. Request. (for extra points include funny gif and or pun in comments)
58
+
59
+ To remember this you can use the easy to remember and totally not tongue-in-check initialism: FCCTPP.
60
+
61
+ I don't want any of these steps to scare you off. If you don't know how to do something or are struggle getting it to work feel free to create a pull request or issue anyway. I'll be happy to help you get your contributions up to code and into the repo!
62
+
63
+ ## License
64
+
65
+ Licensed under MIT by K-2052.
@@ -0,0 +1,9 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'rubocop/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ RuboCop::RakeTask.new(:rubocop)
6
+
7
+ task :default do
8
+ Rake::Task['spec'].execute
9
+ end
data/TODOS ADDED
@@ -0,0 +1,2 @@
1
+ - [ ] rubocop todos
2
+ - [ ] Rdocs
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eldr/assets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'eldr-assets'
8
+ spec.version = Eldr::Assets::VERSION
9
+ spec.authors = ['K-2052']
10
+ spec.email = ['k@2052.me']
11
+ spec.summary = %q{Asset tag helpers for Eldr apps and Rack Apps}
12
+ spec.homepage = 'https://github.com/eldr-rb/eldr-assets'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'eldr-rendering', '~> 0.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '10.4.2'
24
+ spec.add_development_dependency 'rspec', '3.1.0'
25
+ spec.add_development_dependency 'rubocop', '0.28.0'
26
+ spec.add_development_dependency 'rack-test', '0.6.3'
27
+ spec.add_development_dependency 'slim', '3.0.1'
28
+ spec.add_development_dependency 'rspec-html-matchers', '0.6.1'
29
+ end
@@ -0,0 +1,15 @@
1
+ require 'eldr'
2
+ require_relative '../lib/eldr/assets'
3
+ require 'slim'
4
+
5
+ class App < Eldr::App
6
+ include Eldr::Assets
7
+ set :views_dir, File.join(__dir__, 'views')
8
+ set :assets_path, File.join(__dir__, 'assets')
9
+
10
+ get '/' do
11
+ render 'index'
12
+ end
13
+ end
14
+
15
+ run App
@@ -0,0 +1,4 @@
1
+ html
2
+ head
3
+ == js 'app'
4
+ == css 'app'
@@ -0,0 +1 @@
1
+ require_relative 'eldr/assets'
@@ -0,0 +1,12 @@
1
+ require_relative 'assets/helpers'
2
+
3
+ module Eldr
4
+ module Assets
5
+ def self.included(klass)
6
+ klass.include Helpers
7
+ unless klass.instance_methods().include?(:tag)
8
+ klass.include Eldr::Rendering
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,79 @@
1
+ require 'eldr'
2
+ require 'eldr/rendering'
3
+ require 'active_support/core_ext/hash'
4
+
5
+ module Eldr
6
+ module Assets
7
+ module Helpers
8
+ APPEND_ASSET_EXTENSIONS = %w(js css)
9
+ ABSOLUTE_URL_PATTERN = %r{^(https?://)}
10
+
11
+ def css(*sources)
12
+ options = {
13
+ rel: 'stylesheet',
14
+ type: 'text/css'
15
+ }.update(sources.extract_options!.symbolize_keys)
16
+ sources.flatten.inject(ActiveSupport::SafeBuffer.new) do |all,source|
17
+ all << tag(:link, { href: asset_path(:css, source) }.update(options))
18
+ end
19
+ end
20
+
21
+ def js(*sources)
22
+ options = {
23
+ type: 'text/javascript'
24
+ }.update(sources.extract_options!.symbolize_keys)
25
+ sources.flatten.inject(ActiveSupport::SafeBuffer.new) do |all,source|
26
+ all << content_tag(:script, nil, { src: asset_path(:js, source) }.update(options))
27
+ end
28
+ end
29
+
30
+ def asset_path(kind, source = nil)
31
+ kind, source = source, kind if source.nil?
32
+ source = asset_normalize_extension(kind, URI.escape(source.to_s))
33
+
34
+ return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\//
35
+
36
+ source = File.join(asset_folder_name(kind).to_s, source)
37
+ timestamp = asset_timestamp(source)
38
+ result_path = uri_root_path(source)
39
+
40
+ "#{result_path}#{timestamp}"
41
+ end
42
+
43
+ def uri_root_path(*paths)
44
+ root_uri = self.configuration.uri_root
45
+ root_uri ||= ENV['ROOT_URI'] if ENV.include? 'ROOT_URI'
46
+ File.join(ENV['RACK_BASE_URI'].to_s, root_uri || '/', *paths)
47
+ end
48
+
49
+ private
50
+
51
+ def asset_timestamp(file_path)
52
+ return nil if file_path =~ /\?/ || (self.configuration.asset_stamp == false)
53
+
54
+ assets_path = self.configuration.assets_path
55
+ assets_path ||= ENV['ASSETS_PATH']
56
+ assets_path ||= "#{ENV['APP_ROOT']}/assets" if ENV['APP_ROOT']
57
+ assets_path ||= "#{self.configuration.app_root}/assets"
58
+
59
+ asset_file_path = File.join(assets_path, file_path) if assets_path
60
+
61
+ stamp = File.mtime(asset_file_path).to_i if asset_file_path && File.exist?(asset_file_path)
62
+ stamp ||= Time.now.to_i
63
+
64
+ "?#{stamp}"
65
+ end
66
+
67
+ def asset_folder_name(kind)
68
+ asset_folder = self.configuration.send("#{kind}_assets_folder")
69
+ asset_folder ||= kind
70
+ end
71
+
72
+ def asset_normalize_extension(kind, source)
73
+ ignore_extension = !APPEND_ASSET_EXTENSIONS.include?(kind.to_s)
74
+ source << ".#{kind}" unless ignore_extension || source =~ /\.#{kind}/ || source =~ ABSOLUTE_URL_PATTERN
75
+ source
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ module Eldr
2
+ module Assets
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ describe 'ExampleApp' do
2
+ let(:app) do
3
+ path = File.expand_path('../examples/app.ru', File.dirname(__FILE__))
4
+ Rack::Builder.parse_file(path).first
5
+ end
6
+
7
+ let(:rt) do
8
+ Rack::Test::Session.new(app)
9
+ end
10
+
11
+ describe 'GET /' do
12
+ it 'returns a page with a linked css file' do
13
+ time = stop_time_for_test
14
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
15
+ response = rt.get '/'
16
+ html = response.body
17
+ expect(html).to have_tag('link', {:with => expected_options.merge(:href => "/css/app.css?#{time.to_i}")})
18
+ end
19
+
20
+ it 'returns a page with a linked js file' do
21
+ time = stop_time_for_test
22
+ response = rt.get '/'
23
+ html = response.body
24
+ expect(html).to have_tag('script', :with => {:src => "/js/app.js?#{time.to_i}", :type => "text/javascript"})
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,141 @@
1
+ describe Eldr::Assets::Helpers do
2
+ attr_accessor :configuration
3
+
4
+ def configuration
5
+ @configuration ||= Eldr::Configuration.new
6
+ end
7
+
8
+ def config
9
+ configuration
10
+ end
11
+
12
+ describe '#css' do
13
+ it 'displays a stylesheet link item' do
14
+ time = stop_time_for_test
15
+ html = css('style')
16
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
17
+ expect(html).to have_tag('link', {:with => expected_options.merge(:href => "/css/style.css?#{time.to_i}")})
18
+ expect(html.html_safe?).to eq(true)
19
+ end
20
+
21
+ it 'displays a stylesheet link item for long relative path' do
22
+ time = stop_time_for_test
23
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
24
+ html = css('example/demo/style')
25
+ expect(html).to have_tag('link', {:with => expected_options.merge(:href => "/css/example/demo/style.css?#{time.to_i}")})
26
+ end
27
+
28
+ it 'displays a stylesheet link item with absolute path' do
29
+ time = stop_time_for_test
30
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
31
+ html = css('/css/style')
32
+ expect(html).to have_tag('link', {:with => expected_options.merge(:href => "/css/style.css")})
33
+ end
34
+
35
+ it 'displays a stylesheet link item with uri root' do
36
+ configuration.uri_root = "/blog"
37
+
38
+ time = stop_time_for_test
39
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
40
+ html = css('style')
41
+ expect(html).to have_tag('link', {:with => expected_options.merge(:href => "/blog/css/style.css?#{time.to_i}")})
42
+ config.uri_root = nil
43
+ end
44
+
45
+ it 'displays a stylesheet link items' do
46
+ time = stop_time_for_test
47
+ html = css('style', 'layout.css', 'http://google.com/style.css')
48
+ expect(html).to have_tag('link', :with => {:rel => "stylesheet", :type => "text/css"}, :count => 3)
49
+ expect(html).to have_tag('link', :with => {:href => "/css/style.css?#{time.to_i}"})
50
+ expect(html).to have_tag('link', :with => {:href => "/css/layout.css?#{time.to_i}"})
51
+ expect(html).to have_tag('link', :with => {:href => "http://google.com/style.css"})
52
+ expect(html).to eq css(['style', 'layout.css', 'http://google.com/style.css'])
53
+ end
54
+
55
+ it 'does not use a timestamp if stamp setting is false' do
56
+ configuration.asset_stamp = false
57
+ expected_options = { :rel => "stylesheet", :type => "text/css" }
58
+ html = css('style')
59
+ expect(html).to have_tag('link', :with => expected_options.merge(:href => "/css/style.css"))
60
+ configuration.asset_stamp = nil
61
+ end
62
+
63
+ it 'displays a stylesheet link used custom options' do
64
+ html = css('style', :media => 'screen')
65
+ expect(html).to have_tag('link', :with => {:rel => 'stylesheet', :media => 'screen'})
66
+ end
67
+ end
68
+
69
+ describe '#js' do
70
+ it 'displays a javascript item' do
71
+ time = stop_time_for_test
72
+ html = js('application')
73
+ expect(html).to have_tag('script', :with => {:src => "/js/application.js?#{time.to_i}", :type => "text/javascript"})
74
+ expect(html.html_safe?).to eq true
75
+ end
76
+
77
+ it 'responds to js_asset_folder setting' do
78
+ time = stop_time_for_test
79
+ configuration.js_asset_folder = 'js'
80
+ expect('js').to eq asset_folder_name(:js).to_s
81
+ html = js('application')
82
+ expect(html).to have_tag('script', :with => {:src => "/js/application.js?#{time.to_i}", :type => "text/javascript"})
83
+ configuration.js_asset_folder = nil
84
+ end
85
+
86
+ it 'displays a javascript item for long relative path' do
87
+ time = stop_time_for_test
88
+ html = js('example/demo/application')
89
+ expect(html).to have_tag('script', :with => {:src => "/js/example/demo/application.js?#{time.to_i}", :type => "text/javascript"})
90
+ end
91
+
92
+ it 'displays a javascript item for path containing js' do
93
+ time = stop_time_for_test
94
+ html = js 'test/jquery.json'
95
+ expect(html).to have_tag('script', :with => {:src => "/js/test/jquery.json?#{time.to_i}", :type => "text/javascript"})
96
+ end
97
+
98
+ it 'displays a javascript item for path containing period' do
99
+ time = stop_time_for_test
100
+ html = js 'test/jquery.min'
101
+ expect(html).to have_tag('script', :with => {:src => "/js/test/jquery.min.js?#{time.to_i}", :type => "text/javascript"})
102
+ end
103
+
104
+ it 'displays a javascript item with absolute path' do
105
+ time = stop_time_for_test
106
+ html = js('/js/application')
107
+ expect(html).to have_tag('script', :with => {:src => "/js/application.js", :type => "text/javascript"})
108
+ end
109
+
110
+ it 'displays a javascript item with uri root' do
111
+ configuration.uri_root = "/blog"
112
+ time = stop_time_for_test
113
+ html = js('application')
114
+ expect(html).to have_tag('script', :with => {:src => "/blog/js/application.js?#{time.to_i}", :type => "text/javascript"})
115
+ configuration.uri_root = nil
116
+ end
117
+
118
+ it 'does not append extension to absolute paths' do
119
+ time = stop_time_for_test
120
+ html = js('https://maps.googleapis.com/maps/api/js?key=value&sensor=false')
121
+ expect(html).to have_tag('script', :with => {:src => "https://maps.googleapis.com/maps/api/js?key=value&sensor=false"})
122
+ end
123
+
124
+ it 'displays a javascript items' do
125
+ time = stop_time_for_test
126
+ html = js('application', 'base.js', 'http://google.com/lib.js')
127
+ expect(html).to have_tag('script', :with => {:type => "text/javascript"}, :count => 3)
128
+ expect(html).to have_tag('script', :with => {:src => "/js/application.js?#{time.to_i}"})
129
+ expect(html).to have_tag('script', :with => {:src => "/js/base.js?#{time.to_i}"})
130
+ expect(html).to have_tag('script', :with => {:src => "http://google.com/lib.js"})
131
+ expect(html).to eq js(['application', 'base.js', 'http://google.com/lib.js'])
132
+ end
133
+
134
+ it 'does not use a timestamp if stamp setting is false' do
135
+ configuration.asset_stamp = false
136
+ html = js('application')
137
+ expect(html).to have_tag('script', :with => {:src => "/js/application.js", :type => "text/javascript"})
138
+ configuration.asset_stamp = nil
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,20 @@
1
+ require 'rack/test'
2
+ require 'rack'
3
+ require 'rspec-html-matchers'
4
+
5
+ if ENV['COVERALLS_REPO_TOKEN']
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+ end
9
+
10
+ require_relative '../lib/eldr-assets'
11
+
12
+ RSpec.configure do |config|
13
+ config.include Eldr::Assets
14
+
15
+ def stop_time_for_test
16
+ time = Time.now
17
+ allow(Time).to receive(:now).and_return time
18
+ return time
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eldr-assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - K-2052
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: eldr-rendering
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.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.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 10.4.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 10.4.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.28.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.28.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.6.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: slim
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-html-matchers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.6.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.6.1
125
+ description:
126
+ email:
127
+ - k@2052.me
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".rubocop_todo.yml"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE
140
+ - README.md
141
+ - Rakefile
142
+ - TODOS
143
+ - eldr-assets.gemspec
144
+ - examples/app.ru
145
+ - examples/views/index.slim
146
+ - lib/eldr-assets.rb
147
+ - lib/eldr/assets.rb
148
+ - lib/eldr/assets/helpers.rb
149
+ - lib/eldr/assets/version.rb
150
+ - spec/app_spec.rb
151
+ - spec/helpers_spec.rb
152
+ - spec/spec_helper.rb
153
+ homepage: https://github.com/eldr-rb/eldr-assets
154
+ licenses:
155
+ - MIT
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.2.2
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: Asset tag helpers for Eldr apps and Rack Apps
177
+ test_files:
178
+ - spec/app_spec.rb
179
+ - spec/helpers_spec.rb
180
+ - spec/spec_helper.rb
181
+ has_rdoc: