kisko-suits 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ddeff1177740ae116a13145ca29d72c4331a8e1
4
+ data.tar.gz: ded9ccdf907cdb1eae3698f69e3ebff92160f2ed
5
+ SHA512:
6
+ metadata.gz: d89ef4eb536e4b5f3dba7d067db56e74fe50e0a96f8af0e6dcf8e7907e680b1f150754c3616c9e09496c0f4198eb7ec5527287605f5836b87f9e1cd93d0500ba
7
+ data.tar.gz: 831be14962e7d791fb9e6a08fb93deb00ddb55b57b749b4dcefb56f8b7481f30f53fff3b0db65cb7adef268424612e54290916296bce98e8018d05648e198dd4
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ ## Application to compile files as one
2
+
3
+ This app was meant to compile a single Markdown file by including multiple files to be used by our sales team using Deckset for Mac.
4
+
5
+ We create sales presentations and such using [Deckset](http://www.decksetapp.com/). There are a lot of information on those documents that we need to use again and again. Our only solution was to copy and paste those slides to the new presentation each time we started to create one.
6
+
7
+ With Kisko Suits we can create re-usable slides (for example company intro, CVs, contact information) and include those to a compiled presentation. Kisko Suits will update the master Markdown file everytime an included slide is changed/added/removed.
8
+
9
+ ### Installation
10
+
11
+ Everything you need is already installed on every Apple computer. Just run:
12
+
13
+ ```gem install kisko-suits```
14
+
15
+ ### Usage
16
+
17
+ Create a config file (.suits file) for your presentation:
18
+
19
+ File name 'my-presentation.md.suits' would cause kisko-suits to create a Markdown file my-presentation.md
20
+
21
+ my-presentation.md.suits contains normal Markdown content and included portions (using **relative** paths). For example:
22
+
23
+ ```
24
+ # Presentation #1
25
+
26
+ include: introduction.md
27
+ include: company/basic_information.md
28
+
29
+ ## Custom extra information
30
+
31
+ All Markdown formatting **works**.
32
+
33
+ include: project-details.md
34
+ include: CVs/antti.md
35
+ include: CVs/vesa.md
36
+ include: contact_information.md
37
+ ```
38
+
39
+ The included portions will be merged to the document and the end result will be saved as my-presentation.md when you run:
40
+
41
+ ```kisko-suits my-presentation.md.suits```
42
+
43
+ Super simple.
44
+
45
+ If you want to update the output file when any of the included portions in the config are updated, just use the -w switch:
46
+
47
+ ```kisko-suits -w my-presentation.md.suits```
48
+
49
+ This makes it fast to work with the files and see the end result in Deckset.
50
+
51
+ ### CI Build Status
52
+
53
+ ![](https://magnum.travis-ci.com/kiskolabs/kisko-suits.svg?token=DwseF79747iq46syMYaD)
data/bin/kisko-suits ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/kisko-suits"
4
+
5
+ begin
6
+ KiskoSuits::Application.new(ARGV).run
7
+ rescue Errno::ENOENT => err
8
+ abort "kisko-suits: #{err.message}"
9
+ rescue OptionParser::InvalidOption => err
10
+ abort "kisko-suits: #{err.message}\n"
11
+ end
@@ -0,0 +1,2 @@
1
+ include: fail.md
2
+ include: asdas/asdas.md
@@ -0,0 +1,5 @@
1
+ include: what.md
2
+
3
+ adsadas
4
+
5
+ asdasd
@@ -0,0 +1 @@
1
+ what
@@ -0,0 +1,5 @@
1
+ include: test.md
2
+
3
+ extra content
4
+
5
+ include: folder/proot.md
@@ -0,0 +1,31 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
2
+
3
+ asdasd
4
+
5
+ asdasd
6
+
7
+ sds
8
+
9
+ asds
10
+
11
+ asd
12
+ asds
13
+
14
+
15
+ asd
16
+
17
+ asd
18
+
19
+ asd
20
+
21
+ sas
22
+
23
+ end of file
24
+
25
+ extra content
26
+
27
+ what
28
+
29
+ adsadas
30
+
31
+ asdasd
data/data/test.md ADDED
@@ -0,0 +1,23 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
2
+
3
+ asdasd
4
+
5
+ asdasd
6
+
7
+ sds
8
+
9
+ asds
10
+
11
+ asd
12
+ asds
13
+
14
+
15
+ asd
16
+
17
+ asd
18
+
19
+ asd
20
+
21
+ sas
22
+
23
+ end of file
@@ -0,0 +1,6 @@
1
+ require "optparse"
2
+ require 'filewatcher'
3
+
4
+ require_relative "kisko-suits/application"
5
+ require_relative "kisko-suits/compiler"
6
+ require_relative "kisko-suits/watcher"
@@ -0,0 +1,37 @@
1
+ module KiskoSuits
2
+ class Application
3
+ def initialize(argv)
4
+ @params, @files = parse_options(argv)
5
+ end
6
+
7
+ def run
8
+ if @files.empty? || @files.size > 1 || !@files.first.include?(".suits")
9
+ abort "Usage: 'kisko-suits my-presentation.md.suits'\n\nOr start watching file with: 'kisko-suits -w my-presentation.md.suits'"
10
+ else
11
+ if @params[:watch]
12
+ on_update = ->(filename) {
13
+ compiler = KiskoSuits::Compiler.new(@files.first)
14
+ compiler.render
15
+ puts "Processed files and compiled '#{compiler.output_filename}'"
16
+ compiler.included_filenames
17
+ }
18
+ KiskoSuits::Watcher.new(@files.first, on_update).start
19
+ else
20
+ compiler = KiskoSuits::Compiler.new(@files.first)
21
+ compiler.render
22
+ puts "Processed files and compiled '#{compiler.output_filename}'"
23
+ end
24
+ end
25
+ end
26
+
27
+ def parse_options(argv)
28
+ params = {}
29
+ parser = OptionParser.new
30
+
31
+ parser.on("-w") { params[:watch] = true }
32
+ files = parser.parse(argv)
33
+
34
+ [params, files]
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,55 @@
1
+ require "set"
2
+
3
+ module KiskoSuits
4
+ class Compiler
5
+ attr_reader :path, :output_filename, :included_filenames
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ @output_filename = nil
10
+
11
+ @included_filenames = Set.new
12
+ end
13
+
14
+ def render
15
+ @included_filenames.clear
16
+
17
+ abort "Suits file '#{path}' not found" unless File.exists?(path)
18
+
19
+ open_output_file do |output|
20
+ File.foreach(path) do |line|
21
+ output.write(process_line(File.dirname(path), line))
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def process_line(root_dir, line)
29
+ if match = line.match(/\s*include:\s*([\w\.\/]+)/)
30
+ included_path = "#{root_dir}/#{match[1]}"
31
+ if File.exists?(included_path)
32
+ @included_filenames << included_path
33
+
34
+ File.foreach(included_path).map { |included_line|
35
+ process_line(File.dirname(included_path), included_line)
36
+ }.join
37
+ else
38
+ puts "Include #{included_path} can't be found"
39
+ ""
40
+ end
41
+ else
42
+ line
43
+ end
44
+ end
45
+
46
+ def open_output_file(&block)
47
+ @output_filename = path.gsub(".suits", "")
48
+
49
+ abort "Problem with config file (should end with .suits)" if path == @output_filename
50
+
51
+ File.delete(@output_filename) if File.exists?(@output_filename)
52
+ File.open(@output_filename, 'w', &block)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module KiskoSuits
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,46 @@
1
+ require "set"
2
+
3
+ module KiskoSuits
4
+ class Watcher
5
+ attr_reader :initial_filename, :on_update, :watched_paths
6
+
7
+ def initialize(initial_filename, on_update)
8
+ @initial_filename = initial_filename
9
+ @on_update = on_update
10
+ @watched_paths = Set.new
11
+ end
12
+
13
+ def start
14
+ process_path(initial_filename)
15
+ add_path(initial_filename)
16
+ watch
17
+ end
18
+
19
+ private
20
+
21
+ def watch
22
+ watch_file(watched_paths)
23
+ end
24
+
25
+ def watch_file(filenames)
26
+ watcher = FileWatcher.new(filenames.to_a)
27
+ watcher.watch do |changed_filename|
28
+ process_path(changed_filename)
29
+ watcher.finalize
30
+ watch
31
+ end
32
+ end
33
+
34
+ def process_path(path)
35
+ found_paths = on_update.call(path)
36
+
37
+ found_paths.each do |new_filename|
38
+ add_path(new_filename)
39
+ end
40
+ end
41
+
42
+ def add_path(filename)
43
+ watched_paths << filename
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kisko-suits
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Antti Akonniemi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: filewatcher
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
41
+ description: This app was meant to compile markdown partials as one document for our
42
+ sales team using Deckset for Mac
43
+ email:
44
+ - antti@kiskolabs.com
45
+ executables:
46
+ - kisko-suits
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - README.md
51
+ - bin/kisko-suits
52
+ - data/fail.md.suits
53
+ - data/folder/proot.md
54
+ - data/folder/what.md
55
+ - data/preso.md.suits
56
+ - data/preso.md_proper
57
+ - data/test.md
58
+ - lib/kisko-suits.rb
59
+ - lib/kisko-suits/application.rb
60
+ - lib/kisko-suits/compiler.rb
61
+ - lib/kisko-suits/version.rb
62
+ - lib/kisko-suits/watcher.rb
63
+ homepage: http://github.com/kiskolabs/kisko-suits
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.9.2
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.3.6
81
+ requirements: []
82
+ rubyforge_project: kisko-suits
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Application to compile files as one
87
+ test_files: []