pakman 0.7.0 → 1.0.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/Rakefile +7 -7
- data/lib/pakman.rb +2 -2
- data/lib/pakman/cli/commands/fetch.rb +6 -4
- data/lib/pakman/cli/commands/gen.rb +8 -6
- data/lib/pakman/cli/commands/list.rb +7 -5
- data/lib/pakman/cli/ctx.rb +3 -1
- data/lib/pakman/cli/helpers.rb +5 -3
- data/lib/pakman/cli/opts.rb +8 -6
- data/lib/pakman/cli/runner.rb +7 -5
- data/lib/pakman/copier.rb +5 -13
- data/lib/pakman/erb/template.rb +2 -2
- data/lib/pakman/erb/templater.rb +8 -18
- data/lib/pakman/fetcher.rb +10 -17
- data/lib/pakman/finder.rb +8 -15
- data/lib/pakman/liquid/template.rb +15 -7
- data/lib/pakman/liquid/templater.rb +1 -4
- data/lib/pakman/manifest.rb +8 -16
- data/lib/pakman/page.rb +3 -4
- data/lib/pakman/utils.rb +3 -1
- data/lib/pakman/version.rb +2 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22a5cf70dcedaa0eb95834a086d24a7386597853
|
4
|
+
data.tar.gz: 63c75a8c9c8ccb237bd4c1722cb90b62fe5a0816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 659145fbe1d193a0259751e8e1521ebd9845fef0f358a2a9118f574bfe59b13a6d447088e79503efc83e8e9b5c225d85090d541c9aa99ca3850271aee5e88e34
|
7
|
+
data.tar.gz: 30238ac4aad11d19dbb1d11f339eae6c323101ab6d48f1e2435da15138907949db3b110d8184fb1902b28ade6afac7dd4cf939e78067efd07c7be5563b9a500b
|
data/Rakefile
CHANGED
@@ -2,31 +2,31 @@ require 'hoe'
|
|
2
2
|
require './lib/pakman/version.rb'
|
3
3
|
|
4
4
|
Hoe.spec 'pakman' do
|
5
|
-
|
5
|
+
|
6
6
|
self.version = Pakman::VERSION
|
7
|
-
|
7
|
+
|
8
8
|
self.summary = 'pakman - Template Pack Manager (incl. Embedded Ruby, Liquid, etc.)'
|
9
9
|
self.description = summary
|
10
|
-
|
10
|
+
|
11
11
|
self.urls = ['https://github.com/rubylibs/pakman']
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'wwwmake@googlegroups.com'
|
15
|
-
|
15
|
+
|
16
16
|
self.extra_deps = [
|
17
17
|
['fetcher', '>= 0.4.5'],
|
18
18
|
['logutils', '>= 0.6.1'],
|
19
|
-
['liquid', '>=
|
19
|
+
['liquid', '>= 4.0.0'],
|
20
20
|
]
|
21
21
|
|
22
22
|
# switch extension to .rdoc for gihub formatting
|
23
23
|
# self.readme_file = 'README.md'
|
24
24
|
# self.history_file = 'History.md'
|
25
|
-
|
25
|
+
|
26
26
|
self.licenses = ['Public Domain']
|
27
27
|
|
28
28
|
self.spec_extras = {
|
29
|
-
required_ruby_version: '>=
|
29
|
+
required_ruby_version: '>= 2.3'
|
30
30
|
}
|
31
31
|
|
32
32
|
end
|
data/lib/pakman.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
###
|
4
|
-
#
|
4
|
+
# Note: for local testing run like:
|
5
5
|
#
|
6
6
|
# 1.9.x: ruby -Ilib lib/pakman.rb
|
7
7
|
|
@@ -66,4 +66,4 @@ module Pakman
|
|
66
66
|
end # module Pakman
|
67
67
|
|
68
68
|
|
69
|
-
Pakman.main if __FILE__ == $0
|
69
|
+
Pakman.main if __FILE__ == $0
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Fetch
|
@@ -13,12 +15,12 @@ class Fetch
|
|
13
15
|
def run
|
14
16
|
logger.debug "fetch_uri: >#{opts.fetch_uri}<"
|
15
17
|
src = opts.fetch_uri
|
16
|
-
|
18
|
+
|
17
19
|
uri = URI.parse( src )
|
18
20
|
logger.debug "scheme: >#{uri.scheme}<, host: >#{uri.host}<, port: >#{uri.port}<, path: >#{uri.path}<"
|
19
|
-
|
21
|
+
|
20
22
|
pakname = Pakman.pakname_from_file( uri.path )
|
21
|
-
logger.debug "pakname: >#{pakname}<"
|
23
|
+
logger.debug "pakname: >#{pakname}<"
|
22
24
|
|
23
25
|
pakpath = File.expand_path( pakname, opts.config_path )
|
24
26
|
logger.debug "pakpath: >#{pakpath}<"
|
@@ -27,4 +29,4 @@ class Fetch
|
|
27
29
|
end # method run
|
28
30
|
|
29
31
|
end # class Fetch
|
30
|
-
end # module Pakman
|
32
|
+
end # module Pakman
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Gen
|
@@ -15,20 +17,20 @@ class Gen
|
|
15
17
|
def run( args )
|
16
18
|
manifest_name = opts.manifest
|
17
19
|
manifest_name = manifest_name.downcase.gsub('.txt', '' ) # remove .txt if present
|
18
|
-
|
20
|
+
|
19
21
|
logger.debug "manifest=#{manifest_name}"
|
20
22
|
|
21
23
|
# check for matching manifests
|
22
24
|
manifests = installed_template_manifests.select { |m| m[0] == manifest_name+'.txt' }
|
23
|
-
|
25
|
+
|
24
26
|
if manifests.empty?
|
25
27
|
puts "*** error: unknown template pack '#{manifest_name}'; use pakman -l to list installed template packs"
|
26
28
|
exit 2
|
27
29
|
end
|
28
|
-
|
30
|
+
|
29
31
|
manifestsrc = manifests[0][1]
|
30
32
|
pakpath = opts.output_path
|
31
|
-
|
33
|
+
|
32
34
|
if args.empty?
|
33
35
|
Copier.new.copy_pak( manifestsrc, pakpath )
|
34
36
|
else
|
@@ -40,8 +42,8 @@ class Gen
|
|
40
42
|
Templater.new.merge_pak( manifestsrc, pakpath, Ctx.new(data).ctx, name )
|
41
43
|
end
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
end
|
45
47
|
|
46
48
|
end # class Gen
|
47
|
-
end # module Pakman
|
49
|
+
end # module Pakman
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class List
|
@@ -14,16 +16,16 @@ class List
|
|
14
16
|
|
15
17
|
def run
|
16
18
|
manifests = installed_template_manifests
|
17
|
-
|
19
|
+
|
18
20
|
puts 'Installed template packs in search path'
|
19
|
-
|
21
|
+
|
20
22
|
installed_template_manifest_patterns.each_with_index do |pattern,i|
|
21
23
|
puts " [#{i+1}] #{pattern}"
|
22
24
|
end
|
23
25
|
puts ' include:'
|
24
|
-
|
26
|
+
|
25
27
|
if manifests.empty?
|
26
|
-
puts " -- none --"
|
28
|
+
puts " -- none --"
|
27
29
|
else
|
28
30
|
manifests.each do |manifest|
|
29
31
|
puts "%16s (%s)" % [manifest[0].gsub('.txt',''), manifest[1]]
|
@@ -32,4 +34,4 @@ class List
|
|
32
34
|
end
|
33
35
|
|
34
36
|
end # class List
|
35
|
-
end # module Pakman
|
37
|
+
end # module Pakman
|
data/lib/pakman/cli/ctx.rb
CHANGED
data/lib/pakman/cli/helpers.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
module ManifestHelper
|
@@ -18,7 +20,7 @@ module ManifestHelper
|
|
18
20
|
"*.txt",
|
19
21
|
"*/*.txt"
|
20
22
|
]
|
21
|
-
|
23
|
+
|
22
24
|
patterns = []
|
23
25
|
patterns += current_patterns
|
24
26
|
patterns += config_patterns
|
@@ -29,10 +31,10 @@ module ManifestHelper
|
|
29
31
|
excludes = [
|
30
32
|
"Manifest.txt",
|
31
33
|
"*/Manifest.txt"
|
32
|
-
]
|
34
|
+
]
|
33
35
|
|
34
36
|
Finder.new.find_manifests( installed_template_manifest_patterns, excludes )
|
35
37
|
end
|
36
38
|
|
37
39
|
end # module ManifestHelper
|
38
|
-
end # module Pakman
|
40
|
+
end # module Pakman
|
data/lib/pakman/cli/opts.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Opts
|
@@ -5,7 +7,7 @@ class Opts
|
|
5
7
|
def list=(value)
|
6
8
|
@list = value
|
7
9
|
end
|
8
|
-
|
10
|
+
|
9
11
|
def list?
|
10
12
|
return false if @list.nil? # default list flag is false
|
11
13
|
@list == true
|
@@ -29,7 +31,7 @@ class Opts
|
|
29
31
|
def fetch_uri
|
30
32
|
@fetch_uri || '-fetch uri required-'
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
def fetch?
|
34
36
|
@fetch_uri.nil? ? false : true
|
35
37
|
end
|
@@ -38,7 +40,7 @@ class Opts
|
|
38
40
|
def manifest=(value)
|
39
41
|
@manifest = value
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
## fix:/todo: use a different default manifest
|
43
45
|
def manifest
|
44
46
|
@manifest || 's6.txt'
|
@@ -48,7 +50,7 @@ class Opts
|
|
48
50
|
def config_path=(value)
|
49
51
|
@config_path = value
|
50
52
|
end
|
51
|
-
|
53
|
+
|
52
54
|
def config_path
|
53
55
|
@config_path || '~/.pak'
|
54
56
|
end
|
@@ -57,10 +59,10 @@ class Opts
|
|
57
59
|
def output_path=(value)
|
58
60
|
@output_path = value
|
59
61
|
end
|
60
|
-
|
62
|
+
|
61
63
|
def output_path
|
62
64
|
@output_path || '.'
|
63
65
|
end
|
64
66
|
|
65
67
|
end # class Opts
|
66
|
-
end # module Pakman
|
68
|
+
end # module Pakman
|
data/lib/pakman/cli/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Runner
|
@@ -12,7 +14,7 @@ class Runner
|
|
12
14
|
|
13
15
|
def run( args )
|
14
16
|
opt=OptionParser.new do |cmd|
|
15
|
-
|
17
|
+
|
16
18
|
cmd.banner = "Usage: pakman [options]"
|
17
19
|
|
18
20
|
cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |uri|
|
@@ -23,13 +25,13 @@ class Runner
|
|
23
25
|
opts.generate = true
|
24
26
|
opts.manifest = manifest
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
cmd.on( '-l', '--list', "List Installed Templates" ) { opts.list = true }
|
28
30
|
|
29
31
|
cmd.on( '-c', '--config PATH', "Configuration Path (default is #{opts.config_path})" ) do |path|
|
30
32
|
opts.config_path = path
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
cmd.on( '-o', '--output PATH', "Output Path (default is #{opts.output_path})" ) { |path| opts.output_path = path }
|
34
36
|
|
35
37
|
cmd.on( '-v', '--version', "Show version" ) do
|
@@ -65,7 +67,7 @@ Examples:
|
|
65
67
|
|
66
68
|
Further information:
|
67
69
|
http://geraldb.github.com/pakman
|
68
|
-
|
70
|
+
|
69
71
|
EOS
|
70
72
|
exit
|
71
73
|
end
|
@@ -88,4 +90,4 @@ EOS
|
|
88
90
|
end # method run
|
89
91
|
|
90
92
|
end # class Runner
|
91
|
-
end # module Pakman
|
93
|
+
end # module Pakman
|
data/lib/pakman/copier.rb
CHANGED
@@ -1,19 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Copier
|
4
6
|
|
5
7
|
include LogUtils::Logging
|
6
8
|
|
7
|
-
### todo/fix:
|
8
|
-
# remove logger from c'tor
|
9
|
-
# use logutils instead
|
10
|
-
|
11
|
-
def initialize( old_logger_do_not_use=nil )
|
12
|
-
if old_logger_do_not_use != nil
|
13
|
-
puts "*** depreciated API call [Pakman::Copier.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
|
18
10
|
def copy_pak( manifestsrc, pakpath )
|
19
11
|
|
@@ -37,13 +29,13 @@ class Copier
|
|
37
29
|
|
38
30
|
logger.debug "destfull=>#{destfull}<"
|
39
31
|
logger.debug "destpath=>#{destpath}<"
|
40
|
-
|
32
|
+
|
41
33
|
puts " Copying to #{dest} from #{source}..."
|
42
34
|
FileUtils.copy( source, destfull )
|
43
35
|
end
|
44
|
-
|
36
|
+
|
45
37
|
puts "Done (in #{Time.now-start} s)."
|
46
38
|
end # method copy_pak
|
47
39
|
|
48
40
|
end # class Copier
|
49
|
-
end # module Pakman
|
41
|
+
end # module Pakman
|
data/lib/pakman/erb/template.rb
CHANGED
@@ -6,10 +6,10 @@ class ErbTemplate
|
|
6
6
|
|
7
7
|
def self.from_file( path )
|
8
8
|
puts " Loading template (from file) >#{path}<..."
|
9
|
-
text = File.
|
9
|
+
text = File.open( path, 'r:bom|utf-8' ).read ## note: assume utf8
|
10
10
|
self.new( text, path: path ) ## note: pass along path as an option
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def self.from_string( text ) ### use parse as alias - why?? why not??
|
14
14
|
self.new( text )
|
15
15
|
end
|
data/lib/pakman/erb/templater.rb
CHANGED
@@ -10,21 +10,11 @@ class Templater
|
|
10
10
|
|
11
11
|
include LogUtils::Logging
|
12
12
|
|
13
|
-
### todo/fix:
|
14
|
-
# remove logger from c'tor
|
15
|
-
# use logutils instead
|
16
|
-
|
17
|
-
def initialize( old_logger_do_not_use=nil )
|
18
|
-
if old_logger_do_not_use != nil
|
19
|
-
puts "*** depreciated API call [Pakman::Templater.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
13
|
|
24
14
|
def merge_pak( manifestsrc, pakpath, binding, name )
|
25
|
-
|
15
|
+
|
26
16
|
start = Time.now
|
27
|
-
|
17
|
+
|
28
18
|
pakname = Pakman.pakname_from_file( manifestsrc )
|
29
19
|
|
30
20
|
puts "Merging template pack '#{pakname}'"
|
@@ -35,11 +25,11 @@ class Templater
|
|
35
25
|
manifest.each do |entry|
|
36
26
|
dest = entry[0]
|
37
27
|
source = entry[1]
|
38
|
-
|
28
|
+
|
39
29
|
if dest =~ /__file__/ # replace w/ name
|
40
30
|
dest = dest.gsub( '__file__', name )
|
41
31
|
end
|
42
|
-
|
32
|
+
|
43
33
|
# get full (absolute) path and make sure path exists
|
44
34
|
destfull = File.expand_path( dest, pakpath )
|
45
35
|
destpath = File.dirname( destfull )
|
@@ -47,21 +37,21 @@ class Templater
|
|
47
37
|
|
48
38
|
logger.debug "destfull=>#{destfull}<"
|
49
39
|
logger.debug "destpath=>#{destpath}<"
|
50
|
-
|
40
|
+
|
51
41
|
if source =~ /\.erb\.|.erb$/
|
52
42
|
puts " Merging to #{dest}..."
|
53
43
|
|
54
|
-
out = File.new( destfull, 'w
|
44
|
+
out = File.new( destfull, 'w+:utf-8' ) ## note: use utf8 (by default)
|
55
45
|
out << ErbTemplate.from_file( source ).render( binding )
|
56
46
|
out.flush
|
57
47
|
out.close
|
58
48
|
else
|
59
49
|
puts " Copying to #{dest} from #{source}..."
|
60
|
-
|
50
|
+
|
61
51
|
FileUtils.copy( source, destfull )
|
62
52
|
end
|
63
53
|
end # each entry in manifest
|
64
|
-
|
54
|
+
|
65
55
|
puts "Done (in #{Time.now-start} s)."
|
66
56
|
end # method merge_pak
|
67
57
|
|
data/lib/pakman/fetcher.rb
CHANGED
@@ -1,27 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Fetcher
|
4
6
|
|
5
7
|
include LogUtils::Logging
|
6
8
|
|
7
|
-
### todo/fix:
|
8
|
-
# remove logger from c'tor
|
9
|
-
# use logutils instead
|
10
|
-
|
11
|
-
def initialize( old_logger_do_not_use=nil )
|
12
|
-
if old_logger_do_not_use != nil
|
13
|
-
puts "*** depreciated API call [Pakman::Fetcher.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
14
|
-
end
|
15
|
-
end
|
16
9
|
|
17
10
|
def fetch_pak( manifestsrc, pakpath )
|
18
11
|
|
19
12
|
start = Time.now
|
20
13
|
|
21
14
|
uri = URI.parse( manifestsrc )
|
22
|
-
|
15
|
+
|
23
16
|
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
|
24
|
-
|
17
|
+
|
25
18
|
dirname = File.dirname( uri.path )
|
26
19
|
filename = File.basename( uri.path ) # e.g. fullerscreen.txt (with extension)
|
27
20
|
|
@@ -40,7 +33,7 @@ class Fetcher
|
|
40
33
|
puts "Fetching template pack '#{pakname}'"
|
41
34
|
puts " from '#{dlbase}'"
|
42
35
|
puts " saving to '#{pakpath}'"
|
43
|
-
|
36
|
+
|
44
37
|
# step 1: download manifest
|
45
38
|
manifestdest = "#{pakpath}/#{filename}"
|
46
39
|
|
@@ -50,7 +43,7 @@ class Fetcher
|
|
50
43
|
|
51
44
|
## todo: change back to load_file_core after deprecated api got removed
|
52
45
|
manifest = Manifest.load_file_core_v2( manifestdest )
|
53
|
-
|
46
|
+
|
54
47
|
# step 2: download files & templates listed in manifest
|
55
48
|
manifest.each do |entry|
|
56
49
|
source = entry[1]
|
@@ -64,7 +57,7 @@ class Fetcher
|
|
64
57
|
logger.debug "destpath=>#{destpath}<"
|
65
58
|
|
66
59
|
sourcefull = "#{dlbase}/#{source}"
|
67
|
-
|
60
|
+
|
68
61
|
if source =~ /\.erb\.|.erb$/
|
69
62
|
puts " Downloading template '#{source}'..."
|
70
63
|
else
|
@@ -72,7 +65,7 @@ class Fetcher
|
|
72
65
|
end
|
73
66
|
|
74
67
|
fetch_file( sourcefull, destfull )
|
75
|
-
end
|
68
|
+
end
|
76
69
|
puts "Done (in #{Time.now-start} s)."
|
77
70
|
end # method fetch_pak
|
78
71
|
|
@@ -81,9 +74,9 @@ private
|
|
81
74
|
def fetch_file( src, dest )
|
82
75
|
## note: code moved to its own gem, that is, fetcher
|
83
76
|
## see https://github.com/geraldb/fetcher
|
84
|
-
|
77
|
+
|
85
78
|
::Fetcher::Worker.new.copy( src, dest )
|
86
79
|
end
|
87
80
|
|
88
81
|
end # class Fetcher
|
89
|
-
end # module Pakman
|
82
|
+
end # module Pakman
|
data/lib/pakman/finder.rb
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pakman
|
2
4
|
|
3
5
|
class Finder
|
4
6
|
|
5
7
|
include LogUtils::Logging
|
6
8
|
|
7
|
-
### todo/fix:
|
8
|
-
# remove logger from c'tor
|
9
|
-
# use logutils instead
|
10
|
-
|
11
|
-
def initialize( old_logger_do_not_use=nil )
|
12
|
-
if old_logger_do_not_use != nil
|
13
|
-
puts "*** depreciated API call [Pakman::Finder.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
14
|
-
end
|
15
|
-
end
|
16
9
|
|
17
10
|
def find_manifests( patterns, excludes=[] )
|
18
11
|
manifests = []
|
19
|
-
|
12
|
+
|
20
13
|
patterns.each do |pattern|
|
21
14
|
pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
|
22
15
|
logger.debug "Checking >#{pattern}<"
|
@@ -27,20 +20,20 @@ class Finder
|
|
27
20
|
else
|
28
21
|
unless exclude?( file, excludes ) # check for excludes; skip if excluded
|
29
22
|
logger.debug " Adding match >#{file}<"
|
30
|
-
|
23
|
+
|
31
24
|
## todo/fix:
|
32
25
|
# array first entry - downcase and gsub('.txt','') ??
|
33
26
|
# use Pakman.pakname_from_file()
|
34
|
-
|
27
|
+
|
35
28
|
manifests << [ File.basename( file ), file ]
|
36
29
|
end
|
37
30
|
end
|
38
31
|
end
|
39
32
|
end
|
40
|
-
|
33
|
+
|
41
34
|
manifests
|
42
35
|
end
|
43
|
-
|
36
|
+
|
44
37
|
private
|
45
38
|
def exclude?( file, excludes )
|
46
39
|
excludes.each do |pattern|
|
@@ -54,4 +47,4 @@ private
|
|
54
47
|
end
|
55
48
|
|
56
49
|
end # class Finder
|
57
|
-
end # module Pakman
|
50
|
+
end # module Pakman
|
@@ -7,10 +7,10 @@ class LiquidTemplate
|
|
7
7
|
|
8
8
|
def self.from_file( path )
|
9
9
|
puts " Loading template (from file) >#{path}<..."
|
10
|
-
text = File.
|
10
|
+
text = File.open( path, 'r:bom|utf-8' ).read ## note: assume utf8
|
11
11
|
self.new( text, path: path ) ## note: pass along path as an option
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def self.from_string( text ) ### use parse as alias - why?? why not??
|
15
15
|
self.new( text )
|
16
16
|
end
|
@@ -22,13 +22,22 @@ class LiquidTemplate
|
|
22
22
|
def render( hash )
|
23
23
|
## note: hash keys MUST be strings (not symbols) e.g. 'name' => 'Toby'
|
24
24
|
## pp hash
|
25
|
-
@template.render( hash )
|
25
|
+
res = @template.render( hash, { strict_variables: true, strict_filters: true } )
|
26
|
+
|
27
|
+
###
|
28
|
+
## issue warnings/errors if present
|
29
|
+
errors = @template.errors
|
30
|
+
if errors.size > 0
|
31
|
+
puts "!! WARN - #{errors.size} liquid error(s) when rendering template:"
|
32
|
+
pp errors
|
33
|
+
end
|
34
|
+
|
35
|
+
res
|
26
36
|
end
|
27
37
|
|
28
38
|
end # class LiquidTemplate
|
29
39
|
|
30
40
|
|
31
|
-
|
32
41
|
#########################
|
33
42
|
## convenience helper for pages (with headers/front matter)
|
34
43
|
|
@@ -39,7 +48,7 @@ class LiquidPageTemplate
|
|
39
48
|
page = Page.from_file( path ) ## use/todo: use read utf8 - why? why not??
|
40
49
|
self.new( page.contents, path: path ) ## note: pass along path as an option
|
41
50
|
end
|
42
|
-
|
51
|
+
|
43
52
|
def self.from_string( text ) ### use parse as alias - why?? why not??
|
44
53
|
## todo: (auto)-add headers as page.title etc. -- why? why not??
|
45
54
|
page = Page.from_string( text )
|
@@ -49,7 +58,7 @@ class LiquidPageTemplate
|
|
49
58
|
def initialize( text, opts={} )
|
50
59
|
@template = LiquidTemplate.new( text, opts )
|
51
60
|
end
|
52
|
-
|
61
|
+
|
53
62
|
def render( hash )
|
54
63
|
@template.render( hash )
|
55
64
|
end
|
@@ -58,4 +67,3 @@ end ## class LiquidPageTemplate
|
|
58
67
|
|
59
68
|
|
60
69
|
end # module Pakman
|
61
|
-
|
@@ -23,9 +23,6 @@ class LiquidTemplater
|
|
23
23
|
REGEX_EXT = Regexp.new( "\\.(#{EXTS.join('|')})$", Regexp::IGNORECASE )
|
24
24
|
|
25
25
|
|
26
|
-
def initialize
|
27
|
-
end
|
28
|
-
|
29
26
|
## rename binding/hash to assigns or something more specific - why? why not?
|
30
27
|
def merge_pak( manifestsrc, pakpath, binding, name )
|
31
28
|
|
@@ -77,7 +74,7 @@ class LiquidTemplater
|
|
77
74
|
if source_page && source_page.headers?
|
78
75
|
puts " Bingo! Front matter (e.g. ---) found. Merging template to #{dest}..."
|
79
76
|
|
80
|
-
out = File.new( destfull, 'w
|
77
|
+
out = File.new( destfull, 'w+:utf-8' ) ## note: use utf8
|
81
78
|
## note: only pass along contents (not headers e.g. front matter for now)
|
82
79
|
## (auto-)add front matter headers as page.[xxx] - why? why not??
|
83
80
|
out << LiquidTemplate.from_string( source_page.contents ).render( binding )
|
data/lib/pakman/manifest.rb
CHANGED
@@ -6,19 +6,11 @@ class Manifest
|
|
6
6
|
|
7
7
|
include LogUtils::Logging
|
8
8
|
|
9
|
-
### todo/fix:
|
10
|
-
# remove logger from c'tor
|
11
|
-
# use logutils instead
|
12
|
-
|
13
|
-
def initialize( old_logger_do_not_use=nil )
|
14
|
-
if old_logger_do_not_use != nil
|
15
|
-
puts "*** depreciated API call [Pakman::Manifest.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
16
|
-
end
|
17
9
|
|
10
|
+
def initialize()
|
18
11
|
@manifest = []
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
14
|
def self.load_file_core( old_logger_do_not_use, path )
|
23
15
|
puts "*** depreciated API call [Pakman::Manifest.load_file_core] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
|
24
16
|
|
@@ -59,8 +51,8 @@ class Manifest
|
|
59
51
|
|
60
52
|
def load_file_core_worker( path )
|
61
53
|
@manifest = []
|
62
|
-
|
63
|
-
File.open( path ).readlines.each_with_index do |line,i|
|
54
|
+
|
55
|
+
File.open( path, 'r:bom|utf-8' ).readlines.each_with_index do |line,i|
|
64
56
|
case line
|
65
57
|
when /^\s*$/
|
66
58
|
# skip empty lines
|
@@ -69,10 +61,10 @@ class Manifest
|
|
69
61
|
else
|
70
62
|
logger.debug "line #{i+1}: #{line.strip}"
|
71
63
|
values = line.strip.split( /[ <,+]+/ )
|
72
|
-
|
64
|
+
|
73
65
|
# add source for shortcuts (assumes relative path; if not issue warning/error)
|
74
66
|
values << values[0] if values.size == 1
|
75
|
-
|
67
|
+
|
76
68
|
@manifest << values
|
77
69
|
end
|
78
70
|
end
|
@@ -80,10 +72,10 @@ class Manifest
|
|
80
72
|
|
81
73
|
def load_file_worker( path )
|
82
74
|
filename = path
|
83
|
-
|
84
|
-
puts " Loading template manifest #{filename}..."
|
75
|
+
|
76
|
+
puts " Loading template manifest #{filename}..."
|
85
77
|
load_file_core_worker( filename )
|
86
|
-
|
78
|
+
|
87
79
|
# post-processing
|
88
80
|
# normalize all source paths (1..-1) /make full path/add template dir
|
89
81
|
|
data/lib/pakman/page.rb
CHANGED
@@ -10,10 +10,10 @@ class Page
|
|
10
10
|
|
11
11
|
def self.from_file( path )
|
12
12
|
puts " Loading page (from file) >#{path}<..."
|
13
|
-
text = File.
|
13
|
+
text = File.open( path, 'r:bom|utf-8' ).read ## note: assume utf8
|
14
14
|
self.new( text, path: path ) ## note: pass along path as an option
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def self.from_string( text ) ### use parse as alias - why?? why not??
|
18
18
|
self.new( text )
|
19
19
|
end
|
@@ -48,9 +48,8 @@ class Page
|
|
48
48
|
else
|
49
49
|
@contents = text
|
50
50
|
@headers = nil
|
51
|
-
end
|
51
|
+
end
|
52
52
|
end
|
53
53
|
|
54
54
|
end # class Page
|
55
55
|
end # module Pakman
|
56
|
-
|
data/lib/pakman/utils.rb
CHANGED
data/lib/pakman/version.rb
CHANGED
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: 1.0.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:
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fetcher
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.16'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.16'
|
83
83
|
description: pakman - Template Pack Manager (incl. Embedded Ruby, Liquid, etc.)
|
84
84
|
email: wwwmake@googlegroups.com
|
85
85
|
executables:
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: '2.3'
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
155
|
- - ">="
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.2
|
160
|
+
rubygems_version: 2.5.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: pakman - Template Pack Manager (incl. Embedded Ruby, Liquid, etc.)
|