livingstyleguide 1.2.0.pre.1 → 1.2.0.pre.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: 86825c04643629696331540ff589ba16fb57d592
4
- data.tar.gz: 8b7c01b7e88a6bfd3af8ba4616d7101a5928ce4f
3
+ metadata.gz: 055e627e9615c0dfd25421a891676beeeb049e2e
4
+ data.tar.gz: 1bc6c60bf8257467fe1135fd39111cd5a5af6e70
5
5
  SHA512:
6
- metadata.gz: 5cacdc1aca7c7da0e9bd6a5b65877daa7ec01eab7b52f438c502fd7b19b12a5a1c8d12dd16634aa1003ef5921f1bdb2fb4b5ed03cf2fd8861bc4ee69910fbae2
7
- data.tar.gz: 278a316fe32545e1c046e7be77f1f2fb2e2f5690553e5fcd6ddd712e2dfe61ca2e2c14adddbec0d4ddb2375368ef8444421d3da1a90307a23c5b7a257d55b58b
6
+ metadata.gz: 46805c97d4f2325a687659685208970c0406e6eee12bea6e61a9b2e41aa7e150ba40d6876190621391d3cafc748b51b6df3c2821f075522b5898750f0e7c7dd2
7
+ data.tar.gz: 3418637902ee95d9342211657fc42ec4d159c3d39078a0f775ef38e84aa0bdc678c449afbad32ec805f156adf90181b9865b1189e33c0e950f191660f7508199
@@ -9,16 +9,41 @@ require 'tilt'
9
9
  module LivingStyleGuide
10
10
  class CommandLineInterface < Thor
11
11
 
12
- desc 'compile filename', 'Compiles the living style guide to HTML.'
13
- def compile(file)
14
- output_file = file.sub(/\.lsg$/, '')
15
- if defined?(Compass)
16
- Compass.add_project_configuration
17
- output_file.sub! /^#{Compass.configuration.sass_dir}/, Compass.configuration.css_dir
12
+ desc 'compile input_file output_file', 'Compiles the living style guide to HTML.'
13
+ def compile(input_file = nil, output_file = nil)
14
+ template = LivingStyleGuide::TiltTemplate.new(input_file) do
15
+ input(input_file)
16
+ end
17
+ output template.render, input_file, output_file
18
+ end
19
+
20
+ desc 'version', 'Shows the current version of the Gem'
21
+ def version
22
+ puts "LivingStyleGuide #{LivingStyleGuide::VERSION}"
23
+ end
24
+
25
+ private
26
+ def input(input_file = nil)
27
+ @input ||= if input_file.nil?
28
+ $stdin.read
29
+ else
30
+ File.read(input_file)
31
+ end
32
+ end
33
+
34
+ private
35
+ def output(html, input_file = nil, output_file = nil)
36
+ if input_file.nil?
37
+ puts html
38
+ else
39
+ output_file = input_file.sub(/(\.html)?\.lsg$/, '.html') if output_file.nil?
40
+ if defined?(Compass)
41
+ Compass.add_project_configuration
42
+ output_file = output_file.sub(/^#{Compass.configuration.sass_dir}/, Compass.configuration.css_dir)
43
+ end
44
+ File.write output_file, html
45
+ puts "Successfully generated a living style guide at #{output_file}."
18
46
  end
19
- html = Tilt.new(file).render
20
- File.write output_file, html
21
- puts "Successfully generated a living style guide at #{output_file}."
22
47
  end
23
48
 
24
49
  end
@@ -137,6 +137,8 @@ module LivingStyleGuide
137
137
  next unless sass_filename.is_a?(String)
138
138
  glob = "#{sass_filename.sub(/\.s[ac]ss$/, '')}.md"
139
139
  Dir.glob(glob) do |markdown_filename|
140
+ next if files.include?(markdown_filename)
141
+
140
142
  files << markdown_filename
141
143
  @markdown << File.read(markdown_filename)
142
144
  end
@@ -209,4 +211,3 @@ module LivingStyleGuide
209
211
  end
210
212
 
211
213
  end
212
-
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'minisyntax'
2
4
  require 'erb'
3
5
  require 'hooks'
@@ -74,7 +76,11 @@ class LivingStyleGuide::Example
74
76
 
75
77
  private
76
78
  def set_filter(key, argument = nil)
77
- instance_exec argument, &@@filters[key.to_s.gsub('-', '_').to_sym]
79
+ name = key.to_s.gsub('-', '_').to_sym
80
+ unless @@filters.has_key?(name)
81
+ raise NameError.new("Undefined filter “@#{key}” called.", name)
82
+ end
83
+ instance_exec argument, &@@filters[name]
78
84
  end
79
85
 
80
86
  private
@@ -27,6 +27,9 @@ module LivingStyleGuide
27
27
  if defined?(Rails)
28
28
  options[:load_paths] += Rails.application.config.assets.paths
29
29
  end
30
+ if @file.nil?
31
+ options[:load_paths] << Dir.pwd
32
+ end
30
33
  if options[:template_location]
31
34
  options[:template_location].each do |path, short|
32
35
  options[:load_paths] << path
@@ -64,7 +67,7 @@ module LivingStyleGuide
64
67
 
65
68
  private
66
69
  def root
67
- if @scope.respond_to?(:environment)
70
+ if @scope.respond_to?(:environment) and @scope.environment.respond_to?(:root)
68
71
  @scope.environment.root
69
72
  else
70
73
  find_root_path
@@ -73,7 +76,7 @@ module LivingStyleGuide
73
76
 
74
77
  private
75
78
  def find_root_path
76
- path = File.dirname(@file)
79
+ path = @file.nil? ? Dir.pwd : File.dirname(@file)
77
80
  while path.length > 0 do
78
81
  if File.exists?(File.join(path, 'Gemfile')) or File.exists?(File.join(path, '.git'))
79
82
  break
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = '1.2.0.pre.1'
2
+ VERSION = '1.2.0.pre.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livingstyleguide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.pre.1
4
+ version: 1.2.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Hagenburger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax