kisko-suits 0.2.1 → 0.2.2

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: 5c6d515b90c12063e6344c824ca0f0cfc56c23e7
4
- data.tar.gz: 82bb230b2757dda5da601eb5cfc0bc1ad84b5041
3
+ metadata.gz: bca5121f773054ddae30e80e7ac5fc600e51dd0b
4
+ data.tar.gz: 4d663b82ac1b9e51cd51654fa52ee653e9f46150
5
5
  SHA512:
6
- metadata.gz: 3539633e091ec51d82ff676782ccb7ee8fdc4b8bd714d4417642fe52c5f1b5ce592b36b03e014b7dd67f5291788634a007779910763a0918ded4565349923311
7
- data.tar.gz: dcc417989bf6baf8557730208e7f57658df75e6f2cc843076156b79b0cd359c7052ef0d16c896bc7c09fdcf176da56a8844625952642e12b5069d16d1695cfb7
6
+ metadata.gz: '069f74c8bc91e15021fcb55abda9aa6af79921e5800f285e5a2b876d9367918dc4c3aa01d82a54d447aae38466a238127451e0cca5d2285ac9111392d6124e17'
7
+ data.tar.gz: a6b263b27355379ed9a31202ba32104bfd9261e44b5e789badb620125b9b5562436d0105bddcce4a682beda3009c454b969e4cd9ee0371fd7b20e8731080eccc
@@ -1,5 +1,5 @@
1
1
  require "optparse"
2
- require 'filewatcher'
2
+ require "filewatcher"
3
3
 
4
4
  require_relative "kisko-suits/application"
5
5
  require_relative "kisko-suits/compiler"
@@ -5,21 +5,17 @@ module KiskoSuits
5
5
  end
6
6
 
7
7
  def run
8
- if @files.empty? || @files.size > 1 || !@files.first.include?(".suits")
8
+ if !suits_file_passed?
9
9
  abort "Usage: 'kisko-suits my-presentation.md.suits'\n\nOr start watching file with: 'kisko-suits -w my-presentation.md.suits'"
10
10
  else
11
11
  if @params[:watch]
12
12
  on_update = ->(filename) {
13
- compiler = KiskoSuits::Compiler.new(@files.first)
14
- compiler.render
15
- puts "Processed files and compiled '#{compiler.output_filename}'"
13
+ compiler = compile_and_render
16
14
  compiler.included_filenames
17
15
  }
18
16
  KiskoSuits::Watcher.new(@files.first, on_update).start
19
17
  else
20
- compiler = KiskoSuits::Compiler.new(@files.first)
21
- compiler.render
22
- puts "Processed files and compiled '#{compiler.output_filename}'"
18
+ compile_and_render
23
19
  end
24
20
  end
25
21
  end
@@ -33,5 +29,16 @@ module KiskoSuits
33
29
 
34
30
  [params, files]
35
31
  end
32
+
33
+ def suits_file_passed?
34
+ @files.size == 1 && @files.first.include?(".suits")
35
+ end
36
+
37
+ def compile_and_render
38
+ compiler = KiskoSuits::Compiler.new(@files.first)
39
+ compiler.render
40
+ puts "Processed files and compiled '#{compiler.output_filename}'"
41
+ compiler
42
+ end
36
43
  end
37
44
  end
@@ -32,27 +32,12 @@ module KiskoSuits
32
32
  # It's a comment
33
33
  ""
34
34
  elsif line.match(/\s*\$\$\w+\s?=/)
35
- variable_name, variable_value = line.split("=").map(&:strip)
36
- @variables[variable_name] = variable_value
37
- ""
35
+ set_variable(line)
38
36
  elsif match = line.match(/\s*include:\s*([\w\.\/]+)/)
39
37
  included_path = "#{root_dir}/#{match[1]}"
40
- if File.exists?(included_path)
41
- @included_filenames << included_path
42
-
43
- File.foreach(included_path).map { |included_line|
44
- process_line(File.dirname(included_path), included_line)
45
- }.join
46
- else
47
- puts "Include #{included_path} can't be found"
48
- ""
49
- end
38
+ include_file(included_path)
50
39
  else
51
- @variables.each do |variable_name, variable_value|
52
- line.gsub!(Regexp.new(Regexp.escape(variable_name)), variable_value)
53
- end
54
-
55
- line
40
+ substitute_variables(line)
56
41
  end
57
42
  end
58
43
 
@@ -63,5 +48,32 @@ module KiskoSuits
63
48
 
64
49
  File.open(@output_filename, 'w', &block)
65
50
  end
51
+
52
+ def set_variable(line)
53
+ variable_name, variable_value = line.split("=").map(&:strip)
54
+ @variables[variable_name] = variable_value
55
+ ""
56
+ end
57
+
58
+ def include_file(included_path)
59
+ if File.exists?(included_path)
60
+ @included_filenames << included_path
61
+
62
+ File.foreach(included_path).map { |included_line|
63
+ process_line(File.dirname(included_path), included_line)
64
+ }.join
65
+ else
66
+ puts "Include #{included_path} can't be found"
67
+ ""
68
+ end
69
+ end
70
+
71
+ def substitute_variables(line)
72
+ @variables.each do |variable_name, variable_value|
73
+ line = line.gsub(Regexp.new(Regexp.escape(variable_name)), variable_value)
74
+ end
75
+
76
+ line
77
+ end
66
78
  end
67
79
  end
@@ -1,3 +1,3 @@
1
1
  module KiskoSuits
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kisko-suits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Akonniemi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filewatcher
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement