fronton 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/fronton.gemspec +4 -3
- data/lib/fronton/assets_helpers.rb +2 -2
- data/lib/fronton/cli.rb +5 -29
- data/lib/fronton/config.rb +13 -2
- data/lib/fronton/context.rb +22 -0
- data/lib/fronton/version.rb +2 -2
- data/lib/fronton.rb +1 -0
- data/template/fronton.yml +1 -3
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7137692de297bf2d434dfa04d901458b1ba817a2
|
4
|
+
data.tar.gz: 0e370701e42502692d1f4520dcda2f4e286f50ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 421be3479ef525f1ed45d41a2d9e58df611c71f559fa9ed968089cfada432278f863243dcaa98f51898f4e51e021b8d8f081c48ec2e5833d99d1ba617e101d02
|
7
|
+
data.tar.gz: 3f7830b8cbd2504440a517e75eb0ea8dfc37d21a4fee516bb92a980b4cce16684f208b47233dac9035ec29e0c2bfcc383f610b3aa33c9779f70e28cb630b9e54
|
data/README.md
CHANGED
@@ -39,13 +39,12 @@ $ gem install fronton
|
|
39
39
|
### Config file
|
40
40
|
|
41
41
|
Configuration options are readed from a `fronton.yml` file located in project
|
42
|
-
top folder.
|
42
|
+
top folder. `application.js`, `application.css` and all non js&css files in
|
43
|
+
*assets_paths* are already added.
|
43
44
|
|
44
45
|
```yaml
|
45
46
|
assets:
|
46
|
-
-
|
47
|
-
- application.css
|
48
|
-
- "*.png"
|
47
|
+
- otherfile.js
|
49
48
|
assets_paths:
|
50
49
|
- assets/javascripts
|
51
50
|
- assets/stylesheets
|
@@ -72,7 +71,7 @@ pages_paths:
|
|
72
71
|
|
73
72
|
| Attribute | Type | Description |
|
74
73
|
| ------------- | ------ | ---------------------------------------------------------- |
|
75
|
-
| assets | Array | List of assets to compile
|
74
|
+
| assets | Array | List of assets to compile |
|
76
75
|
| assets_paths | Array | List of directories where Sprockets find files for require |
|
77
76
|
| assets_url | String | URL for assets in production |
|
78
77
|
| compressors | Hash | Hash with selected compressors by type |
|
data/fronton.gemspec
CHANGED
@@ -28,9 +28,10 @@ Gem::Specification.new do |spec|
|
|
28
28
|
#
|
29
29
|
## DEPENDENCIES
|
30
30
|
#
|
31
|
-
spec.add_dependency '
|
32
|
-
spec.add_dependency 'rack',
|
33
|
-
spec.add_dependency 'sprockets',
|
31
|
+
spec.add_dependency 'activesupport', '~> 5.0'
|
32
|
+
spec.add_dependency 'rack', '~> 2.0'
|
33
|
+
spec.add_dependency 'sprockets', '~> 3.7'
|
34
|
+
spec.add_dependency 'thor', '~> 0.19'
|
34
35
|
|
35
36
|
#
|
36
37
|
## DEVELOPMENT DEPENDENCIES
|
@@ -2,7 +2,7 @@ module Fronton
|
|
2
2
|
class AssetsHelpers
|
3
3
|
def initialize(options = {})
|
4
4
|
@use_digest = options.fetch(:digest, false)
|
5
|
-
@prefix = options.fetch(:prefix, 'assets')
|
5
|
+
@prefix = options.fetch(:prefix, '/assets')
|
6
6
|
@manifest = options.fetch(:manifest)
|
7
7
|
end
|
8
8
|
|
@@ -18,7 +18,7 @@ module Fronton
|
|
18
18
|
|
19
19
|
def asset_path(name)
|
20
20
|
asset_name = @use_digest && @manifest.assets[name] ? @manifest.assets[name] : name
|
21
|
-
|
21
|
+
File.join(@prefix, asset_name)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/fronton/cli.rb
CHANGED
@@ -48,17 +48,8 @@ module Fronton
|
|
48
48
|
config.require_dependencies
|
49
49
|
|
50
50
|
# assets helpers
|
51
|
-
config.environment.context_class.
|
52
|
-
|
53
|
-
"/assets/#{path}"
|
54
|
-
end
|
55
|
-
alias_method :'asset-path', :asset_path
|
56
|
-
|
57
|
-
def asset_url(path, _options = {})
|
58
|
-
"url(#{asset_path(path)})"
|
59
|
-
end
|
60
|
-
alias_method :'asset-url', :asset_url
|
61
|
-
end
|
51
|
+
config.environment.context_class.digest_assets = false
|
52
|
+
config.environment.context_class.assets_prefix = '/assets'
|
62
53
|
|
63
54
|
conf = config
|
64
55
|
|
@@ -93,24 +84,9 @@ module Fronton
|
|
93
84
|
end
|
94
85
|
|
95
86
|
# assets helpers
|
96
|
-
config.
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def asset_path(path, _options = {})
|
102
|
-
path = self.class.superclass.fronton_config.manifest.assets[path]
|
103
|
-
"#{self.class.superclass.fronton_config.assets_url}/#{path}"
|
104
|
-
end
|
105
|
-
alias_method :'asset-path', :asset_path
|
106
|
-
|
107
|
-
def asset_url(path, _options = {})
|
108
|
-
"url(#{asset_path(path)})"
|
109
|
-
end
|
110
|
-
alias_method :'asset-url', :asset_url
|
111
|
-
end
|
112
|
-
|
113
|
-
config.environment.context_class.fronton_config = config
|
87
|
+
prefix = "#{config.assets_url}/assets"
|
88
|
+
config.environment.context_class.digest_assets = true
|
89
|
+
config.environment.context_class.assets_prefix = prefix
|
114
90
|
|
115
91
|
# compile assets
|
116
92
|
config.manifest.compile(config.assets)
|
data/lib/fronton/config.rb
CHANGED
@@ -3,11 +3,16 @@ require 'logger'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'sprockets'
|
5
5
|
require 'fronton/dependency'
|
6
|
+
require 'fronton/context'
|
6
7
|
|
7
8
|
module Fronton
|
8
9
|
class Config
|
9
10
|
class YAMLNotFound < StandardError; end
|
10
11
|
|
12
|
+
PRECOMPILE_CRITERIA = lambda do |logical_path, filename|
|
13
|
+
filename.start_with?(Dir.pwd) && !['.js', '.css', ''].include?(File.extname(logical_path))
|
14
|
+
end
|
15
|
+
|
11
16
|
def self.load!
|
12
17
|
file = Pathname.pwd.join('fronton.yml')
|
13
18
|
|
@@ -29,7 +34,10 @@ module Fronton
|
|
29
34
|
#
|
30
35
|
|
31
36
|
def assets
|
32
|
-
@assets ||=
|
37
|
+
@assets ||= begin
|
38
|
+
assets_conf = @config['assets'].is_a?(Array) ? @config['assets'] : []
|
39
|
+
[PRECOMPILE_CRITERIA, /(?:\/|\\|\A)application\.(css|js)$/] + assets_conf
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
def assets_paths
|
@@ -43,7 +51,7 @@ module Fronton
|
|
43
51
|
end
|
44
52
|
|
45
53
|
def assets_url
|
46
|
-
@config['assets_url']
|
54
|
+
@config['assets_url']
|
47
55
|
end
|
48
56
|
|
49
57
|
def output
|
@@ -109,6 +117,9 @@ module Fronton
|
|
109
117
|
RailsAssets.load_paths.each { |path| env.append_path path }
|
110
118
|
end
|
111
119
|
|
120
|
+
# context helpers
|
121
|
+
env.context_class.send :include, ::Fronton::Context
|
122
|
+
|
112
123
|
env
|
113
124
|
end
|
114
125
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fronton
|
2
|
+
module Context
|
3
|
+
def self.included(klass)
|
4
|
+
klass.class_eval do
|
5
|
+
class_attribute :assets_prefix, :digest_assets
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def asset_url(path, _options = {})
|
10
|
+
"url(#{asset_path(path)})"
|
11
|
+
end
|
12
|
+
alias_method :'asset-url', :asset_url
|
13
|
+
|
14
|
+
def asset_path(path, _options = {})
|
15
|
+
asset = link_asset(path)
|
16
|
+
digest_path = asset.digest_path
|
17
|
+
path = digest_path if digest_assets
|
18
|
+
File.join(assets_prefix || "/", path)
|
19
|
+
end
|
20
|
+
alias_method :'asset-path', :asset_path
|
21
|
+
end
|
22
|
+
end
|
data/lib/fronton/version.rb
CHANGED
data/lib/fronton.rb
CHANGED
data/template/fronton.yml
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fronton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Aranda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.19'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.19'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: coveralls
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +153,7 @@ files:
|
|
139
153
|
- lib/fronton/assets_helpers.rb
|
140
154
|
- lib/fronton/cli.rb
|
141
155
|
- lib/fronton/config.rb
|
156
|
+
- lib/fronton/context.rb
|
142
157
|
- lib/fronton/dependency.rb
|
143
158
|
- lib/fronton/html_server.rb
|
144
159
|
- lib/fronton/page.rb
|
@@ -175,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
190
|
version: '0'
|
176
191
|
requirements: []
|
177
192
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.5.1
|
179
194
|
signing_key:
|
180
195
|
specification_version: 4
|
181
196
|
summary: A command-line tool for build frontend apps in Ruby
|