easy_html_generator 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/lib/easy_html_generator.rb +5 -4
- data/lib/easy_html_generator/generator/base.rb +12 -0
- data/lib/easy_html_generator/generator/combine.rb +5 -2
- data/lib/easy_html_generator/generator/compile/haml/context.rb +1 -3
- data/lib/easy_html_generator/generator/compile/haml/helper/activesupport_override.rb +3 -10
- data/lib/easy_html_generator/generator/copy.rb +2 -2
- data/lib/easy_html_generator/generator/delete.rb +2 -1
- data/lib/easy_html_generator/generator/service/bower.rb +1 -1
- data/lib/easy_html_generator/project.rb +3 -1
- data/lib/easy_html_generator/rack_dispatcher.rb +8 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4121de001c06afef8a4674c5027e2327efc693c9
|
4
|
+
data.tar.gz: c67d23e2d49c758f6278ee9a1dc88cb9fb19cef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65d9714558acef3e3feaf91b4e9904225529fee83f4b293fec3717cd2acd2d099a0c10f0f28ac1ee9d97b6315ae795e7775b62a5572268b4511b1ef75fe2e348
|
7
|
+
data.tar.gz: e48670c042579af8ebbf2a4690ff75cbbf4a42eaf7d6faefb2bf336f9b7ea238a89500308d44095abe69ae4715ec9260fdeb04922cf5351047cca8086a9e47b2
|
data/README.md
CHANGED
@@ -146,7 +146,8 @@ generators:
|
|
146
146
|
|
147
147
|
#### Copy
|
148
148
|
* operates on: `dist` and `src`
|
149
|
-
* copies folder or files from dist to src
|
149
|
+
* copies folder or files from dist to src per default
|
150
|
+
* supports `src://` and `dist://`
|
150
151
|
* config:
|
151
152
|
|
152
153
|
```
|
@@ -159,14 +160,15 @@ generators:
|
|
159
160
|
target: 'styles'
|
160
161
|
selector: '**/*.css'
|
161
162
|
-
|
162
|
-
source: 'assets/scripts'
|
163
|
-
target: 'scripts'
|
163
|
+
source: 'src://assets/scripts'
|
164
|
+
target: 'dist://scripts'
|
164
165
|
selector: '**/*.js'
|
165
166
|
```
|
166
167
|
|
167
168
|
#### Combine
|
168
169
|
* operates on: `dist`
|
169
|
-
* combines merges files on dist
|
170
|
+
* combines merges files on dist per default
|
171
|
+
* supports `src://` and `dist://`
|
170
172
|
* config:
|
171
173
|
|
172
174
|
```
|
@@ -179,14 +181,15 @@ generators:
|
|
179
181
|
files:
|
180
182
|
- 'scripts/**/*.js'
|
181
183
|
-
|
182
|
-
file: 'styles/combined.css'
|
184
|
+
file: 'dist://styles/combined.css'
|
183
185
|
files:
|
184
|
-
- 'styles/**/*.css'
|
186
|
+
- 'src://styles/**/*.css'
|
185
187
|
```
|
186
188
|
|
187
189
|
#### Delete
|
188
190
|
* operates on: `dist`
|
189
|
-
* deletes files or folders on dist
|
191
|
+
* deletes files or folders on dist per default
|
192
|
+
* supports `src://` and `dist://`
|
190
193
|
* config:
|
191
194
|
|
192
195
|
```
|
@@ -195,6 +198,7 @@ generators:
|
|
195
198
|
enabled: false
|
196
199
|
files:
|
197
200
|
- '*'
|
201
|
+
- 'src://bower_components'
|
198
202
|
```
|
199
203
|
|
200
204
|
### Compile-Generators
|
data/lib/easy_html_generator.rb
CHANGED
@@ -8,6 +8,7 @@ require 'bootstrap-sass'
|
|
8
8
|
require 'bundler'
|
9
9
|
require 'colorize'
|
10
10
|
require 'rack'
|
11
|
+
require 'rack/contrib'
|
11
12
|
require 'thin'
|
12
13
|
|
13
14
|
# main module loads projects and dispatches rack requests
|
@@ -83,17 +84,17 @@ module EasyHtmlGenerator
|
|
83
84
|
|
84
85
|
def self.rack_app
|
85
86
|
Rack::Builder.new do
|
87
|
+
use Rack::ShowExceptions
|
86
88
|
use Rack::Reloader, 0
|
87
89
|
use EasyHtmlGenerator::RackDispatcher
|
90
|
+
use Rack::Deflater
|
91
|
+
use Rack::ContentLength
|
92
|
+
use Rack::StaticCache, urls: [''], root: EasyHtmlGenerator::DIST_PATH
|
88
93
|
use Rack::Static,
|
89
94
|
urls: [''],
|
90
95
|
root: EasyHtmlGenerator::DIST_PATH,
|
91
96
|
index: 'index.html'
|
92
97
|
|
93
|
-
use Rack::ContentLength
|
94
|
-
use Rack::Deflater
|
95
|
-
use Rack::ETag
|
96
|
-
|
97
98
|
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, ['404 File not found!']] }
|
98
99
|
end
|
99
100
|
end
|
@@ -80,4 +80,16 @@ class EasyHtmlGenerator::Generator::Base
|
|
80
80
|
STDERR.puts " | #{msg.sub(@project.src_path, '')
|
81
81
|
.sub('EasyHtmlGenerator::', '')}"
|
82
82
|
end
|
83
|
+
|
84
|
+
def resolve_path_prefix(path, default_prefix = '')
|
85
|
+
if path.include? 'src://'
|
86
|
+
default_prefix = @project.src_path
|
87
|
+
path.sub!('src://', '')
|
88
|
+
end
|
89
|
+
if path.include? 'dist://'
|
90
|
+
default_prefix = @project.dist_path
|
91
|
+
path.sub!('dist://', '')
|
92
|
+
end
|
93
|
+
File.join(default_prefix, path)
|
94
|
+
end
|
83
95
|
end
|
@@ -17,12 +17,15 @@ class EasyHtmlGenerator::Generator::Combine <
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def do_config(config)
|
20
|
+
target_file = resolve_path_prefix(config.file, @project.dist_path)
|
20
21
|
o = ''
|
21
22
|
config.files.each do |file_pattern|
|
22
|
-
|
23
|
+
resolved_pattern = resolve_path_prefix(file_pattern, @project.dist_path)
|
24
|
+
Dir[resolved_pattern].each do |file|
|
25
|
+
next if target_file == file
|
23
26
|
o += File.read(file) + "\n"
|
24
27
|
end
|
25
28
|
end
|
26
|
-
File.write(
|
29
|
+
File.write(target_file, o)
|
27
30
|
end
|
28
31
|
end
|
@@ -43,9 +43,7 @@ class EasyHtmlGenerator::Generator::Compile::Haml::Context
|
|
43
43
|
# Use it if it's there.
|
44
44
|
file_to_render = scope_file if File.exist? scope_file
|
45
45
|
end
|
46
|
-
|
47
|
-
Haml::Engine.new(File.read(file_to_render), @config).render self
|
48
|
-
end
|
46
|
+
Haml::Engine.new(File.read(file_to_render), @config).render self
|
49
47
|
rescue StandardError => e
|
50
48
|
raise e, "#{e.message} in #{file_name} ", e.backtrace
|
51
49
|
end
|
@@ -26,23 +26,16 @@ module ActivesupportOverride
|
|
26
26
|
|
27
27
|
def path_to_css(path)
|
28
28
|
return path if external_path?(path)
|
29
|
-
|
30
|
-
file_exists?(test) ? test : path
|
29
|
+
@project.uri_path_to(:styles, path)
|
31
30
|
end
|
32
31
|
|
33
32
|
def path_to_js(path)
|
34
33
|
return path if external_path? path
|
35
|
-
|
36
|
-
file_exists?(test) ? test : path
|
34
|
+
@project.uri_path_to(:scripts, path)
|
37
35
|
end
|
38
36
|
|
39
37
|
def path_to_image(path)
|
40
38
|
return path if external_path? path
|
41
|
-
|
42
|
-
file_exists?(test) ? test : path
|
39
|
+
@project.uri_path_to(:images, path)
|
43
40
|
end
|
44
|
-
|
45
|
-
# def url_for(options = '')
|
46
|
-
# return options
|
47
|
-
# end
|
48
41
|
end
|
@@ -10,8 +10,8 @@ class EasyHtmlGenerator::Generator::Copy < EasyHtmlGenerator::Generator::Base
|
|
10
10
|
log_running
|
11
11
|
|
12
12
|
@config.dirs.each do |config|
|
13
|
-
src_path =
|
14
|
-
dest_path =
|
13
|
+
src_path = resolve_path_prefix(config.source, @project.src_path)
|
14
|
+
dest_path = resolve_path_prefix(config.target, @project.dist_path)
|
15
15
|
|
16
16
|
self.class.copy_r(src_path, dest_path, config.selector)
|
17
17
|
end
|
@@ -10,7 +10,8 @@ class EasyHtmlGenerator::Generator::Delete < EasyHtmlGenerator::Generator::Base
|
|
10
10
|
log_running
|
11
11
|
|
12
12
|
@config.files.each do |file_pattern|
|
13
|
-
|
13
|
+
resolved_pattern = resolve_path_prefix(file_pattern, @project.dist_path)
|
14
|
+
Dir[resolved_pattern].each do |file|
|
14
15
|
EasyHtmlGenerator::Checksum.invalidate_file file
|
15
16
|
|
16
17
|
FileUtils.rm_rf file
|
@@ -15,7 +15,7 @@ class EasyHtmlGenerator::Generator::Service::Bower <
|
|
15
15
|
|
16
16
|
def do_file(bower_file, *_args)
|
17
17
|
input_folder = File.dirname(bower_file)
|
18
|
-
output_folder = File.join(@project.
|
18
|
+
output_folder = File.join(@project.dist_path, @config.target)
|
19
19
|
|
20
20
|
cmd = "cd #{input_folder} && bower install"
|
21
21
|
cmd = "if which bower >/dev/null; then echo '\e[32mrunning bower\e[0m' \
|
@@ -23,7 +23,9 @@ class EasyHtmlGenerator::Project
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def uri_path_to(type, relative_path = '')
|
26
|
-
File.join(
|
26
|
+
uri_path = File.join(@config.paths.dist[type.to_sym], relative_path)
|
27
|
+
local_path = File.join(@dist_path, uri_path)
|
28
|
+
File.exist?(local_path) ? uri_path : relative_path
|
27
29
|
end
|
28
30
|
|
29
31
|
def generate
|
@@ -22,10 +22,17 @@ class EasyHtmlGenerator::RackDispatcher
|
|
22
22
|
case request.path_info
|
23
23
|
when '/'
|
24
24
|
create_directory_listening_index_file
|
25
|
+
env['PATH_INFO'] = '/index.html'
|
25
26
|
else
|
26
27
|
EasyHtmlGenerator.dispatch(request)
|
27
28
|
end
|
28
|
-
@app.call(env)
|
29
|
+
status, headers, body = @app.call(env)
|
30
|
+
|
31
|
+
headers['Connection'] = 'Keep-Alive'
|
32
|
+
headers['Charset'] = 'UTF-8'
|
33
|
+
headers['Vary'] = 'Accept-Encoding'
|
34
|
+
|
35
|
+
[status, headers, body]
|
29
36
|
end
|
30
37
|
|
31
38
|
def create_directory_listening_index_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_html_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Hanoldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-contrib
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: shotgun
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|