kisko-suits 0.2.1 → 0.3.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
- SHA1:
3
- metadata.gz: 5c6d515b90c12063e6344c824ca0f0cfc56c23e7
4
- data.tar.gz: 82bb230b2757dda5da601eb5cfc0bc1ad84b5041
2
+ SHA256:
3
+ metadata.gz: 64311c554df4ff27cf625648dd7584ef813edac27927a18974da796e9adc66b7
4
+ data.tar.gz: e506f0a895b3a862ec043221357d981ec4bb0aaaa12c71d59b7135aaf960611e
5
5
  SHA512:
6
- metadata.gz: 3539633e091ec51d82ff676782ccb7ee8fdc4b8bd714d4417642fe52c5f1b5ce592b36b03e014b7dd67f5291788634a007779910763a0918ded4565349923311
7
- data.tar.gz: dcc417989bf6baf8557730208e7f57658df75e6f2cc843076156b79b0cd359c7052ef0d16c896bc7c09fdcf176da56a8844625952642e12b5069d16d1695cfb7
6
+ metadata.gz: 13be24948a51f1c543a8dc61d35a68937df17d4a47a306470c6d24c21ee791fc7a689b69505c83210eb70a03fb8c717c15ef5cb699f940129a6697bc7652be10
7
+ data.tar.gz: d4a7c0fa3d6a2d7dbf85128db80ec7111bfad2ccc9b798dd1d56f8aad140eedb2c947ab37e704e4bce31ee3b48e2b2433b9291f6935f45faecb33564956a4f62
@@ -0,0 +1,4 @@
1
+ $$my_variable = Variable content
2
+ $$another_variable= More $$my_variable
3
+
4
+ Normal content $$another_variable
@@ -0,0 +1,2 @@
1
+
2
+ Normal content More Variable content
@@ -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
@@ -16,7 +16,7 @@ module KiskoSuits
16
16
  @included_filenames.clear
17
17
  @variables.clear
18
18
 
19
- abort "Suits file '#{path}' not found" unless File.exists?(path)
19
+ abort "Suits file '#{path}' not found" unless File.exist?(path)
20
20
 
21
21
  open_output_file do |output|
22
22
  File.foreach(path).each do |line|
@@ -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.exist?(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.3.0"
3
3
  end
data/lib/kisko-suits.rb CHANGED
@@ -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"
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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Akonniemi
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2024-07-24 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
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 13.2.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 13.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: gem-release
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.2.2
41
69
  description: This app was meant to compile markdown partials as one document for our
42
70
  sales team using Deckset for Mac
43
71
  email:
@@ -48,7 +76,6 @@ extensions: []
48
76
  extra_rdoc_files: []
49
77
  files:
50
78
  - README.md
51
- - bin/kisko-suits
52
79
  - data/fail.md.suits
53
80
  - data/folder/proot.md
54
81
  - data/folder/what.md
@@ -56,8 +83,11 @@ files:
56
83
  - data/preso.md_proper
57
84
  - data/preso_with_variables.md.suits
58
85
  - data/preso_with_variables.md_proper
86
+ - data/preso_with_variables_within_variables.md.suits
87
+ - data/preso_with_variables_within_variables.md_proper
59
88
  - data/short_test.md
60
89
  - data/test.md
90
+ - exe/kisko-suits
61
91
  - lib/kisko-suits.rb
62
92
  - lib/kisko-suits/application.rb
63
93
  - lib/kisko-suits/compiler.rb
@@ -67,7 +97,7 @@ homepage: http://github.com/kiskolabs/kisko-suits
67
97
  licenses:
68
98
  - MIT
69
99
  metadata: {}
70
- post_install_message:
100
+ post_install_message:
71
101
  rdoc_options: []
72
102
  require_paths:
73
103
  - lib
@@ -82,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
112
  - !ruby/object:Gem::Version
83
113
  version: 1.3.6
84
114
  requirements: []
85
- rubyforge_project: kisko-suits
86
- rubygems_version: 2.6.13
87
- signing_key:
115
+ rubygems_version: 3.5.16
116
+ signing_key:
88
117
  specification_version: 4
89
118
  summary: Application to compile files as one
90
119
  test_files: []
File without changes