livingstyleguide 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4072457c67f202db733afd113f87390edca902f5
4
- data.tar.gz: f4874e3e3b8ce3773002565ff7da285e39275ade
3
+ metadata.gz: 87e479b61b3908455eba0e0736876700f7db009e
4
+ data.tar.gz: 41f5b342d7b41d198b06863925ddd864adab556f
5
5
  SHA512:
6
- metadata.gz: fc50d10fbfc82a240f952202131cf72ec25c0d5ee59a87eb7c89ab6651917176a61754ee590bca0ad5c0945b024c024b1e3482a06229976f34e439725edbca55
7
- data.tar.gz: b5ecf4fb1cff88ad447055fb25f6834b456ed26426acb2d47dee46b826218c2c64c7382fc48d0c5841ef3a2a9b862248f3c2c873b275eb1d1d077032c64b48ed
6
+ metadata.gz: 688c685befee8c0950bc3abb04d13d38208526dd5c7e03ec5d51bed01737983d7b1dc48a1365d241720dadcb942aff55f013c46776a04a267d52b50daaa8b944
7
+ data.tar.gz: 4dffe131b8f86d86cbe93e5282ad362b056abbecc81f0f5bd4a089798aee562430d0b5d4fd3d7f7be40f31739c2eac0f0fbc5fc06269901016674c26e56025c1
@@ -9,8 +9,8 @@ def map_files(glob)
9
9
  if glob.index("*")
10
10
  files.uniq!
11
11
  files.reject! { |f| document.files.include?(f) }
12
- else
13
- raise Errno::ENOENT if files.empty?
12
+ elsif files.empty?
13
+ raise Errno::ENOENT
14
14
  end
15
15
 
16
16
  files.map do |file|
@@ -280,7 +280,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
280
280
  end
281
281
 
282
282
  def template_name
283
- (@type == :lsg || @type == :markdown) ? :redcarpet : @type
283
+ @type == :lsg || @type == :markdown ? :redcarpet : @type
284
284
  end
285
285
 
286
286
  def generate_id
@@ -310,4 +310,4 @@ class LivingStyleGuide::Document < ::Tilt::Template
310
310
  end
311
311
  end
312
312
 
313
- Tilt.register "lsg", LivingStyleGuide::Document
313
+ Tilt.register LivingStyleGuide::Document, "lsg"
@@ -1,9 +1,9 @@
1
- if defined?(Rails) && defined?(Rails::Railtie)
1
+ if defined?(Rails) && defined?(Rails::Railtie) && defined?(Sprockets)
2
2
  require "rails"
3
3
  class LivingStyleGuideRailtie < Rails::Railtie
4
4
  initializer "living_style_guide.assets" do |app|
5
5
  Rails.application.config.assets.configure do |env|
6
- env.register_engine(".lsg", ::LivingStyleGuide::Document)
6
+ LivingStyleGuideTransformer.register(env)
7
7
  end
8
8
  LivingStyleGuide.default_options[:scss_template] =
9
9
  ::Sass::Rails::ScssTemplate
@@ -1,10 +1,55 @@
1
1
  if defined?(Sprockets)
2
2
  begin
3
3
  require "sprockets"
4
- Sprockets.register_engine(".lsg", ::LivingStyleGuide::Document)
5
- if Sprockets.respond_to?(:append_path)
6
- Sprockets.append_path(::LivingStyleGuide::SASS_PATH)
4
+
5
+ class LivingStyleGuideTransformer
6
+ def initialize(filename)
7
+ @filename = filename
8
+ @source = yield
9
+ end
10
+
11
+ def render(context, _)
12
+ self.class.run(@filename, @source, context)
13
+ end
14
+
15
+ def self.run(filename, source, context)
16
+ doc = LivingStyleGuide::Document.new(filename) { source }
17
+ doc.render(context)
18
+ end
19
+
20
+ def self.call(input)
21
+ filename = input[:filename]
22
+ source = input[:data]
23
+ context = input[:environment].context_class.new(input)
24
+
25
+ result = run(filename, source, context)
26
+ context.metadata.merge(data: result)
27
+ end
28
+
29
+ def self.register(env)
30
+ if env.respond_to?(:register_transformer)
31
+ env.register_mime_type("text/lsg",
32
+ extensions: [".lsg"],
33
+ charset: :unicode)
34
+ env.register_transformer("text/lsg", "text/html",
35
+ LivingStyleGuideTransformer)
36
+ end
37
+
38
+ if env.respond_to?(:register_engine)
39
+ args = [".lsg", ::LivingStyleGuide::Document]
40
+ if Sprockets::VERSION.start_with?("3")
41
+ args << { mime_type: "text/html", silence_deprecation: true }
42
+ end
43
+ env.register_engine(*args)
44
+ end
45
+
46
+ if env.respond_to?(:append_path)
47
+ env.append_path(::LivingStyleGuide::SASS_PATH)
48
+ end
49
+ end
7
50
  end
51
+
52
+ LivingStyleGuideTransformer.register(Sprockets)
8
53
  rescue LoadError
9
54
  end
10
55
  end
@@ -49,7 +49,7 @@ module LivingStyleGuide
49
49
 
50
50
  def parse_options(data)
51
51
  data.strip!
52
- @options = (data[0] == "{") ? JSON.parse(data) : YAML.load(data)
52
+ @options = data[0] == "{" ? JSON.parse(data) : YAML.load(data)
53
53
  @options = {} unless @options
54
54
  @options.keys.each do |key|
55
55
  @options[key.tr("-", "_").to_sym] = @options.delete(key)
@@ -78,7 +78,7 @@ module LivingStyleGuide
78
78
 
79
79
  def find_root_path
80
80
  path = @file.nil? ? Dir.pwd : File.dirname(@file)
81
- while path.length > 0
81
+ while !path.empty?
82
82
  if File.exists?(File.join(path, "Gemfile")) ||
83
83
  File.exists?(File.join(path, ".git"))
84
84
  break
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Hagenburger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax
@@ -220,9 +220,8 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
- description: |-
224
- Automaticaly generate beautiful front-end style guides with Sas and
225
- Markdown. Se htps:/livingstyleguide.org for details.
223
+ description: Automatically generate beautiful front-end style guides with Sass and
224
+ Markdown. See https://livingstyleguide.org for details.
226
225
  email:
227
226
  - nico@hagenburger.net
228
227
  executables:
@@ -308,9 +307,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
307
  version: '0'
309
308
  requirements: []
310
309
  rubyforge_project:
311
- rubygems_version: 2.4.5
310
+ rubygems_version: 2.5.1
312
311
  signing_key:
313
312
  specification_version: 4
314
313
  summary: Generate beautiful front-end style guides
315
314
  test_files: []
316
- has_rdoc: