liquidoc 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9adb50baa6b3a7c4f31b2de0cc7888bdb69e798f
4
- data.tar.gz: '0392150cfd9c8a5b2ea35ac16116e1ae519bd874'
3
+ metadata.gz: a430c1aff6da069b98f775ec32e1e6b4392bd44b
4
+ data.tar.gz: 1b8b0d19f71c46709b4c6960f71567ab299c96a4
5
5
  SHA512:
6
- metadata.gz: 2762bc4215573e07f60bcc88d91c2fd2b62dc9995be94ac29b89fd96ec9f214d4135f6f7d66239b99acf3ee4fff57b21d3a599e54d14298073cd287ac4b96a95
7
- data.tar.gz: b0c252cbc74af8f56ffdd03718713a7a193d9da94caa110cc68abd5a7f58e917ea611031b939aaca8a456a370f8da3a3fc13e770605279a60dbad22fff681c84
6
+ metadata.gz: 541de3451669ef6a77cbc5c800baaa9d85f03033f660396eb0afaa6b694d3b803892d7daf7b5ad6479a7891f51d941313569e6147aea2d4a2bb5d5180c400180
7
+ data.tar.gz: 340ba705cce103d733002e9ddc02b3ae3bb1f86c32149bbe78cb2b574e015a1951bbfc4024c559f12dc1179eed0ddeda87c136aabf0d5e786915d1520935ee86
data/lib/liquidoc.rb CHANGED
@@ -7,6 +7,7 @@ require 'asciidoctor'
7
7
  require 'logger'
8
8
  require 'csv'
9
9
  require 'crack/xml'
10
+ require 'fileutils'
10
11
 
11
12
  # ===
12
13
  # Table of Contents
@@ -14,15 +15,15 @@ require 'crack/xml'
14
15
  #
15
16
  # 1. dependencies stack
16
17
  # 2. default settings
17
- # 3. general methods
18
- # 4. object classes
19
- # 5. action-specific methods
20
- # 5a. parse methods
21
- # 5b. migrate methods
22
- # 5c. render methods
23
- # 6. text manipulation
24
- # 7. command/option parser
25
- # 8. executive method calls
18
+ # 3. general procs def
19
+ # 4. object classes def
20
+ # 5. action-specific procs def
21
+ # 5a. parse procs def
22
+ # 5b. migrate procs def
23
+ # 5c. render procs def
24
+ # 6. text manipulation modules/classes def
25
+ # 7. command/option parser def
26
+ # 8. executive proc calls
26
27
 
27
28
  # ===
28
29
  # Default settings
@@ -33,7 +34,6 @@ require 'crack/xml'
33
34
  @configs_dir = @base_dir + '_configs'
34
35
  @templates_dir = @base_dir + '_templates/'
35
36
  @data_dir = @base_dir + '_data/'
36
- @output_dir = @base_dir + '_output/'
37
37
  @attributes_file_def = '_data/asciidoctor.yml'
38
38
  @attributes_file = @attributes_file_def
39
39
  @pdf_theme_file = 'theme/pdf-theme.yml'
@@ -48,7 +48,7 @@ require 'crack/xml'
48
48
  end
49
49
 
50
50
  # ===
51
- # Executive methods
51
+ # Executive procs
52
52
  # ===
53
53
 
54
54
  # Establish source, template, index, etc details for build jobs from a config file
@@ -84,7 +84,9 @@ def iterate_build cfg
84
84
  liquify(data, build.template, build.output) # perform the liquify operation
85
85
  end
86
86
  when "migrate"
87
- @logger.warn "Migrate actions not yet implemented."
87
+ inclusive = true
88
+ inclusive = step.options['inclusive'] if defined?(step.options['inclusive'])
89
+ copy_assets(step.source, step.target, inclusive)
88
90
  when "render"
89
91
  @logger.warn "Render actions not yet implemented."
90
92
  when "deploy"
@@ -182,6 +184,18 @@ class BuildConfigStep
182
184
  return @@step['data']
183
185
  end
184
186
 
187
+ def source
188
+ return @@step['source']
189
+ end
190
+
191
+ def target
192
+ return @@step['target']
193
+ end
194
+
195
+ def options
196
+ return @@step['options']
197
+ end
198
+
185
199
  def builds
186
200
  return @@step['builds']
187
201
  end
