guard-gimli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 Fredrik Wallgren
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.textile ADDED
@@ -0,0 +1,44 @@
1
+ h1. guard-gimli
2
+
3
+ gimli guard allows to automatically convert your files when markup is changed
4
+
5
+ h2. Install
6
+
7
+ Please be sure to have "Guard":http://github.com/guard/guard installed before continue.
8
+
9
+ Install the gem:
10
+
11
+ bc. gem install guard-gimli
12
+
13
+ Add guard definition to your Guardfile by running this command:
14
+
15
+ bc. guard init gimli
16
+
17
+ h2. Usage
18
+
19
+ All commands originate from the directory where the file is located
20
+ Please read "Guard usage doc":http://github.com/guard/guard#readme and "gimli usage doc":http://github.com/walle/gimli#readme
21
+
22
+ h2. Guardfile
23
+
24
+ You can adapt your markup files like you want.
25
+ Please read "Guard doc":http://github.com/guard/guard#readme for more info about Guardfile DSL.
26
+
27
+ bc. guard 'gimli' do
28
+ watch(%r{.+\.(md|mkdn?|mdown|markdown|textile|rdoc|org|creole|re?st(\.txt)?|asciidoc|pod|\d|(media)?wiki)})
29
+ end
30
+
31
+ h2. Options
32
+
33
+ LiveReload guard have 1 option that you can set like this:
34
+
35
+ bc. guard 'gimli', :outputdir => 'build' do
36
+ ...
37
+ end
38
+
39
+ Available options:
40
+
41
+ bc. :outputdir => 'build' # default nil ie. directory of file
42
+
43
+ See "gimli doc":http://github.com/walle/gimli#readme for more info.
44
+
@@ -0,0 +1,31 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class Gimli < Guard
6
+
7
+ autoload :Converter, 'guard/gimli/converter'
8
+
9
+ attr_reader :converter
10
+
11
+ def initialize(watchers = [], options = {})
12
+ super
13
+ @options = {
14
+ :outputdir => nil
15
+ }.update(options)
16
+ end
17
+
18
+ def start
19
+ @converter = Converter.new(@options)
20
+ end
21
+
22
+ def stop
23
+ end
24
+
25
+ def run_on_change(paths)
26
+ converter.reload(paths)
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,56 @@
1
+ module Guard
2
+ class Gimli
3
+ class Converter
4
+
5
+ def initialize(options)
6
+ @outputdir = options[:outputdir]
7
+ end
8
+
9
+ def reload(paths = [])
10
+ UI.info "Building pdfs for #{paths.join(' ')}"
11
+ start_at = Time.now
12
+ paths.each do |path|
13
+ system("gimli#{command(path)}")
14
+ UI.info "#{outputinfo(path)} built"
15
+ end
16
+ end
17
+
18
+ def command(path)
19
+ command = " -f #{escape(path)}"
20
+ command += outputdir(escape(path)).nil? ? '' : " -o #{outputdir(escape(path))}"
21
+ end
22
+
23
+ def outputdir(path)
24
+ if @outputdir.nil?
25
+ base_dir path
26
+ else
27
+ if base_dir(path).nil?
28
+ @outputdir
29
+ else
30
+ File.join(base_dir(path), @outputdir)
31
+ end
32
+ end
33
+ end
34
+
35
+ def outputinfo(path)
36
+ info = outputdir(path)
37
+ info += '/' unless info.nil?
38
+ info = info.to_s + "#{filename(path)}.pdf"
39
+ end
40
+
41
+ def filename(path)
42
+ File.basename(path).gsub(/\..+$/, '')
43
+ end
44
+
45
+ def base_dir(path)
46
+ dir = File.dirname path
47
+ dir unless dir == '.'
48
+ end
49
+
50
+ def escape(path)
51
+ path.gsub(' ', '\ ')
52
+ end
53
+ end
54
+ end
55
+ end
56
+
@@ -0,0 +1,4 @@
1
+ guard 'gimli' do
2
+ watch(%r{.+\.(md|mkdn?|mdown|markdown|textile|rdoc|org|creole|re?st(\.txt)?|asciidoc|pod|\d|(media)?wiki)})
3
+ end
4
+
@@ -0,0 +1,6 @@
1
+ module Guard
2
+ module GimliVersion
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
6
+
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-gimli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fredrik Wallgren
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-05-05 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: guard
17
+ requirement: &10226600 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *10226600
26
+ - !ruby/object:Gem::Dependency
27
+ name: gimli
28
+ requirement: &10226180 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *10226180
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &10225760 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *10225760
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &10225340 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *10225340
59
+ - !ruby/object:Gem::Dependency
60
+ name: rr
61
+ requirement: &10224920 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *10224920
70
+ description: Guard::Gimli automatically converts your markup files when they are modified.
71
+ email:
72
+ - fredrik.wallgren@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - lib/guard/gimli/version.rb
78
+ - lib/guard/gimli/templates/Guardfile
79
+ - lib/guard/gimli/converter.rb
80
+ - lib/guard/gimli.rb
81
+ - LICENSE
82
+ - README.textile
83
+ has_rdoc: true
84
+ homepage: https://github.com/walle/guard-gimli
85
+ licenses: []
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project: guard-gimli
104
+ rubygems_version: 1.6.2
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Guard gem for gimli
108
+ test_files: []