sprockets-svg 0.0.4 → 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.
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" opacity="0.4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
5
+ x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
6
+ <path display="none" d="M19.001,4.416c-0.667,0.292-1.375,0.5-2.125,0.583c0.771-0.458,1.354-1.188,1.625-2.042
7
+ c-0.708,0.417-1.5,0.729-2.334,0.896c-0.688-0.708-1.646-1.167-2.709-1.167c-2.042,0-3.688,1.646-3.688,3.688
8
+ c0,0.292,0.021,0.583,0.083,0.854C6.791,7.062,4.083,5.666,2.249,3.437c-0.313,0.542-0.5,1.104-0.5,1.792
9
+ c0,1.271,0.646,2.396,1.646,3.063C2.791,8.271,2.228,8.104,1.728,7.833c0,0.021,0,0.021,0,0.042c0,1.792,1.271,3.292,2.959,3.625
10
+ c-0.313,0.083-0.646,0.125-0.979,0.125c-0.229,0-0.458-0.021-0.688-0.062c0.458,1.458,1.834,2.542,3.438,2.563
11
+ c-1.25,1-2.855,1.75-4.584,1.75c-0.292,0-0.583-0.021-0.875-0.062c1.625,1.042,3.584,1.5,5.667,1.5
12
+ c6.792,0,10.501-5.626,10.501-10.501c0-0.167,0-0.313,0-0.479C17.876,5.812,18.501,5.166,19.001,4.416z"/>
13
+ <path d="M17.386,1H2.613C2.065,1,1,2.065,1,2.614v14.773C1,17.935,2.065,19,2.613,19l7.887,0v-7H8V9.5h2.5V8
14
+ c0-2.325,1.566-3.911,3.64-3.911c0.994,0,1.516,0.107,1.765,0.14L16,6.5h-1.5C13.372,6.5,13,7.214,13,8v1.5h3L15.5,12H13v7l4.386,0
15
+ C17.935,19,19,17.935,19,17.386V2.614C19,2.065,17.935,1,17.386,1z"/>
16
+ <path display="none" d="M10.417,1C5.499,1,3.041,4.521,3.041,7.459c0,1.771,0.667,3.355,2.104,3.959c0.25,0.083,0.458,0,0.521-0.271
17
+ c0.042-0.167,0.167-0.625,0.208-0.833c0.062-0.25,0.042-0.333-0.146-0.563c-0.417-0.5-0.688-1.125-0.688-2.042
18
+ c0-2.604,1.959-4.938,5.105-4.938c2.771,0,4.292,1.688,4.292,3.959c0,2.98-1.313,5.501-3.271,5.501c-1.083,0-1.896-0.896-1.646-2
19
+ c0.313-1.313,0.917-2.729,0.917-3.667c0-0.854-0.458-1.542-1.396-1.542c-1.104,0-1.979,1.125-1.979,2.667
20
+ c0,0.979,0.312,1.646,0.312,1.646S6.25,14.127,6.062,14.96C5.666,16.627,6,18.69,6.02,18.898c0.021,0.104,0.167,0.146,0.25,0.042
21
+ c0.104-0.125,1.417-1.75,1.854-3.375c0.146-0.458,0.729-2.834,0.729-2.834c0.375,0.688,1.417,1.271,2.542,1.271
22
+ c3.313,0,5.563-3.021,5.563-7.084C16.959,3.854,14.376,1,10.417,1z"/>
23
+ <g display="none">
24
+ <g display="inline">
25
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18.25,5.75H1.75c-0.749,0-1.5,0.757-1.5,1.5v7.5c0,0.743,0.751,1.5,1.5,1.5h1.5
26
+ v-4h13.5v4h1.5c0.749,0,1.5-0.757,1.5-1.5v-7.5C19.75,6.507,19,5.75,18.25,5.75z M16.75,9.75h-1.5v-1.5h1.5V9.75z M15.25,1.25
27
+ H4.75v3h10.5V1.25z M4.75,18.75h10.5v-5H4.75V18.75z"/>
28
+ </g>
29
+ </g>
30
+ <g display="none">
31
+ <g display="inline">
32
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16,1.005H4v3.021h12V1.005z M18.5,5.005H1.521C1.042,5.005,0,6.005,0,6.526v8
33
+ c0,0.5,1.021,1.479,1.542,1.479H3v-4h14v4.031l1.531-0.031c0.453,0,1.469-1,1.469-1.438v-8C20,6.005,18.984,5.005,18.5,5.005z
34
+ M17,9.005h-1v-1h1V9.005z M3.979,19.005h12.062v-5.979H3.979V19.005z"/>
35
+ </g>
36
+ </g>
37
+ </svg>
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,7 @@
1
+ class AssetsController < ApplicationController
2
+
3
+ def test
4
+ render text: Rails.application.assets[params[:file]].to_s
5
+ end
6
+
7
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "sprockets/railtie"
5
+
6
+ if defined?(Bundler)
7
+ Bundler.require(*Rails.groups(assets: %w(development test)))
8
+ end
9
+
10
+ module App
11
+ class Application < Rails::Application
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,2 @@
1
+ require File.expand_path('../application', __FILE__)
2
+ App::Application.initialize!
@@ -0,0 +1,12 @@
1
+ App::Application.configure do
2
+ config.assets.digest = true
3
+ config.cache_classes = true
4
+ config.serve_static_assets = true
5
+ config.static_cache_control = "public, max-age=3600"
6
+ config.eager_load = false
7
+ config.consider_all_requests_local = true
8
+ config.action_controller.perform_caching = false
9
+ config.action_dispatch.show_exceptions = false
10
+ config.action_controller.allow_forgery_protection = false
11
+ config.active_support.deprecation = :stderr
12
+ end
@@ -0,0 +1 @@
1
+ App::Application.config.secret_key_base = 'test'
@@ -0,0 +1,3 @@
1
+ App::Application.routes.draw do
2
+ root to: 'assets#test'
3
+ end
@@ -0,0 +1,2 @@
1
+ require ::File.expand_path('../config/environment', __FILE__)
2
+ run App::Application
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ require 'digest/md5'
4
+ require 'fileutils'
5
+ require 'json'
6
+
7
+ COMPILED_ASSETS_PATH = File.expand_path('app/public/assets/', File.dirname(__FILE__))
8
+ ASSETS = Pathname.new(COMPILED_ASSETS_PATH)
9
+
10
+ describe 'Rake task' do
11
+ before :each do
12
+ FileUtils.mkdir_p(COMPILED_ASSETS_PATH)
13
+ end
14
+
15
+ after :each do
16
+ FileUtils.rm_rf(COMPILED_ASSETS_PATH)
17
+ end
18
+
19
+ let(:svg_name) { 'facebook-052e5d3070b50e0b3e60014378ece289.svg' }
20
+
21
+ let(:png_name) { 'facebook.svg-052e5d3070b50e0b3e60014378ece289.png' }
22
+
23
+ let(:svg_path) { ASSETS.join(svg_name) }
24
+
25
+ let(:png_path) { ASSETS.join(png_name) }
26
+
27
+ let(:font_path) { ASSETS.join('fontawesome-webfont-7534bcc67141208ea7a8c9be3a960f17.svg') }
28
+
29
+ let(:svg_fingerprint) { Digest::MD5.hexdigest(svg_path.read) }
30
+
31
+ let(:manifest_path) { Dir[ASSETS.join('manifest-*.json')].first }
32
+
33
+ let(:manifest) { JSON.parse(File.read(manifest_path)) }
34
+
35
+ let(:png_source) { png_path.read }
36
+
37
+ it "generate a PNG from the SVG source" do
38
+ output = `cd spec/app; bundle exec rake assets:precompile 2>&1`
39
+ puts output unless $?.success?
40
+ $?.should be_success
41
+
42
+ expect(svg_path).to be_exist
43
+ expect(png_path).to be_exist
44
+
45
+ expect(svg_fingerprint).to be == '85385a2b8357015a4ae6d8ab782d5389'
46
+ # Metadata etc are kinda time dependant, so this assertion is the best I can do.
47
+ expect(png_source).to be_starts_with("\x89PNG\r\n")
48
+
49
+ expect(manifest['files'][svg_name]).to be_present
50
+ expect(manifest['files'][png_name]).to be_present
51
+
52
+ expect(manifest['assets']['facebook.svg.png']).to be == png_name
53
+
54
+ expect(font_path).to be_exist
55
+ expect(Dir[ASSETS.join('fontawesome-webfont-*.png')]).to be_empty
56
+ end
57
+ end
58
+
59
+ describe AssetsController, type: :controller do
60
+
61
+ it 'rack' do
62
+ get :test, file: 'facebook.svg.png'
63
+ expect(response).to be_success
64
+ expect(response.body.force_encoding('utf-8')).to be_starts_with("\x89PNG\r\n")
65
+ end
66
+
67
+ end
@@ -0,0 +1,18 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require_relative 'app/config/environment'
4
+ require 'rspec/rails'
5
+ require_relative '../lib/sprockets-svg'
6
+
7
+
8
+ RSpec.configure do |c|
9
+ c.filter_run_excluding not_jruby: RUBY_PLATFORM == 'java'
10
+ end
11
+
12
+
13
+ RSpec.configure do |config|
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+ config.order = 'random'
18
+ end
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.5'
22
- spec.add_development_dependency 'rake'
23
22
  spec.add_dependency 'sprockets'
