hamloft 0.2.4 → 0.2.5

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: 72b5e54af21c599a2cea0920edcca58ad637a932
4
- data.tar.gz: 9335aa05602c9da27f8ea08d10d6f394e31210b9
3
+ metadata.gz: 40807ee3a7e3517a4f34b52fda3c73a0a8dce5f2
4
+ data.tar.gz: 2e5eeb028f33fae5d926546ae6bb772f5c6336d3
5
5
  SHA512:
6
- metadata.gz: 9043a17dd2f544ff1f938f85dc91eb6b3e5090a339bd5810c8ea613a710aca51c175d56644a1305483d7b73cfc6b50d6726d1c2b5c4c9c44d6ac54816808afd2
7
- data.tar.gz: d9e7490a33fd6688fefd0438684cddaa07dd555e7461d0cb1e5c9db43eb1dcd757ea25972bc530c4d73eb1ad094b1f755e7aadbcdb2cc134ce7096577ecf9c63
6
+ metadata.gz: 4060f0dba012feaecae55ac7539614f9eae4d6515827bd0171e67ae5ed95b3bd6d0e53b716dffa0f621c39ca08c779ecd36e23c801554490b7b42e600d3e7d54
7
+ data.tar.gz: 20e0feb0cc815a48b6c1a34c65495960e4e74737185b745170a442aaab658be8dc5485d51d72a1fbd77e99181d991112fa91cd16a5bc5b49d5da91c467e4220b
data/Gemfile.lock CHANGED
@@ -1,56 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hamloft (0.2.4)
4
+ hamloft (0.2.5)
5
5
  haml (~> 4.0)
6
- nokogiri (~> 1.6)
6
+ nokogiri (~> 1.8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- ast (2.0.0)
12
- astrolabe (1.3.1)
13
- parser (~> 2.2)
11
+ ast (2.3.0)
14
12
  coderay (1.1.0)
15
- diff-lcs (1.2.5)
13
+ diff-lcs (1.3)
16
14
  haml (4.0.7)
17
15
  tilt
18
16
  method_source (0.8.2)
19
- mini_portile2 (2.1.0)
20
- nokogiri (1.6.8)
21
- mini_portile2 (~> 2.1.0)
22
- pkg-config (~> 1.1.7)
23
- parser (2.2.2.6)
24
- ast (>= 1.1, < 3.0)
25
- pkg-config (1.1.7)
17
+ mini_portile2 (2.2.0)
18
+ nokogiri (1.8.0)
19
+ mini_portile2 (~> 2.2.0)
20
+ parallel (1.11.2)
21
+ parser (2.4.0.0)
22
+ ast (~> 2.2)
26
23
  powerpack (0.1.1)
27
24
  pry (0.10.3)
28
25
  coderay (~> 1.1.0)
29
26
  method_source (~> 0.8.1)
30
27
  slop (~> 3.4)
31
- rainbow (2.0.0)
32
- rspec (3.3.0)
33
- rspec-core (~> 3.3.0)
34
- rspec-expectations (~> 3.3.0)
35
- rspec-mocks (~> 3.3.0)
36
- rspec-core (3.3.2)
37
- rspec-support (~> 3.3.0)
38
- rspec-expectations (3.3.1)
28
+ rainbow (2.2.2)
29
+ rake
30
+ rake (12.0.0)
31
+ rspec (3.6.0)
32
+ rspec-core (~> 3.6.0)
33
+ rspec-expectations (~> 3.6.0)
34
+ rspec-mocks (~> 3.6.0)
35
+ rspec-core (3.6.0)
36
+ rspec-support (~> 3.6.0)
37
+ rspec-expectations (3.6.0)
39
38
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.3.0)
41
- rspec-mocks (3.3.2)
39
+ rspec-support (~> 3.6.0)
40
+ rspec-mocks (3.6.0)
42
41
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.3.0)
44
- rspec-support (3.3.0)
45
- rubocop (0.32.1)
46
- astrolabe (~> 1.3)
47
- parser (>= 2.2.2.5, < 3.0)
42
+ rspec-support (~> 3.6.0)
43
+ rspec-support (3.6.0)
44
+ rubocop (0.49.1)
45
+ parallel (~> 1.10)
46
+ parser (>= 2.3.3.1, < 3.0)
48
47
  powerpack (~> 0.1)
49
48
  rainbow (>= 1.99.1, < 3.0)
50
- ruby-progressbar (~> 1.4)
51
- ruby-progressbar (1.7.5)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (~> 1.0, >= 1.0.1)
51
+ ruby-progressbar (1.8.1)
52
52
  slop (3.6.0)
53
- tilt (2.0.5)
53
+ tilt (2.0.7)
54
+ unicode-display_width (1.2.1)
54
55
 
55
56
  PLATFORMS
56
57
  ruby
@@ -58,8 +59,8 @@ PLATFORMS
58
59
  DEPENDENCIES
59
60
  hamloft!
60
61
  pry (~> 0.10)
61
- rspec (~> 3.3)
62
- rubocop (~> 0.32)
62
+ rspec (~> 3.6)
63
+ rubocop (~> 0.49)
63
64
 
64
65
  BUNDLED WITH
65
- 1.12.4
66
+ 1.14.6
data/hamloft.gemspec CHANGED
@@ -13,10 +13,10 @@ Gem::Specification.new do |s|
13
13
  s.summary = "Hamloft - MagLoft Widget Parser."
14
14
  s.description = "This gem contains template built parser for creating MagLoft theme templates."
15
15
  s.add_runtime_dependency 'haml', "~> 4.0"
16
- s.add_runtime_dependency "nokogiri", "~> 1.6"
17
- s.add_development_dependency "rspec", "~> 3.3"
16
+ s.add_runtime_dependency "nokogiri", "~> 1.8"
17
+ s.add_development_dependency "rspec", "~> 3.6"
18
18
  s.add_development_dependency "pry", "~> 0.10"
19
- s.add_development_dependency "rubocop", "~> 0.32"
19
+ s.add_development_dependency "rubocop", "~> 0.49"
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
22
  s.require_path = 'lib'
@@ -1,31 +1,28 @@
1
1
  module Hamloft
2
2
  class Engine < Haml::Engine
3
-
4
3
  def render(scope = Object.new, locals = {}, &block)
5
4
  parent = scope.instance_variable_defined?('@haml_buffer') ? scope.instance_variable_get('@haml_buffer') : nil
6
5
  buffer = Haml::Buffer.new(parent, @options.for_buffer)
7
6
 
8
7
  if scope.is_a?(Binding) || scope.is_a?(Proc)
9
- scope_object = eval("self", scope)
10
- scope = scope_object.instance_eval{binding} if block_given?
8
+ scope_object = eval('self', scope)
9
+ scope = scope_object.instance_eval { binding } if block_given?
11
10
  else
12
11
  scope_object = scope
13
- scope = scope_object.instance_eval{binding}
12
+ scope = scope_object.instance_eval { binding }
14
13
  end
15
14
 
16
- set_locals(locals.merge(:_hamlout => buffer, :_erbout => buffer.buffer), scope, scope_object)
15
+ set_locals(locals.merge(_hamlout: buffer, _erbout: buffer.buffer), scope, scope_object)
17
16
 
18
17
  scope_object.instance_eval do
19
18
  extend Haml::Helpers
20
19
  extend Hamloft::Helpers
21
-
20
+
22
21
  # Inject widget helpers
23
22
  Hamloft.widgets.each do |widget|
24
- if defined?(widget::Helpers)
25
- extend widget::Helpers
26
- end
23
+ extend widget::Helpers if defined?(widget::Helpers)
27
24
  end
28
-
25
+
29
26
  @haml_buffer = buffer
30
27
  end
31
28
  begin
@@ -39,6 +36,5 @@ module Hamloft
39
36
  @haml_buffer = buffer.upper if buffer
40
37
  end
41
38
  end
42
-
43
39
  end
44
40
  end
@@ -1,11 +1,10 @@
1
1
  module Hamloft
2
2
  module Helpers
3
-
4
3
  def style_string(options, *args, &block)
5
4
  Hamloft::StyleBuilder.new(options, args).process(block)
6
5
  end
7
-
8
- def block(identifier, variables={})
6
+
7
+ def block(identifier, variables = {})
9
8
  haml_contents = Hamloft.block_resolver.resolve(identifier, @_haml_locals)
10
9
  Hamloft.render(haml_contents, @_haml_locals.merge(variables))
11
10
  end
@@ -14,25 +13,25 @@ module Hamloft
14
13
  def asset(url)
15
14
  "#{asset_uri}/themes/#{@_haml_locals[:theme]}/#{url}"
16
15
  end
17
-
16
+
18
17
  def root_asset(url)
19
18
  "#{asset_uri}/#{url}"
20
19
  end
21
-
20
+
22
21
  def asset_uri
23
22
  @_haml_locals[:asset_uri] || Hamloft.asset_uri
24
23
  end
25
-
26
- def var(key, default=nil)
24
+
25
+ def var(key, default = nil)
27
26
  variable(:variables, {})[key.to_sym] || default
28
27
  end
29
-
30
- def variable(key, default=false)
28
+
29
+ def variable(key, default = false)
31
30
  @_haml_locals[key.to_sym] || default
32
31
  end
33
-
32
+
34
33
  def parse_html(key, type)
35
- if html = @_haml_locals[key.to_sym] and not Hamloft.template(type).nil?
34
+ if (html = @_haml_locals[key.to_sym]) && !Hamloft.template(type).nil?
36
35
  template = Hamloft.template(type).new(self, html)
37
36
  template.container do
38
37
  template.chunks.each do |chunk|
@@ -42,45 +41,45 @@ module Hamloft
42
41
  end
43
42
  end
44
43
 
45
- def link(href, referrer="Baker", &block)
46
- if referrer and not referrer.empty? and not href.include?("referrer=")
47
- href = "#{href}#{href.include?("?") ? "&" : "?"}referrer=#{referrer}"
44
+ def link(href, referrer = 'Baker', &block)
45
+ if referrer && !referrer.empty? && !href.include?('referrer=')
46
+ href = "#{href}#{href.include?('?') ? '&' : '?'}referrer=#{referrer}"
48
47
  end
49
- haml_tag :a, :href => href do
50
- block.call if block
48
+ haml_tag :a, href: href do
49
+ yield if block
51
50
  end
52
51
  end
53
52
 
54
53
  def font(font_face, &block)
55
- haml_tag :font, :face => font_face do
56
- block.call if block
54
+ haml_tag :font, face: font_face do
55
+ yield if block
57
56
  end
58
57
  end
59
58
 
60
59
  def style(*args, &block)
61
60
  style = nil
62
- if args[-1].class.name == "Hash"
61
+ if args[-1].class.name == 'Hash'
63
62
  style_options = args.pop
64
63
  style = style_string(style_options, *style_options.keys)
65
64
  end
66
-
67
- classes = args.map{|a| "__#{a}"}
68
- haml_tag :span, :class => classes.join(" "), :style => style do
69
- block.call if block
70
- end
65
+
66
+ classes = args.map { |a| "__#{a}" }
67
+ haml_tag :span, class: classes.join(' '), style: style do
68
+ yield if block
69
+ end
71
70
  end
72
71
 
73
72
  # drop container
74
73
 
75
74
  def drop_container
76
- haml_tag :div, :class => "_typeloft_widget_drop_container"
75
+ haml_tag :div, class: '_typeloft_widget_drop_container'
77
76
  end
78
-
77
+
79
78
  # widgets
80
79
 
81
80
  def widget_block(widget, &block)
82
81
  haml_tag :div, widget.typeloft_widget_options do
83
- block.call(widget) if block
82
+ yield(widget) if block
84
83
  end
85
84
  end
86
85
  end
@@ -3,64 +3,63 @@ module Hamloft
3
3
  attr_accessor :options
4
4
  attr_accessor :styles
5
5
 
6
- def initialize(options, styles=[])
6
+ def initialize(options, styles = [])
7
7
  @options = {}
8
8
  @styles = {}
9
-
9
+
10
10
  # expand margins
11
11
  if styles.include?(:margin)
12
- styles = styles | [:margin_top, :margin_right, :margin_bottom, :margin_left]
13
- styles.reject! {|style| styles === :margin}
12
+ styles |= %i[margin_top margin_right margin_bottom margin_left]
13
+ styles.reject! { |_style| styles === :margin }
14
14
  end
15
-
15
+
16
16
  # expand paddings
17
17
  if styles.include?(:padding)
18
- styles = styles | [:padding_top, :padding_right, :padding_bottom, :padding_left]
19
- styles.reject! {|style| styles === :padding}
18
+ styles |= %i[padding_top padding_right padding_bottom padding_left]
19
+ styles.reject! { |_style| styles === :padding }
20
20
  end
21
-
21
+
22
22
  # build sanitized options
23
23
  options.each do |k, v|
24
24
  @options[sanitize_style(k)] = v
25
25
  end
26
-
26
+
27
27
  # add initial styles
28
28
  add_multi(styles)
29
29
  end
30
-
31
- def process(block=nil)
30
+
31
+ def process(block = nil)
32
32
  block.call(self) if block
33
- result = @styles.map{|k, v|"#{k}: #{v};"}.join(" ")
33
+ result = @styles.map { |k, v| "#{k}: #{v};" }.join(' ')
34
34
  result.empty? ? nil : result
35
35
  end
36
-
36
+
37
37
  def add_multi(styles)
38
38
  styles.each do |style|
39
39
  add(style)
40
40
  end
41
41
  end
42
-
43
- def add(style, value=nil, template=nil)
42
+
43
+ def add(style, value = nil, template = nil)
44
44
  style = sanitize_style(style)
45
-
45
+
46
46
  # handle empty value field
47
- if (not value or value.empty?) and not (not @options[style] or @options[style].empty?)
47
+ if (!value || value.empty?) && !(!(@options[style]) || @options[style].empty?)
48
48
  value = @options[style]
49
49
  end
50
-
50
+
51
51
  # apply template
52
- if value and not value.empty? and template and not template.empty?
52
+ if value && !value.empty? && template && !template.empty?
53
53
  value = ERB.new(template).result(binding)
54
54
  end
55
-
56
- @styles[style] = value if value and not value.empty?
55
+
56
+ @styles[style] = value if value && !value.empty?
57
57
  end
58
-
58
+
59
59
  def sanitize_style(value)
60
- value.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1-\2').
61
- gsub(/([a-z\d])([A-Z])/,'\1-\2').
62
- tr("_", "-").downcase
60
+ value.to_s.gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2')
61
+ .gsub(/([a-z\d])([A-Z])/, '\1-\2')
62
+ .tr('_', '-').downcase
63
63
  end
64
-
65
64
  end
66
- end
65
+ end
@@ -1,24 +1,23 @@
1
1
  module Hamloft
2
2
  class Template
3
3
  attr_accessor :haml, :html, :doc
4
-
4
+
5
5
  def initialize(haml, html)
6
6
  self.haml = haml
7
7
  self.html = html
8
- self.doc = Nokogiri::HTML.fragment(self.html)
8
+ self.doc = Nokogiri::HTML.fragment(self.html)
9
9
  end
10
-
10
+
11
11
  def chunks
12
12
  []
13
13
  end
14
-
14
+
15
15
  def container(&block)
16
16
  yield(block)
17
17
  end
18
-
19
- def process_chunk(chunk)
18
+
19
+ def process_chunk(_chunk)
20
20
  nil
21
21
  end
22
-
23
22
  end
24
23
  end
@@ -1,3 +1,3 @@
1
1
  module Hamloft
2
- VERSION = "0.2.4"
2
+ VERSION = '0.2.5'.freeze
3
3
  end
@@ -4,7 +4,7 @@ module Hamloft
4
4
  attr_accessor :options
5
5
 
6
6
  def identifier
7
- "base"
7
+ 'base'
8
8
  end
9
9
 
10
10
  def defaults
@@ -14,10 +14,10 @@ module Hamloft
14
14
  def initialize(options)
15
15
  @options = defaults.merge(options)
16
16
  end
17
-
17
+
18
18
  def typeloft_widget_options
