semi 0.4.0 → 0.5.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: 55b3140197955790078f136079197dc4aeaf73dc
4
- data.tar.gz: fe2e1b04e130ddff9a3827d878d8a419799d37ed
3
+ metadata.gz: b8900c56654ccdb2e841d4f73f7581aab3fa9e1b
4
+ data.tar.gz: a6ddfce5bccc3ce13570dc4b12f8e6b9027cd4ac
5
5
  SHA512:
6
- metadata.gz: 82141279b74989cd5d7d7db3e56b4a917edee58e57196756d377f717e2e7ee601609683f5c3a6233d9c110f4e027ff9399a6951be54b2ddb87bf40fb4c4d4c90
7
- data.tar.gz: 1cd20d26abb58aaf4577aac85d4b089616182a766f5000ce291b92231c3ab2e20c224892d6a4a512146df721494870db5f1edd071c8029c270e490dd6214dce3
6
+ metadata.gz: c72cfef1461dae9bc15bc4751274eb3c32ef7580143b146ecd22d0986258db71e3c72fd894f983dc76ce7caefa141e4513529184d9c99bf753de71e494227ae7
7
+ data.tar.gz: 05d193e0858b084f1b20946dea0168a5d8cd7387eabb985f9099e1df452f30ca7858f0176ebbfd3ba7fffae6a2016a4cc1b204c920f505312b7f9415a98c4bf2
data/lib/semi/config.rb CHANGED
@@ -39,5 +39,27 @@ module Semi
39
39
 
40
40
  return data
41
41
  end
42
+
43
+ def process_file(filename, dictionary)
44
+ if Dir.exist? filename
45
+ Dir.glob("#{filename}/*").each do |file|
46
+ process_file(file, dictionary)
47
+ end
48
+ elsif File.exist? filename
49
+ # Read the file and apply @dictionary values
50
+ contents = File.open(filename, 'r') do |fp|
51
+ renderer = ERB.new(fp.readlines.join, nil, '%<>-')
52
+ renderer.result(dictionary.instance_eval {binding})
53
+ end
54
+
55
+ # Reopen the file and write the rendered contents
56
+ File.open(filename, 'w') do |fp|
57
+ fp.write(contents)
58
+ end
59
+ else
60
+ raise RuntimeError, "Unable to find file or directory named #{filename}"
61
+ end
62
+ end
63
+
42
64
  end
43
65
  end
data/lib/semi/driver.rb CHANGED
@@ -42,22 +42,11 @@ module Semi
42
42
  # Process the config files and generate final versions
43
43
  @config.files.each do |file|
44
44
  # Read the template file and render
45
- if File.exist? file
46
- contents = File.open(file, 'r') do |fp|
47
- renderer = ERB.new(fp.readlines.join, nil, '%<>-')
48
- renderer.result(@dictionary.instance_eval {binding})
49
- end
50
-
51
- # Reopen the file and write the rendered contents
52
- File.open(file, 'w') do |fp|
53
- fp.write(contents)
54
- end
55
- end
45
+ @config.process_file(file, @dictionary)
56
46
  end
57
47
 
58
48
  # Check for pre-defined commands
59
49
  args = ARGV
60
- puts args.inspect
61
50
  if args.count == 0 and @config.commands.include? 'default'
62
51
  args = @config.commands['default']
63
52
  elsif args.count == 1 and args[0] == 'help'
@@ -76,7 +65,7 @@ module Semi
76
65
 
77
66
 
78
67
  # Execute the command line
79
- puts "Executing: #{args}"
68
+ #puts "Executing: #{args}"
80
69
  exec([args].flatten.join(' '))
81
70
  end
82
71
 
data/lib/semi/variable.rb CHANGED
@@ -20,7 +20,7 @@ module Semi
20
20
 
21
21
  def self.import(val, hints=nil)
22
22
  # If hints have been supplied, try to create from them
23
- if not hints.nil?
23
+ unless hints.nil?
24
24
  hints = [hints].flatten.select {|h| @@var_types.include? h }
25
25
  if hints.count > 0
26
26
  return @@var_types[hints[0]].new(val)
data/lib/semi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Semi
2
- version = '0.4.0'
2
+ version = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerard Hickey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake