kisko-suits 0.1.0 → 0.2.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: 63be19a0310c7d726082af6f17ab2baa8d9eba85
4
- data.tar.gz: 12146d0d806620d5531d70d3514bb4239f3868de
3
+ metadata.gz: 9d2cb5fe50c92941b976d082594872a5a557d725
4
+ data.tar.gz: 873914fa82a5c3e2e69814c52d0657ba7de2ef77
5
5
  SHA512:
6
- metadata.gz: d62d754d11abbeae557b62d359aaa70f3549086e013f1d3bb44282b5bf85703d3374a9639b41080fc9ac50fab3ef66bdd9f12657c7991997bd99e101de770605
7
- data.tar.gz: f165caa53796b93519de65d94357dd39caccae8cb8cb1bfbb5ed92db8c69d2b4f0dfb0135ea1f0be1d4d96a137cf2564e3ca3ce209f737b0f6481c2f59cc8bf8
6
+ metadata.gz: 1be5d150c0b89022084aa94adba17456f34af8b40d4d7ed34b18cf04b83a9becb8f5dd6fce3fd9eae633eceb7b723ddd044a14512329beeb1f5c9c80e92b638f
7
+ data.tar.gz: 7ecb6eff92fa4b61d21b66931be8f6889ee42bebd09777a2c3a7b373c77faa17610f7e8608a1010002e813286693aece25d06c06ad10223085bb270b62ae0e96
data/README.md CHANGED
@@ -25,12 +25,13 @@ my-presentation.md.suits contains normal Markdown content and included portions
25
25
  ```
26
26
  # Presentation #1
27
27
 
28
+ $$custom_variables = amazing custom variables
28
29
  include: introduction.md
29
30
  include: company/basic_information.md
30
31
 
31
32
  ## Custom extra information
32
33
 
33
- All Markdown formatting **works**.
34
+ All Markdown formatting **works** and you can use $$custom_variables to save time.
34
35
 
35
36
  include: project-details.md
36
37
  include: CVs/antti.md
@@ -0,0 +1,8 @@
1
+ $$my_variable = Variable content
2
+ $$another_variable=Kisko
3
+
4
+ Normal content $$another_variable
5
+
6
+ $$my_variable
7
+
8
+ include: short_test.md
@@ -0,0 +1,6 @@
1
+
2
+ Normal content Kisko
3
+
4
+ Variable content
5
+
6
+ Short test file Kisko.
@@ -0,0 +1 @@
1
+ Short test file $$another_variable.
@@ -9,15 +9,17 @@ module KiskoSuits
9
9
  @output_filename = nil
10
10
 
11
11
  @included_filenames = Set.new
12
+ @variables = {}
12
13
  end
13
14
 
14
15
  def render
15
16
  @included_filenames.clear
17
+ @variables.clear
16
18
 
17
19
  abort "Suits file '#{path}' not found" unless File.exists?(path)
18
20
 
19
21
  open_output_file do |output|
20
- File.foreach(path) do |line|
22
+ File.foreach(path).each do |line|
21
23
  output.write(process_line(File.dirname(path), line))
22
24
  end
23
25
  end
@@ -28,6 +30,11 @@ module KiskoSuits
28
30
  def process_line(root_dir, line)
29
31
  if line.start_with?('[//]:')
30
32
  # It's a comment
33
+ ""
34
+ elsif line.match(/\s*\$\$\w+\s?=/)
35
+ variable_name, variable_value = line.split("=").map(&:strip)
36
+ @variables[variable_name] = variable_value
37
+ ""
31
38
  elsif match = line.match(/\s*include:\s*([\w\.\/]+)/)
32
39
  included_path = "#{root_dir}/#{match[1]}"
33
40
  if File.exists?(included_path)
@@ -41,6 +48,10 @@ module KiskoSuits
41
48
  ""
42
49
  end
43
50
  else
51
+ @variables.each do |variable_name, variable_value|
52
+ line.gsub!(Regexp.new(Regexp.escape(variable_name)), variable_value)
53
+ end
54
+
44
55
  line
45
56
  end
46
57
  end
@@ -1,3 +1,3 @@
1
1
  module KiskoSuits
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
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.1.0
4
+ version: 0.2.0
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-09-28 00:00:00.000000000 Z
11
+ date: 2017-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filewatcher
@@ -54,6 +54,9 @@ files:
54
54
  - data/folder/what.md
55
55
  - data/preso.md.suits
56
56
  - data/preso.md_proper
57
+ - data/preso_with_variables.md.suits
58
+ - data/preso_with_variables.md_proper
59
+ - data/short_test.md
57
60
  - data/test.md
58
61
  - lib/kisko-suits.rb
59
62
  - lib/kisko-suits/application.rb