19
19
  attributes = {
20
- :class => "_typeloft_widget",
20
+ :class => '_typeloft_widget',
21
21
  :"data-widget-identifier" => identifier
22
22
  }
23
23
  @options.each do |k, v|
@@ -25,6 +25,5 @@ module Hamloft
25
25
  end
26
26
  attributes
27
27
  end
28
-
29
28
  end
30
29
  end
data/lib/hamloft.rb CHANGED
@@ -1,22 +1,22 @@
1
- require "haml"
2
- require "erb"
3
- require "nokogiri"
4
- require "hamloft/engine"
5
- require "hamloft/style_builder"
6
- require "hamloft/helpers"
7
- require "hamloft/template"
8
- require "hamloft/widget"
1
+ require 'haml'
2
+ require 'erb'
3
+ require 'nokogiri'
4
+ require 'hamloft/engine'
5
+ require 'hamloft/style_builder'
6
+ require 'hamloft/helpers'
7
+ require 'hamloft/template'
8
+ require 'hamloft/widget'
9
9
 
10
10
  module Hamloft
11
11
  @@_templates = {}
12
12
  @@_widgets = []
13
13
  @@_block_resolver = nil
14
14
  @@_asset_uri = nil
15
-
15
+
16
16
  def self.block_resolver=(resolver)
17
17
  @@_block_resolver = resolver
18
18
  end
19
-
19
+
20
20
  def self.block_resolver
21
21
  @@_block_resolver
22
22
  end
@@ -24,27 +24,27 @@ module Hamloft
24
24
  def self.asset_uri=(asset_uri)
25
25
  @@_asset_uri = asset_uri
26
26
  end
27
-
27
+
28
28
  def self.asset_uri
29
- @@_asset_uri || "."
29
+ @@_asset_uri || '.'
30
30
  end
31
-
32
- def self.render(haml, variables={})
31
+
32
+ def self.render(haml, variables = {})
33
33
  Hamloft::Engine.new(haml, remove_whitespace: true).render(Object.new, variables)
34
34
  end
35
-
35
+
36
36
  def self.register_template(key, template)
37
37
  @@_templates[key] = template
38
38
  end
39
-
39
+
40
40
  def self.register_widget(klass)
41
41
  @@_widgets.push(klass)
42
42
  end
43
-
43
+
44
44
  def self.widgets
45
45
  @@_widgets
46
46
  end
47
-
47
+
48
48
  def self.template(key)
49
49
  @@_templates[key]
50
50
  end
@@ -1,52 +1,51 @@
1
1
  class TumblrTemplate < Hamloft::Template
2
-
3
2
  def chunks
4
- self.doc.children
3
+ doc.children
5
4
  end
6
-
5
+
7
6
  def container(&block)
8
- haml.container_widget(padding_left: "0em", padding_right: "0em", &block)
7
+ haml.container_widget(padding_left: '0em', padding_right: '0em', &block)
9
8
  end
10
-
9
+
11
10
  def process_chunk(chunk)
12
11
  case chunk.name
13
- when "text"
14
- haml.paragraph_widget({margin_left: "2em", margin_right: "2em"}, chunk.text)
15
- when "p"
16
- haml.paragraph_widget({margin_left: "2em", margin_right: "2em"}, chunk.text)
17
- when "a"
18
- if chunk.css("img").length > 0
19
- haml.image_widget_link(href: chunk.attribute("href").to_s, source: chunk.css("img").first.attribute("src").to_s)
12
+ when 'text'
13
+ haml.paragraph_widget({ margin_left: '2em', margin_right: '2em' }, chunk.text)
14
+ when 'p'
15
+ haml.paragraph_widget({ margin_left: '2em', margin_right: '2em' }, chunk.text)
16
+ when 'a'
17
+ if !chunk.css('img').empty?
18
+ haml.image_widget_link(href: chunk.attribute('href').to_s, source: chunk.css('img').first.attribute('src').to_s)
20
19
  else
21
- haml.paragraph_widget({margin_left: "2em", margin_right: "2em"}, chunk.text) do
22
- haml.link(chunk.attribute("href").to_s)
20
+ haml.paragraph_widget({ margin_left: '2em', margin_right: '2em' }, chunk.text) do
21
+ haml.link(chunk.attribute('href').to_s)
23
22
  end
24
23
  end
25
- when "figure"
24
+ when 'figure'
26
25
  case chunk.children.first.name
27
- when "img"
28
- haml.image_widget(source: chunk.children.first.attribute("src").to_s, margin_bottom: "1em")
29
- when "iframe"
30
- iframe_url = chunk.children.first.attribute("src").value
31
- if iframe_url.include?("screen.yahoo.com") and match = iframe_url.match("screen\.yahoo\.com\/([a-z0-9\-]+)\.html")
32
- haml.yahoo_screen_widget(yahoo_screen_id: match[1], margin_bottom: "1em")
33
- elsif iframe_url.include?("www.youtube.com") and match = iframe_url.match("www\.youtube\.com\/.*\/([a-zA-Z0-9]+)")
34
- haml.youtube_widget(youtube_id: match[1], margin_bottom: "1em")
26
+ when 'img'
27
+ haml.image_widget(source: chunk.children.first.attribute('src').to_s, margin_bottom: '1em')
28
+ when 'iframe'
29
+ iframe_url = chunk.children.first.attribute('src').value
30
+ if iframe_url.include?('screen.yahoo.com') && (match = iframe_url.match("screen\.yahoo\.com\/([a-z0-9\-]+)\.html"))
31
+ haml.yahoo_screen_widget(yahoo_screen_id: match[1], margin_bottom: '1em')
32
+ elsif iframe_url.include?('www.youtube.com') && (match = iframe_url.match("www\.youtube\.com\/.*\/([a-zA-Z0-9]+)"))
33
+ haml.youtube_widget(youtube_id: match[1], margin_bottom: '1em')
35
34
  else
36
35
  puts "-- unhandled iframe: #{iframe_url}"
37
36
  end
38
37
  else
39
38
  puts "-- unhandled figure: #{chunk.children.first.name}"
40
39
  end
41
- when "div"
42
- if chunk.attribute("class").to_s == "sponlogo"
43
- haml.container_widget background_color: "white", padding_left: "1em", padding_right: "1em", padding_bottom: "0.5em", padding_top: "1em" do
44
- haml.columns_widget columns: "3x9" do |row|
40
+ when 'div'
41
+ if chunk.attribute('class').to_s == 'sponlogo'
42
+ haml.container_widget background_color: 'white', padding_left: '1em', padding_right: '1em', padding_bottom: '0.5em', padding_top: '1em' do
43
+ haml.columns_widget columns: '3x9' do |row|
45
44
  haml.column row do
46
- process_chunk(chunk.children()[0])
45
+ process_chunk(chunk.children[0])
47
46
  end
48
47
  haml.column row do
49
- haml.paragraph_widget({align: "right"}, chunk.children()[1].text)
48
+ haml.paragraph_widget({ align: 'right' }, chunk.children[1].text)
50
49
  end
51
50
  end
52
51
  end
@@ -61,5 +60,4 @@ class TumblrTemplate < Hamloft::Template
61
60
  puts "-- unhandled chunk: #{chunk.name}"
62
61
  end
63
62
  end
64
-
65
63
  end
@@ -1,41 +1,4 @@
1
- -# ROOT DROP CONTAINER
2
- - drop_container
3
-
4
- -# ROOT CONTAINER
5
- - container_widget min_height: "calc(100vh - 92px)", parallax_effect: "fixed", image_source: variable(:background_url, asset("images/bg/pastel-01.jpg")), image_size: "cover", background_color: "overlay", image_position: "top center" do
6
-
7
- -# TOP PAGE CONTAINER
8
- - container_widget min_height: "calc(100vh - 92px)" do
9
-
10
- -# FIXED CONTAINER
11
- - container_widget animate: "fade-in-down scroll-animate", style: "fixed", padding_top: "30vh", padding_left: "10vw", padding_right: "10vw" do
12
-
13
- -# MAIN HEADING
14
- - heading_widget align: "left", style: "feature" do
15
- - style :bold, color: "#FFFFFF" do
16
- = variable(:title, "WHY I DESIGN?")
17
-
18
- - horizontal_rule_widget style: "flourish-01", color: "light"
19
-
20
- -# CENTER CONTAINER
21
- - container_widget style: "thin", background_color: "custom", bg_color: "rgba(255, 255, 255, 0.95)", padding_top: "1em", margin_bottom: "6em", animate: "fade-in-up" do
22
-
23
- - container_widget padding_left: "1em", padding_right: "1em" do
24
-
25
- - button_widget style: "success", href: "#scroll-next" do
26
- - style :bold, color: "#FFFFFF" do
27
- BEGIN
28
-
29
- -# HEADER CONTAINER
30
- - container_widget parallax_effect: "up", image_source: variable(:image_url, asset("images/base/bg/stripes.jpg")), margin_left: "1em", margin_right: "1em", margin_top: "1em", padding_top: "2em", padding_bottom: "2em", padding_left: "2em", padding_right: "2em" do
31
- - heading_widget type: "h2", align: "center", style: "feature" do
32
- - style :bold, color: "#FFFFFF" do
33
- = variable(:title, "WHY I DESIGN?")
34
-
35
- -# BODY CONTAINER
36
- - container_widget padding_top: "2em", padding_left: "0em", padding_right: "0em" do
37
- - parse_html(:html, :tumblr)
38
-
39
- - button_widget style: "success", href: "#scroll-top" do
40
- - style :bold, color: "#FFFFFF" do
41
- BACK
1
+ - sample_widget do
2
+ SAMPLE
3
+ - sample_widget do
4
+ = variable(:title)
@@ -0,0 +1,19 @@
1
+ class SampleWidget < Hamloft::Widget
2
+ include Hamloft::Helpers
3
+ attr_accessor :options
4
+
5
+ def identifier
6
+ 'sample'
7
+ end
8
+
9
+ module Helpers
10
+ def sample_widget(options = {}, contents = nil, &block)
11
+ widget_block(SampleWidget.new(options)) do |_widget|
12
+ haml_tag :div, class: 'sample' do
13
+ haml_concat(contents) if contents
14
+ yield if block
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
data/spec/hamloft_spec.rb CHANGED
@@ -1,16 +1,10 @@
1
1
  require 'hamloft'
2
2
  RSpec.describe Hamloft do
3
-
4
- it "renders a custom hamloft template" do
5
-
6
- require_relative "fixtures/template/tumblr.rb"
7
- Hamloft.register_template(:tumblr, TumblrTemplate)
8
-
9
- haml = File.read("spec/fixtures/test.haml")
10
- results = Hamloft.render(haml, {
11
- html: "<p>foo</p><p>bar</p>"
12
- })
3
+ it 'renders a custom hamloft widget' do
4
+ require_relative 'fixtures/widget/sample.rb'
5
+ Hamloft.register_widget(SampleWidget)
6
+ haml = File.read('spec/fixtures/test.haml')
7
+ results = Hamloft.render(haml, title: 'TEST TITLE')
13
8
  expect(results).to be_kind_of String
14
9
  end
15
-
16
10
  end
data/spec/spec_helper.rb CHANGED
@@ -41,57 +41,55 @@ RSpec.configure do |config|
41
41
  mocks.verify_partial_doubles = true
42
42
  end
43
43
 