@@ -202,15 +216,14 @@ class Build
202
216
  def initialize build, type
203
217
  @@build = build
204
218
  @@type = type
205
- @@logger = Logger.new(STDOUT)
206
219
  required = []
207
220
  case type
208
221
  when "parse"
209
222
  required = ["template,output"]
210
- when "render"
211
- required = ["index,output"]
212
223
  when "migrate"
213
224
  required = ["source,target"]
225
+ when "render"
226
+ required = ["index,output"]
214
227
  end
215
228
  for req in required
216
229
  if (defined?(req)).nil?
@@ -231,14 +244,6 @@ class Build
231
244
  @@build['index']
232
245
  end
233
246
 
234
- def source
235
- @@build['source']
236
- end
237
-
238
- def target
239
- @@build['target']
240
- end
241
-
242
247
  end #class Build
243
248
 
244
249
  class DataSrc
@@ -305,9 +310,9 @@ class DataSrc
305
310
  end
306
311
 
307
312
  # ===
308
- # Action-specific methods
309
- #
310
- # PARSE-type build methods
313
+ # Action-specific procs
314
+ # ===
315
+ # PARSE-type build procs
311
316
  # ===
312
317
 
313
318
  # Pull in a semi-structured data file, converting contents to a Ruby hash
@@ -316,7 +321,7 @@ def ingest_data datasrc
316
321
  unless datasrc.is_a? Object
317
322
  raise "InvalidDataObject"
318
323
  end
319
- # This method should really begin here, once the data object is in order
324
+ # This proc should really begin here, once the datasrc object is in order
320
325
  case datasrc.type
321
326
  when "yml"
322
327
  begin
@@ -407,8 +412,9 @@ def liquify datasrc, template_file, output
407
412
  end
408
413
  unless output.downcase == "stdout"
409
414
  output_file = output
415
+ base_path = File.dirname(output)
410
416
  begin
411
- Dir.mkdir(@output_dir) unless File.exists?(@output_dir)
417
+ Dir.mkdir(base_path) unless File.exists?(base_path)
412
418
  File.open(output_file, 'w') { |file| file.write(rendered) } # saves file
413
419
  rescue Exception => ex
414
420
  @logger.error "Failed to save output.\n#{ex.class} #{ex.message}"
@@ -424,30 +430,36 @@ def liquify datasrc, template_file, output
424
430
  end
425
431
 
426
432
  # ===
427
- # MIGRATE-type methods
433
+ # MIGRATE-type procs
428
434
  # ===
429
435
 
430
- # Copy images and other assets into output dir for HTML operations
431
- def copy_assets src, dest
432
- if @recursive
433
- dest = "#{dest}/#{src}"
434
- recursively = "Recursively c"
435
- else
436
- recursively = "C"
437
- end
438
- @logger.debug "#{recursively}opying image assets to #{dest}"
436
+ # Copy images and other files into target dir
437
+ def copy_assets src, dest, inclusive=true
438
+ if File.file?(src) # for sources that are files
439
+ target_dir = File.dirname(dest)
440
+ else # if src is a directory
441
+ unless inclusive then src = src + "/." end
442
+ target_dir = dest
443
+ end
444
+ @logger.debug "Copying #{src} to #{dest}"
445
+ # puts "Dir name: " + File.dirname(dest)
446
+ # puts "Dir exists: " + File.exists?(File.dirname(dest)).to_s
439
447
  begin
440
- FileUtils.mkdir_p(dest) unless File.exists?(dest)
441
- FileUtils.cp_r(src, dest)
448
+ FileUtils.mkdir_p(dest) unless File.exists?(target_dir)
449
+ if File.directory?(src)
450
+ FileUtils.cp_r(src, dest)
451
+ else
452
+ FileUtils.cp(src, dest)
453
+ end
454
+ @logger.info "Copied assets."
442
455
  rescue Exception => ex
443
456
  @logger.warn "Problem while copying assets. #{ex.message}"
444
- return
457
+ raise
445
458
  end
446
- @logger.debug "\s\s#{recursively}opied: #{src} --> #{dest}/#{src}"
447
459
  end
448
460
 
449
461
  # ===
450
- # RENDER-type methods
462
+ # RENDER-type procs
451
463
  # ===
452
464
 
453
465
  # Gather attributes from a fixed attributes file
@@ -1,3 +1,3 @@
1
1
  module Liquidoc
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dominick