24
23
  spec.add_dependency 'nokogiri'
25
24
  spec.add_dependency 'rmagick'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sprockets
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +74,8 @@ extensions: []
88
74
  extra_rdoc_files: []
89
75
  files:
90
76
  - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
91
79
  - Gemfile
92
80
  - LICENSE.txt
93
81
  - README.md
@@ -99,6 +87,21 @@ files:
99
87
  - lib/sprockets/svg/railtie.rb
100
88
  - lib/sprockets/svg/server.rb
101
89
  - lib/sprockets/svg/version.rb
90
+ - spec/app/.gitignore
91
+ - spec/app/Rakefile
92
+ - spec/app/app/assets/fonts/fontawesome-webfont.svg
93
+ - spec/app/app/assets/images/facebook.svg
94
+ - spec/app/app/controllers/application_controller.rb
95
+ - spec/app/app/controllers/assets_controller.rb
96
+ - spec/app/config.ru
97
+ - spec/app/config/application.rb
98
+ - spec/app/config/boot.rb
99
+ - spec/app/config/environment.rb
100
+ - spec/app/config/environments/test.rb
101
+ - spec/app/config/initializers/secret_token.rb
102
+ - spec/app/config/routes.rb
103
+ - spec/rails_spec.rb
104
+ - spec/spec_helper.rb
102
105
  - sprockets-svg.gemspec
103
106
  homepage: https://github.com/byroot/sprockets-svg
104
107
  licenses:
@@ -124,4 +127,19 @@ rubygems_version: 2.2.1
124
127
  signing_key:
125
128
  specification_version: 4
126
129
  summary: SVG toolchain for sprockets
127
- test_files: []
130
+ test_files:
131
+ - spec/app/.gitignore
132
+ - spec/app/Rakefile
133
+ - spec/app/app/assets/fonts/fontawesome-webfont.svg
134
+ - spec/app/app/assets/images/facebook.svg
135
+ - spec/app/app/controllers/application_controller.rb
136
+ - spec/app/app/controllers/assets_controller.rb
137
+ - spec/app/config.ru
138
+ - spec/app/config/application.rb
139
+ - spec/app/config/boot.rb
140
+ - spec/app/config/environment.rb
141
+ - spec/app/config/environments/test.rb
142
+ - spec/app/config/initializers/secret_token.rb
143
+ - spec/app/config/routes.rb
144
+ - spec/rails_spec.rb
145
+ - spec/spec_helper.rb