44
- # The settings below are suggested to provide a good initial experience
45
- # with RSpec, but feel free to customize to your heart's content.
46
- =begin
47
- # These two settings work together to allow you to limit a spec run
48
- # to individual examples or groups you care about by tagging them with
49
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
50
- # get run.
51
- config.filter_run :focus
52
- config.run_all_when_everything_filtered = true
53
-
54
- # Allows RSpec to persist some state between runs in order to support
55
- # the `--only-failures` and `--next-failure` CLI options. We recommend
56
- # you configure your source control system to ignore this file.
57
- config.example_status_persistence_file_path = "spec/examples.txt"
58
-
59
- # Limits the available syntax to the non-monkey patched syntax that is
60
- # recommended. For more details, see:
61
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
63
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
64
- config.disable_monkey_patching!
65
-
66
- # This setting enables warnings. It's recommended, but in some cases may
67
- # be too noisy due to issues in dependencies.
68
- config.warnings = true
69
-
70
- # Many RSpec users commonly either run the entire suite or an individual
71
- # file, and it's useful to allow more verbose output when running an
72
- # individual spec file.
73
- if config.files_to_run.one?
74
- # Use the documentation formatter for detailed output,
75
- # unless a formatter has already been configured
76
- # (e.g. via a command-line flag).
77
- config.default_formatter = 'doc'
78
- end
79
-
80
- # Print the 10 slowest examples and example groups at the
81
- # end of the spec run, to help surface which specs are running
82
- # particularly slow.
83
- config.profile_examples = 10
84
-
85
- # Run specs in random order to surface order dependencies. If you find an
86
- # order dependency and want to debug it, you can fix the order by providing
87
- # the seed, which is printed after each run.
88
- # --seed 1234
89
- config.order = :random
90
-
91
- # Seed global randomization in this process using the `--seed` CLI option.
92
- # Setting this allows you to use `--seed` to deterministically reproduce
93
- # test failures related to randomization by passing the same `--seed` value
94
- # as the one that triggered the failure.
95
- Kernel.srand config.seed
96
- =end
44
+ # The settings below are suggested to provide a good initial experience
45
+ # with RSpec, but feel free to customize to your heart's content.
46
+ # # These two settings work together to allow you to limit a spec run
47
+ # # to individual examples or groups you care about by tagging them with
48
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # # get run.
50
+ # config.filter_run :focus
51
+ # config.run_all_when_everything_filtered = true
52
+ #
53
+ # # Allows RSpec to persist some state between runs in order to support
54
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
55
+ # # you configure your source control system to ignore this file.
56
+ # config.example_status_persistence_file_path = "spec/examples.txt"
57
+ #
58
+ # # Limits the available syntax to the non-monkey patched syntax that is
59
+ # # recommended. For more details, see:
60
+ # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
+ # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
63
+ # config.disable_monkey_patching!
64
+ #
65
+ # # This setting enables warnings. It's recommended, but in some cases may
66
+ # # be too noisy due to issues in dependencies.
67
+ # config.warnings = true
68
+ #
69
+ # # Many RSpec users commonly either run the entire suite or an individual
70
+ # # file, and it's useful to allow more verbose output when running an
71
+ # # individual spec file.
72
+ # if config.files_to_run.one?
73
+ # # Use the documentation formatter for detailed output,
74
+ # # unless a formatter has already been configured
75
+ # # (e.g. via a command-line flag).
76
+ # config.default_formatter = 'doc'
77
+ # end
78
+ #
79
+ # # Print the 10 slowest examples and example groups at the
80
+ # # end of the spec run, to help surface which specs are running
81
+ # # particularly slow.
82
+ # config.profile_examples = 10
83
+ #
84
+ # # Run specs in random order to surface order dependencies. If you find an
85
+ # # order dependency and want to debug it, you can fix the order by providing
86
+ # # the seed, which is printed after each run.
87
+ # # --seed 1234
88
+ # config.order = :random
89
+ #
90
+ # # Seed global randomization in this process using the `--seed` CLI option.
91
+ # # Setting this allows you to use `--seed` to deterministically reproduce
92
+ # # test failures related to randomization by passing the same `--seed` value
93
+ # # as the one that triggered the failure.
94
+ # Kernel.srand config.seed
97
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamloft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.6'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.3'
47
+ version: '3.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.3'
54
+ version: '3.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.32'
75
+ version: '0.49'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.32'
82
+ version: '0.49'
83
83
  description: This gem contains template built parser for creating MagLoft theme templates.
84
84
  email:
85
85
  - tobias.strebitzer@magloft.com
@@ -102,6 +102,7 @@ files:
102
102
  - lib/hamloft/widget.rb
103
103
  - spec/fixtures/template/tumblr.rb
104
104
  - spec/fixtures/test.haml
105
+ - spec/fixtures/widget/sample.rb
105
106
  - spec/hamloft_spec.rb
106
107
  - spec/spec_helper.rb
107
108
  homepage: http://www.magloft.com
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.6.6
128
+ rubygems_version: 2.6.10
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: Hamloft - MagLoft Widget Parser.