pakman 0.6.0 → 0.7.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.
- checksums.yaml +4 -4
- data/Manifest.txt +5 -0
- data/lib/pakman/liquid/templater.rb +39 -10
- data/lib/pakman/version.rb +1 -1
- data/test/liquid/pak/hello.doc +8 -0
- data/test/liquid/pak/hello.txt +3 -0
- data/test/liquid/pak/s9logo.png +0 -0
- data/test/liquid/pak/testbin.txt +7 -0
- data/test/test_liquid_binaries.rb +48 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8627dadb6e570d024eada852f7661770864c3238
|
4
|
+
data.tar.gz: 2c8f9252f3bceb14c559d06d7851d23fb11dfe45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d1f9cdab69b5084546f7d52cbb1471a5159e84d591105b9b83198697eca19e415da4943de9a6b69d4804cd7e8b0973116f33c4a3f2e2b77e2d9c3c27131bfb4
|
7
|
+
data.tar.gz: 674ef0df51ad6fe5ffea55cd194ad12fdcaa286d5a432ec16b1d80f1c03d4c255decd15b84ef517ff80bb9db9ce35b9116e746ee6fb2ffe47f470f1818533700
|
data/Manifest.txt
CHANGED
@@ -26,8 +26,12 @@ test/data/test.yml
|
|
26
26
|
test/erb/pak/test.html.erb
|
27
27
|
test/erb/pak/test.txt
|
28
28
|
test/helper.rb
|
29
|
+
test/liquid/pak/hello.doc
|
30
|
+
test/liquid/pak/hello.txt
|
31
|
+
test/liquid/pak/s9logo.png
|
29
32
|
test/liquid/pak/test.html
|
30
33
|
test/liquid/pak/test.txt
|
34
|
+
test/liquid/pak/testbin.txt
|
31
35
|
test/liquid/test.html
|
32
36
|
test/pages/empty.txt
|
33
37
|
test/pages/page1.txt
|
@@ -36,5 +40,6 @@ test/pages/page3.txt
|
|
36
40
|
test/pages/text.txt
|
37
41
|
test/test_erb.rb
|
38
42
|
test/test_liquid.rb
|
43
|
+
test/test_liquid_binaries.rb
|
39
44
|
test/test_liquid_drops.rb
|
40
45
|
test/test_page.rb
|
@@ -7,14 +7,30 @@ class LiquidTemplater
|
|
7
7
|
|
8
8
|
include LogUtils::Logging
|
9
9
|
|
10
|
+
|
11
|
+
###
|
12
|
+
## check these file extensions for processing
|
13
|
+
## processing (w/ liquid) if front matter header found / present
|
14
|
+
|
15
|
+
EXTS = ['html', 'svg',
|
16
|
+
'js', 'json',
|
17
|
+
'css',
|
18
|
+
'txt', 'text',
|
19
|
+
'md', 'markdown']
|
20
|
+
|
21
|
+
## convert html to \.html$ (e.g. match end-of-string and leading dot)
|
22
|
+
## e.g. /\.(html|svg|...)$|/ etc.
|
23
|
+
REGEX_EXT = Regexp.new( "\\.(#{EXTS.join('|')})$", Regexp::IGNORECASE )
|
24
|
+
|
25
|
+
|
10
26
|
def initialize
|
11
27
|
end
|
12
28
|
|
13
29
|
## rename binding/hash to assigns or something more specific - why? why not?
|
14
30
|
def merge_pak( manifestsrc, pakpath, binding, name )
|
15
|
-
|
31
|
+
|
16
32
|
start = Time.now
|
17
|
-
|
33
|
+
|
18
34
|
pakname = Pakman.pakname_from_file( manifestsrc )
|
19
35
|
|
20
36
|
puts "Merging template pack '#{pakname}'"
|
@@ -25,11 +41,11 @@ class LiquidTemplater
|
|
25
41
|
manifest.each do |entry|
|
26
42
|
dest = entry[0]
|
27
43
|
source = entry[1]
|
28
|
-
|
44
|
+
|
29
45
|
if dest =~ /__file__/ # replace w/ name
|
30
46
|
dest = dest.gsub( '__file__', name )
|
31
47
|
end
|
32
|
-
|
48
|
+
|
33
49
|
# get full (absolute) path and make sure path exists
|
34
50
|
destfull = File.expand_path( dest, pakpath )
|
35
51
|
destpath = File.dirname( destfull )
|
@@ -37,16 +53,29 @@ class LiquidTemplater
|
|
37
53
|
|
38
54
|
logger.debug "destfull=>#{destfull}<"
|
39
55
|
logger.debug "destpath=>#{destpath}<"
|
40
|
-
|
56
|
+
|
41
57
|
###
|
42
58
|
# note:
|
43
59
|
# use jekyll convention for now
|
44
60
|
# check if file starts with front matter (yaml block)
|
45
61
|
# if yes, process (with liquid) otherwise copy as is 1:1
|
46
62
|
|
47
|
-
|
48
|
-
|
49
|
-
|
63
|
+
####
|
64
|
+
# note: for now only check files with known source extensions!!!
|
65
|
+
# do NOT check binaries (e.g. gif, png, ico, etc. -- regex will fail w/ encoding error)
|
66
|
+
# todo/check: check how jekyll works e.g. does jekyll check binaries for front-matter etc. ????
|
67
|
+
|
68
|
+
is_source_page = REGEX_EXT.match( source ) # note: returns nil or MatchData - do NOT use check == false or true (will NOT work)
|
69
|
+
|
70
|
+
if is_source_page.nil?
|
71
|
+
puts " No (pre-)processing for '#{source}' (copy 1:1) - no matching (known) source extension e.g. #{EXTS.join('|')}"
|
72
|
+
source_page = nil
|
73
|
+
else
|
74
|
+
source_page = Page.from_file( source )
|
75
|
+
end
|
76
|
+
|
77
|
+
if source_page && source_page.headers?
|
78
|
+
puts " Bingo! Front matter (e.g. ---) found. Merging template to #{dest}..."
|
50
79
|
|
51
80
|
out = File.new( destfull, 'w+' )
|
52
81
|
## note: only pass along contents (not headers e.g. front matter for now)
|
@@ -56,11 +85,11 @@ class LiquidTemplater
|
|
56
85
|
out.close
|
57
86
|
else
|
58
87
|
puts " Copying to #{dest} from #{source}..."
|
59
|
-
|
88
|
+
|
60
89
|
FileUtils.copy( source, destfull )
|
61
90
|
end
|
62
91
|
end # each entry in manifest
|
63
|
-
|
92
|
+
|
64
93
|
puts "Done (in #{Time.now-start} s)."
|
65
94
|
end # method merge_pak
|
66
95
|
|
data/lib/pakman/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_liquid_binaries.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestLiquidBinaries < MiniTest::Test
|
12
|
+
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Liquid::Template.error_mode = :strict
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_rx
|
20
|
+
rx = Pakman::LiquidTemplater::REGEX_EXT
|
21
|
+
|
22
|
+
pp rx
|
23
|
+
|
24
|
+
## todo: check why assert rx.match( 'test.html' ) == true doesn't work
|
25
|
+
## (note: regex.match will return MatchData or nil)
|
26
|
+
|
27
|
+
assert rx.match( 'test.html' ).nil? == false
|
28
|
+
assert rx.match( 'TEST.HTML' ).nil? == false
|
29
|
+
assert rx.match( 'test.js' ).nil? == false
|
30
|
+
assert rx.match( 'test.json' ).nil? == false
|
31
|
+
assert rx.match( 'test.gif' ).nil? == true
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_merge
|
36
|
+
hash = YAML.load_file( "#{Pakman.root}/test/data/test.yml" )
|
37
|
+
ctx= { 'headers' => hash['headers'], 'slides' => hash['slides'] }
|
38
|
+
pp ctx
|
39
|
+
|
40
|
+
manifestsrc = "#{Pakman.root}/test/liquid/pak/testbin.txt"
|
41
|
+
outpath = "#{Pakman.root}/tmp/#{Time.now.to_i}" ## pakpath/output path
|
42
|
+
|
43
|
+
Pakman::LiquidTemplater.new.merge_pak( manifestsrc, outpath, ctx, 'test' )
|
44
|
+
|
45
|
+
assert true
|
46
|
+
end # method test_merge
|
47
|
+
|
48
|
+
end # class TestLiquidBinaries
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fetcher
|
@@ -118,8 +118,12 @@ files:
|
|
118
118
|
- test/erb/pak/test.html.erb
|
119
119
|
- test/erb/pak/test.txt
|
120
120
|
- test/helper.rb
|
121
|
+
- test/liquid/pak/hello.doc
|
122
|
+
- test/liquid/pak/hello.txt
|
123
|
+
- test/liquid/pak/s9logo.png
|
121
124
|
- test/liquid/pak/test.html
|
122
125
|
- test/liquid/pak/test.txt
|
126
|
+
- test/liquid/pak/testbin.txt
|
123
127
|
- test/liquid/test.html
|
124
128
|
- test/pages/empty.txt
|
125
129
|
- test/pages/page1.txt
|
@@ -128,6 +132,7 @@ files:
|
|
128
132
|
- test/pages/text.txt
|
129
133
|
- test/test_erb.rb
|
130
134
|
- test/test_liquid.rb
|
135
|
+
- test/test_liquid_binaries.rb
|
131
136
|
- test/test_liquid_drops.rb
|
132
137
|
- test/test_page.rb
|
133
138
|
homepage: https://github.com/rubylibs/pakman
|