reustyle 2.0.9 → 2.0.10
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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/ustyle/deploy.rb +2 -2
- data/lib/ustyle/engine.rb +5 -5
- data/lib/ustyle/helpers/icon_helper.rb +2 -2
- data/lib/ustyle/icons.rb +1 -1
- data/lib/ustyle/middleware/icon_middleware.rb +3 -3
- data/lib/ustyle/sass_functions.rb +5 -5
- data/lib/ustyle/sinatra.rb +3 -3
- data/lib/ustyle/sprockets.rb +3 -3
- data/lib/ustyle/utils.rb +4 -4
- data/lib/ustyle/version.rb +2 -2
- data/lib/ustyle.rb +3 -3
- data/styleguide/assets/sass/main.scss +1 -1
- data/tasks/publish.rake +19 -19
- data/ustyle.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17642de7e04c43caaeacb023fcf752355ddbb5fdd94055fa01f6074fa6230c17
|
4
|
+
data.tar.gz: fc86faf6bd4084fc6a59e20aee08b8526b65b9d55e1414efd8d23f24ee6f0ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7504ab66dab67a329c9b550798cc156975b4bda23a0e8e1b96d3e663f691d7e40ffc2437a510d3a328b39d563e9bb9dd348ebecf42782ea78f67d39030d6cc9d
|
7
|
+
data.tar.gz: 6156bf2c3d52c8e2d9bae780a97e6b4b75625d01099dd781a6c6f54992e8b81f29a61ce260e468d06487e6560128af7fd8a672419b8e0656f5d8e1a562612c0c
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ gem 'sprockets-helpers'
|
|
66
66
|
Then in your app file (usually named server.rb/app.rb etc), after declaring your `class App < Sinatra::Base`:
|
67
67
|
|
68
68
|
```ruby
|
69
|
-
register Sinatra::
|
69
|
+
register Sinatra::Reustyle
|
70
70
|
```
|
71
71
|
|
72
72
|
**You must use `sprockets-sass` version 1.1.0 or above, as there was a bug where the postprocessor was getting added to the preprocessor which caused autoprefixer to break**
|
@@ -81,13 +81,13 @@ Due to this, you need to have the `icons.svg` symbol map on the same domain, pro
|
|
81
81
|
|
82
82
|
For Rails apps, in your `development.rb` file (you do not want this in production)
|
83
83
|
```ruby
|
84
|
-
config.middleware.use
|
84
|
+
config.middleware.use Reustyle::IconMiddleware
|
85
85
|
```
|
86
86
|
|
87
87
|
For Rack apps (including Sinatra)
|
88
88
|
```ruby
|
89
89
|
configure :development do
|
90
|
-
use
|
90
|
+
use Reustyle::IconMiddleware
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
data/lib/ustyle/deploy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "aws-sdk"
|
2
2
|
require "time"
|
3
3
|
|
4
|
-
module
|
4
|
+
module Reustyle
|
5
5
|
REGION = 'eu-west-1'
|
6
6
|
BUCKET = 'uswitch-assets-eu'
|
7
7
|
CLOUDFRONT_DISTRIBUTION = 'E3F1XI0HIG20E0'
|
@@ -38,4 +38,4 @@ module Ustyle
|
|
38
38
|
def self.s3
|
39
39
|
@conn ||= Aws::S3::Resource.new(region: REGION)
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
data/lib/ustyle/engine.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'autoprefixer-rails'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Reustyle
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
add_paths_block = lambda { |app|
|
6
|
-
|
7
|
-
app.config.assets.paths << File.join(
|
6
|
+
Reustyle.asset_directories.each do |asset_directory|
|
7
|
+
app.config.assets.paths << File.join(Reustyle.assets_path, asset_directory)
|
8
8
|
end
|
9
9
|
}
|
10
10
|
|
@@ -19,12 +19,12 @@ module Ustyle
|
|
19
19
|
class Railtie < ::Rails::Railtie
|
20
20
|
if config.respond_to?(:assets) and not config.assets.nil?
|
21
21
|
config.assets.configure do |env|
|
22
|
-
AutoprefixerRails.install(env,
|
22
|
+
AutoprefixerRails.install(env, Reustyle.autoprefixer_config)
|
23
23
|
end
|
24
24
|
else
|
25
25
|
initializer :setup_autoprefixer, group: :all do |app|
|
26
26
|
if defined? app.assets and not app.assets.nil?
|
27
|
-
AutoprefixerRails.install(app.assets,
|
27
|
+
AutoprefixerRails.install(app.assets, Reustyle.autoprefixer_config)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/ustyle/icons.rb
CHANGED
@@ -2,11 +2,11 @@ require 'uri'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'ustyle/utils'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Reustyle
|
6
6
|
class IconMiddleware
|
7
7
|
def initialize(app, options = {})
|
8
8
|
@app = app
|
9
|
-
@icon_path = options[:path] ||
|
9
|
+
@icon_path = options[:path] || Reustyle.cloudfront_url("icons.svg", :icon, false, false)
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
@@ -24,4 +24,4 @@ module Ustyle
|
|
24
24
|
res.body
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
@@ -5,17 +5,17 @@ require "base64"
|
|
5
5
|
module Sass::Script::Functions
|
6
6
|
|
7
7
|
def ustyle_version
|
8
|
-
::Sass::Script::String.new ::
|
8
|
+
::Sass::Script::String.new ::Reustyle::VERSION
|
9
9
|
end
|
10
10
|
declare :ustyle_version, []
|
11
11
|
|
12
12
|
def inline_svg(source)
|
13
13
|
assert_type source, :String
|
14
|
-
if
|
14
|
+
if Reustyle.sprockets?
|
15
15
|
svg = escaped_svg(sprockets_context.environment.find_asset(source.value).to_s)
|
16
|
-
::Sass::Script::String.new "url(data:#{
|
16
|
+
::Sass::Script::String.new "url(data:#{Reustyle.mime_type_for(source.value)};charset=utf-8,#{svg})"
|
17
17
|
else
|
18
|
-
path = File.join(::
|
18
|
+
path = File.join(::Reustyle.assets_path, "images", source.value)
|
19
19
|
asset_data_uri(path, svg = true)
|
20
20
|
end
|
21
21
|
end
|
@@ -38,7 +38,7 @@ module Sass::Script::Functions
|
|
38
38
|
else
|
39
39
|
asset = CGI::escape(Base64.strict_encode64(data(path).to_s))
|
40
40
|
end
|
41
|
-
url = "data:#{
|
41
|
+
url = "data:#{Reustyle.mime_type_for(path)};#{encoding},#{asset}"
|
42
42
|
::Sass::Script::String.new "url('#{url}')"
|
43
43
|
end
|
44
44
|
|
data/lib/ustyle/sinatra.rb
CHANGED
@@ -3,7 +3,7 @@ if defined?(::Sinatra)
|
|
3
3
|
module Reustyle
|
4
4
|
def self.registered app
|
5
5
|
app.set :root, Dir.pwd
|
6
|
-
app.set :sprockets, ::
|
6
|
+
app.set :sprockets, ::Reustyle.sprockets_env
|
7
7
|
app.set :assets_prefix, %w(assets)
|
8
8
|
app.set :assets_path, File.join(app.root, "app", app.assets_prefix.join)
|
9
9
|
app.set :public_folder, File.join(app.root, "public")
|
@@ -12,7 +12,7 @@ if defined?(::Sinatra)
|
|
12
12
|
app.set :assets_digest, true
|
13
13
|
|
14
14
|
# Setup Sprockets
|
15
|
-
::
|
15
|
+
::Reustyle.asset_directories.each do |asset_directory|
|
16
16
|
app.sprockets.append_path File.join(app.assets_path, asset_directory)
|
17
17
|
end
|
18
18
|
|
@@ -24,7 +24,7 @@ if defined?(::Sinatra)
|
|
24
24
|
end
|
25
25
|
|
26
26
|
require 'autoprefixer-rails'
|
27
|
-
AutoprefixerRails.install(app.sprockets, ::
|
27
|
+
AutoprefixerRails.install(app.sprockets, ::Reustyle.autoprefixer_config)
|
28
28
|
|
29
29
|
app.helpers Sprockets::Helpers
|
30
30
|
end
|
data/lib/ustyle/sprockets.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "sprockets"
|
2
2
|
require "sprockets-helpers"
|
3
3
|
|
4
|
-
::
|
5
|
-
::
|
6
|
-
end
|
4
|
+
::Reustyle.asset_directories.each do |asset_directory|
|
5
|
+
::Reustyle.sprockets_env.append_path File.join(::Reustyle.assets_path, asset_directory)
|
6
|
+
end
|
data/lib/ustyle/utils.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'digest'
|
2
2
|
require 'mime/types'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Reustyle
|
5
5
|
|
6
6
|
def self.production?
|
7
7
|
ENV['RACK_ENV'] == 'production' || ENV['RAILS_ENV'] == 'production' || ENV['NODE_ENV'] == 'production' || false
|
@@ -9,7 +9,7 @@ module Ustyle
|
|
9
9
|
|
10
10
|
def self.cloudfront_url path, type, versioned = true, digest = true
|
11
11
|
File.join "https://assets0.uswitch.com/s3/uswitch-assets-eu/ustyle/",
|
12
|
-
(versioned ?
|
12
|
+
(versioned ? Reustyle::VERSION : ""),
|
13
13
|
folder_by_type(type),
|
14
14
|
(digest ? asset_digest(path) : path)
|
15
15
|
end
|
@@ -23,11 +23,11 @@ module Ustyle
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.versioned_path file
|
26
|
-
File.join "ustyle",
|
26
|
+
File.join "ustyle", Reustyle::VERSION, file
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.digest
|
30
|
-
Digest::SHA1.hexdigest
|
30
|
+
Digest::SHA1.hexdigest Reustyle::VERSION
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.folder_by_type type
|
data/lib/ustyle/version.rb
CHANGED
data/lib/ustyle.rb
CHANGED
@@ -6,7 +6,7 @@ require "ustyle/utils"
|
|
6
6
|
require "ustyle/hash"
|
7
7
|
require "ustyle/middleware/icon_middleware"
|
8
8
|
|
9
|
-
module
|
9
|
+
module Reustyle
|
10
10
|
class << self
|
11
11
|
def load!
|
12
12
|
require "ustyle/sass_functions"
|
@@ -48,11 +48,11 @@ module Ustyle
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def autoprefixer_config
|
51
|
-
file = File.join
|
51
|
+
file = File.join Reustyle.gem_path, 'config/autoprefixer.yml'
|
52
52
|
params = YAML.load_file(file).symbolize_keys
|
53
53
|
params
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
Reustyle.load!
|
data/tasks/publish.rake
CHANGED
@@ -6,22 +6,22 @@ require 'ustyle/deploy'
|
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
8
|
namespace :ustyle do
|
9
|
-
desc "Publishes uStyle v#{
|
9
|
+
desc "Publishes uStyle v#{Reustyle::VERSION}"
|
10
10
|
task :upgrade => [ "git:add", "git:push" ] do
|
11
|
-
puts green("Committing new version of uStyle - v#{
|
11
|
+
puts green("Committing new version of uStyle - v#{Reustyle::VERSION}")
|
12
12
|
end
|
13
13
|
|
14
14
|
task :publish => [ "deploy:images", "deploy:stylesheets" ] do
|
15
|
-
puts green("Publishing uStyle v#{
|
15
|
+
puts green("Publishing uStyle v#{Reustyle::VERSION}")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
namespace :git do
|
20
20
|
task :add do
|
21
|
-
`git commit -am '#{
|
21
|
+
`git commit -am '#{Reustyle::VERSION}' && git tag -a v#{Reustyle::VERSION} -m '#{Reustyle::VERSION}'`
|
22
22
|
end
|
23
23
|
|
24
|
-
desc "Push version #{
|
24
|
+
desc "Push version #{Reustyle::VERSION} to github"
|
25
25
|
task :push do
|
26
26
|
`git push -u -f && git push -f --tags`
|
27
27
|
end
|
@@ -32,29 +32,29 @@ namespace :deploy do
|
|
32
32
|
task :stylesheets do
|
33
33
|
Dir["dist/*.{css,json,js,svg}"].each do |file|
|
34
34
|
file_name = File.basename(file)
|
35
|
-
content_type =
|
36
|
-
|
37
|
-
|
35
|
+
content_type = Reustyle.mime_type_for(file_name)
|
36
|
+
Reustyle.s3_upload( Reustyle.versioned_path(file_name), file, content_type )
|
37
|
+
Reustyle.s3_upload( "ustyle/#{file_name}", file, content_type )
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
"/s3/#{
|
42
|
-
"/s3/#{
|
43
|
-
"/s3/#{
|
44
|
-
"/s3/#{
|
45
|
-
"/s3/#{
|
46
|
-
"/s3/#{
|
40
|
+
Reustyle.invalidate([
|
41
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/ustyle-latest.css",
|
42
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/rebrand-latest.css",
|
43
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/ustyle.min.js",
|
44
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/ustyle-content.css",
|
45
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/rebrand-content.css",
|
46
|
+
"/s3/#{Reustyle::BUCKET}/ustyle/icons.svg"
|
47
47
|
])
|
48
48
|
end
|
49
49
|
|
50
50
|
desc "Deploy images to S3"
|
51
51
|
task :images do
|
52
|
-
images_dir = File.join
|
52
|
+
images_dir = File.join Reustyle.assets_path, "images", "**", "*"
|
53
53
|
Dir[images_dir].each do |file|
|
54
54
|
next if File.directory?(file)
|
55
|
-
file_path = file.gsub(Regexp.new("#{
|
56
|
-
hashed_file =
|
57
|
-
|
55
|
+
file_path = file.gsub(Regexp.new("#{Reustyle.assets_path}/"), "")
|
56
|
+
hashed_file = Reustyle.asset_digest(file_path)
|
57
|
+
Reustyle.s3_upload( Reustyle.versioned_path(hashed_file), file, Reustyle.mime_type_for(file))
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/ustyle.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "ustyle/version"
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "reustyle"
|
9
|
-
spec.version =
|
9
|
+
spec.version = Reustyle::VERSION
|
10
10
|
spec.authors = ["uSwitch Limited", "David Annez", "Ricardo Cerqueira", "Joe Green", "Thomas Britton", "Ivo Reis"]
|
11
11
|
spec.email = ["developers@uswitch.com", "david.annez@uswitch.com"]
|
12
12
|
spec.description = %q{uSwitch style guide}
|