gretel-jsonld 0.1.1 → 0.2.0

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: 3ee0aa4c582e0ed7f3be4f2b3b45a68fbc91b307
4
- data.tar.gz: 3c6e4229650d0c54bb5f85a63e6286fc5f929ea8
3
+ metadata.gz: b148016c75478dd947e087855608b34439be9ba8
4
+ data.tar.gz: ab4814c23a2a01042724350f8ea5fae3321dab89
5
5
  SHA512:
6
- metadata.gz: 845201072ef51ec8237ab5c78bb58bb9cafc8b352fdffa1aa1067813fbf05d4983eed2b7a6859cd20c55ca35d3b5482e367d8fcd490f072228911239eef925c1
7
- data.tar.gz: 4af53b5deea25b7afd2a95614b0fbef8e677eca5e3bf8d01ee03ccaf60c376d75388805bf6153a7f7789b89148f89f5b71697335820c51285598e3b12b7b8bc3
6
+ metadata.gz: ccda8ccceb6689db485af211b7ad4d16fefbb17a98f3fcfa0853b6e6545fd3ed696a98a0f1e058f94bec13e16522e1aee4799a820151a376785fe7821cca3447
7
+ data.tar.gz: cce14c004c513533c2c1b8c83772fc941917da428ebbca6d0c16cb844c21401ac429db8f8f39f444326ebe34a6f912ad3ffd20bfe4bf8e915f7b958addad4786
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # CHANGELOG
2
+ ## [0.2.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.2.0) (November 25, 2017)
3
+ * [Write README](https://github.com/yasaichi/gretel-jsonld/pull/7)
4
+ * [Use `JSONLD` as module name instead of `Jsonld`](https://github.com/yasaichi/gretel-jsonld/pull/6)
5
+ * [Specify the required Ruby version](https://github.com/yasaichi/gretel-jsonld/pull/5)
6
+
2
7
  ## [0.1.1](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.1.1) (November 25, 2017)
3
- * Cope with Rails 4.0 or former
8
+ * [Cope with Rails 4.0 or former](https://github.com/yasaichi/gretel-jsonld/pull/4)
4
9
 
5
10
  ## [0.1.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.1.0) (November 23, 2017)
6
11
  * The initial release to reserve the gem name
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
- # Gretel::Jsonld
2
- Short description and motivation.
1
+ # gretel-jsonld
2
+ [![Gem Version](https://badge.fury.io/rb/gretel-jsonld.svg)](http://badge.fury.io/rb/gretel-jsonld)
3
+ [![Build Status](https://travis-ci.org/yasaichi/gretel-jsonld.svg?branch=master)](https://travis-ci.org/yasaichi/gretel-jsonld)
4
+ [![Code Climate](https://api.codeclimate.com/v1/badges/fc3fd5037eb200bedbf5/maintainability)](https://codeclimate.com/github/yasaichi/gretel-jsonld/maintainability)
5
+ [![Test Coverage](https://codeclimate.com/github/yasaichi/gretel-jsonld/badges/coverage.svg)](https://codeclimate.com/github/yasaichi/gretel-jsonld/coverage)
3
6
 
4
- ## Usage
5
- How to use my plugin.
7
+ gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.
6
8
 
7
9
  ## Installation
8
- Add this line to your application's Gemfile:
10
+ Add this line to your application's `Gemfile`:
9
11
 
10
12
  ```ruby
11
13
  gem 'gretel-jsonld'
@@ -16,13 +18,109 @@ And then execute:
16
18
  $ bundle
17
19
  ```
18
20
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install gretel-jsonld
21
+ ## Usage
22
+ First, run the installation generator with:
23
+
24
+ ```sh
25
+ $ rails generate gretel:install
26
+ ```
27
+
28
+ Next, define "crumbs" in `config/breadcrumbs.rb`:
29
+
30
+ ```ruby
31
+ # See also: https://github.com/lassebunk/gretel#more-examples
32
+
33
+ # Root crumb
34
+ crumb :root do
35
+ link 'Home', root_path
36
+ end
37
+
38
+ # Issue list
39
+ crumb :issues do
40
+ link 'All issues', issues_path
41
+ end
42
+
43
+ # Issue
44
+ crumb :issue do |issue|
45
+ link issue.title, issue
46
+ parent :issues
47
+ end
48
+ ```
49
+
50
+ Then, add this line to your application's layout:
51
+
52
+ ```erb
53
+ <%= jsonld_breadcrumbs %>
22
54
  ```
23
55
 
56
+ Finally, specify a current breadcrumb in each view:
57
+
58
+ ```erb
59
+ <% breadcrumb :issue, @issue %>
60
+ ```
61
+
62
+ This will generate the following breadcrumbs, marked up with JSON-LD (indented for readability):
63
+
64
+ ```html
65
+ <script type="application/ld+json">
66
+ {
67
+ "@context":"http://schema.org",
68
+ "@type":"BreadcrumbList",
69
+ "itemListElement":[
70
+ {
71
+ "@type":"ListItem",
72
+ "position":1,
73
+ "item":{
74
+ "@id":"/",
75
+ "name":"Home"
76
+ }
77
+ },
78
+ {
79
+ "@type":"ListItem",
80
+ "position":2,
81
+ "item":{
82
+ "@id":"/issues",
83
+ "name":"All issues"
84
+ }
85
+ },
86
+ {
87
+ "@type":"ListItem",
88
+ "position":3,
89
+ "item":{
90
+ "@id":"/issues/46",
91
+ "name":"My Issue"
92
+ }
93
+ }
94
+ ]
95
+ }
96
+ </script>
97
+ ```
98
+
99
+ ## Options
100
+
101
+ You can pass `jsonld_breadcrumbs` the same options as `breadcrumbs`:
102
+
103
+ ```erb
104
+ <%= jsonld_breadcrumbs link_current_to_request_path: false %>
105
+ ```
106
+
107
+ For further information, please see [gretel's documentation](https://github.com/lassebunk/gretel/blob/master/README.md#options).
108
+
109
+ ## Supported versions
110
+ Note that gretel-jsonld doesn't support all versions of gretel, Ruby and Rails:
111
+
112
+ * gretel: gretel-jsonld supports __only 3.x__ for now
113
+ * Ruby: gretel 3.x supports __1.9.3 or later__, but gretel-jsonld does __only 2.2.2 or later__
114
+ * Rails: gretel 3.x supports __3.1 or later__, but gretel-jsonld does __only 3.2 or later__
115
+
24
116
  ## Contributing
25
- Contribution directions go here.
117
+ You should follow the steps below:
118
+
119
+ 1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
120
+ 2. Create a feature branch: `git checkout -b add-new-feature`
121
+ 3. Commit your changes: `git commit -am 'Add new feature'`
122
+ 4. Push the branch: `git push origin add-new-feature`
123
+ 4. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
26
124
 
27
125
  ## License
28
126
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ require "rdoc/task"
10
10
 
11
11
  RDoc::Task.new(:rdoc) do |rdoc|
12
12
  rdoc.rdoc_dir = "rdoc"
13
- rdoc.title = "Gretel::Jsonld"
13
+ rdoc.title = "Gretel::JSONLD"
14
14
  rdoc.options << "--line-numbers"
15
15
  rdoc.rdoc_files.include("README.md")
16
16
  rdoc.rdoc_files.include("lib/**/*.rb")
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
+ require "active_support"
5
+ require "active_support/json/encoding"
4
6
  require "gretel/jsonld/breadcrumb/list_item"
5
7
 
6
8
  module Gretel
7
- module Jsonld
9
+ module JSONLD
8
10
  module Breadcrumb
9
11
  class List
10
12
  def initialize(link_collection)
@@ -28,7 +30,7 @@ module Gretel
28
30
 
29
31
  def item_list_element
30
32
  @link_collection.map.with_index(1) do |link, index|
31
- ::Gretel::Jsonld::Breadcrumb::ListItem.new(
33
+ ::Gretel::JSONLD::Breadcrumb::ListItem.new(
32
34
  id: link.url,
33
35
  name: link.text,
34
36
  position: index,
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
+ require "active_support"
5
+ require "active_support/json/encoding"
4
6
 
5
7
  module Gretel
6
- module Jsonld
8
+ module JSONLD
7
9
  module Breadcrumb
8
10
  class ListItem
9
11
  def initialize(id:, name:, position:)
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support"
3
4
  require "active_support/lazy_load_hooks"
4
5
  require "rails/railtie"
5
6
 
6
7
  module Gretel
7
- module Jsonld
8
+ module JSONLD
8
9
  class Railtie < ::Rails::Railtie
9
10
  initializer "gretel.jsonld" do
10
11
  ::ActiveSupport.on_load(:action_view) do
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
+ require "active_support"
5
+ require "active_support/core_ext/string/output_safety"
4
6
  require "gretel/jsonld/breadcrumb/list"
5
7
 
6
8
  module Gretel
7
- module Jsonld
9
+ module JSONLD
8
10
  class Renderer
9
11
  def initialize(view_context)
10
12
  @view_context = view_context
@@ -15,7 +17,7 @@ module Gretel
15
17
 
16
18
  @view_context.content_tag(
17
19
  :script,
18
- JSON.generate(::Gretel::Jsonld::Breadcrumb::List.new(link_collection)).html_safe,
20
+ JSON.generate(::Gretel::JSONLD::Breadcrumb::List.new(link_collection)).html_safe,
19
21
  type: "application/ld+json",
20
22
  )
21
23
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gretel
4
- module Jsonld
5
- VERSION = "0.1.1"
4
+ module JSONLD
5
+ VERSION = "0.2.0".freeze
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ require "gretel"
5
5
  require "gretel/jsonld/renderer"
6
6
 
7
7
  module Gretel
8
- module Jsonld
8
+ module JSONLD
9
9
  module ViewHelpers
10
10
  def jsonld_breadcrumbs(options = {})
11
11
  gretel_jsonld_renderer.render(breadcrumbs(options))
@@ -14,10 +14,10 @@ module Gretel
14
14
  private
15
15
 
16
16
  def gretel_jsonld_renderer
17
- @_gretel_jsonld_renderer ||= ::Gretel::Jsonld::Renderer.new(self)
17
+ @_gretel_jsonld_renderer ||= ::Gretel::JSONLD::Renderer.new(self)
18
18
  end
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
- ActionView::Base.include(Gretel::Jsonld::ViewHelpers)
23
+ ActionView::Base.include(Gretel::JSONLD::ViewHelpers)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel-jsonld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasaichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gretel
@@ -126,7 +126,6 @@ files:
126
126
  - lib/gretel/jsonld/renderer.rb
127
127
  - lib/gretel/jsonld/version.rb
128
128
  - lib/gretel/jsonld/view_helpers.rb
129
- - lib/tasks/gretel/jsonld_tasks.rake
130
129
  homepage: https://github.com/yasaichi/gretel-jsonld
131
130
  licenses:
132
131
  - MIT
@@ -139,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
138
  requirements:
140
139
  - - ">="
141
140
  - !ruby/object:Gem::Version
142
- version: '0'
141
+ version: 2.2.2
143
142
  required_rubygems_version: !ruby/object:Gem::Requirement
144
143
  requirements:
145
144
  - - ">="
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
- # desc "Explaining what the task does"
3
- # task :gretel_jsonld do
4
- # # Task goes here
5
- # end