snipp 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -22,6 +22,7 @@ $ gem install snipp
22
22
  ```
23
23
  ## Usage
24
24
  Call `item_tag` like `content_tag`
25
+
25
26
  ```html+ruby
26
27
  <%= item_tag :div, scope: true, type: :review do %>
27
28
  <%= item_tag :span, 'Snipp', prop: :itemreviewd %>
@@ -32,7 +33,9 @@ Call `item_tag` like `content_tag`
32
33
  Rating: <%= item_tag :span, '4.5', prop: :rating %>
33
34
  <% end %>
34
35
  ```
36
+
35
37
  This would output
38
+
36
39
  ```html
37
40
  <div itemscope itemtype="http://data-vocabulary.org/Review">
38
41
  <span itemprop="itemreviewed">Snipp</span>
@@ -45,26 +48,40 @@ This would output
45
48
  ```
46
49
 
47
50
  ### Breadcrumbs
51
+ 1. Define naming routes. You can specify a name for any route using the :as option in Rails Application.
52
+ 2. Setup the Rails Application for Internationalization (i18n).
53
+ 3. Call `breadcrumb` method.
54
+
48
55
  ```html+ruby
49
- <%= breadcrumb [:root, :food, :food_fruit, :food_fruit_red, :food_fruit_red_apple], s: "/" %>
56
+ <%= breadcrumb [:index, :foods, :fruits] %>
50
57
  ```
51
-
52
- link to `root_path`, `food_path`, `food_fruit_path`, `food_fruit_red`, `food_fruit_red_apple`
53
-
54
- Link text
58
+ This would output something like `Top > Foods > Fruits`, if you will set labels in your `Rails.root/config/locales`
55
59
  ```yaml
56
60
  en:
57
61
  views:
58
62
  breadcrumb:
59
63
  # Sample
60
- root: "Top"
61
- food: "Food"
62
- food_fruit: "Fruit"
63
- food_fruit_red: "Red"
64
- food_fruit_red_apple: "Apple"
64
+ index: "Top"
65
+ food: "Foods"
66
+ food_fruit: "Fruits"
67
+ ```
68
+ Link to `root_path`, `food_path`, `food_fruit_path`.
69
+
70
+
71
+ #### Change the separator
72
+ Use the :s or :separator option.
73
+
74
+ ```html+ruby
75
+ <%= breadcrumb [:index, :foods, :fruits], s: "/" %>
76
+ ```
77
+
78
+ #### Use variables and Customize labels
79
+
80
+ ```html+ruby
81
+ <%= breadcrumb [:index, :foods, :fruits, { path: fruits_color_path('Red'), label: 'Red' }, { path: food_path(color: 'Red', name: 'Apple'), label: 'Apple' }], s: "/" %>
65
82
  ```
66
83
 
67
- For more information, read erb files in `app/view/snipp/`
84
+ For more information, read erb files in [`app/view/snipp/`](https://github.com/yulii/snipp/tree/master/app/views/snipp)
68
85
 
69
86
  ## Contributing
70
87
 
data/lib/snipp/config.rb CHANGED
@@ -12,6 +12,7 @@ module Snipp
12
12
 
13
13
  class Configuration #:nodoc:
14
14
  include ActiveSupport::Configurable
15
+ config_accessor :root_url
15
16
  config_accessor :markup
16
17
 
17
18
  def param_name
@@ -15,10 +15,10 @@ module Snipp
15
15
  bc = []
16
16
  paths.each do |e|
17
17
  if e.is_a?(Hash)
18
- body = content_tag :span, I18n.t(e[:label], i18n_options.merge(default: e[:label])), itemprop: :title
18
+ body = item_tag :span, I18n.t(e[:label], i18n_options.merge(default: e[:label])), prop: :title
19
19
  bc.push link_to body, e[:path], itemprop: :url
20
20
  else
21
- body = content_tag :span, I18n.t(e, i18n_options), itemprop: :title
21
+ body = item_tag :span, I18n.t(e, i18n_options), prop: :title
22
22
  bc.push link_to body, send("#{e}_path"), itemprop: :url
23
23
  end
24
24
  end
@@ -34,8 +34,9 @@ module Snipp
34
34
  end
35
35
 
36
36
  def geo latitude, longitude, options = {}
37
+ return unless latitude and longitude
37
38
  item_tag :span, prop: :geo, scope: true, type: :geo, class: "geo" do
38
- "#{content_tag :span, latitude, itemprop: :latitude}#{content_tag :span, longitude, itemprop: :longitude}".html_safe
39
+ "#{item_tag :meta, nil, prop: :latitude, content: latitude}#{item_tag :meta, nil, prop: :longitude, content: longitude}".html_safe
39
40
  end
40
41
  end
41
42
 
@@ -49,7 +50,11 @@ module Snipp
49
50
  item_options = item_options options, escape if options
50
51
  tag_options = tag_options options, escape if options
51
52
  content = if block_given? then capture(&block) else content_or_options_with_block end
52
- "<#{name}#{tag_options}#{item_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>".html_safe
53
+ if content
54
+ "<#{name}#{tag_options}#{item_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>".html_safe
55
+ else
56
+ "<#{name}#{tag_options}#{item_options} />".html_safe
57
+ end
53
58
  end
54
59
 
55
60
  def item_options options, escape = true
data/lib/snipp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Snipp
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -19,8 +19,8 @@ describe Snipp::Markup::Microdata do
19
19
  let(:itemtype) { "http://data-vocabulary.org/Geo" }
20
20
 
21
21
  shared_examples_for 'defined the latitude and longitude' do |e|
22
- it { expect(page).to have_selector('[itemprop="latitude"]', text: e[:latitude], count: 1) }
23
- it { expect(page).to have_selector('[itemprop="longitude"]', text: e[:longitude], count: 1) }
22
+ it { expect(page).to have_selector("[itemprop=\"latitude\"][content=\"#{e[:latitude]}\"]" ,count: 1) }
23
+ it { expect(page).to have_selector("[itemprop=\"longitude\"][content=\"#{e[:longitude]}\"]" ,count: 1) }
24
24
  end
25
25
 
26
26
  describe "geo" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails