gretel-jsonld 0.1.1 → 0.3.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
- SHA1:
3
- metadata.gz: 3ee0aa4c582e0ed7f3be4f2b3b45a68fbc91b307
4
- data.tar.gz: 3c6e4229650d0c54bb5f85a63e6286fc5f929ea8
2
+ SHA256:
3
+ metadata.gz: 1e7bf55860ae8f21a3d5a931806e9c550cf4e1d31af9546703d86d125d14c00e
4
+ data.tar.gz: 3286dab9d4dbcc9b9e61a7e4528359ada4e3cb63e59af75a40c765497d2e3c68
5
5
  SHA512:
6
- metadata.gz: 845201072ef51ec8237ab5c78bb58bb9cafc8b352fdffa1aa1067813fbf05d4983eed2b7a6859cd20c55ca35d3b5482e367d8fcd490f072228911239eef925c1
7
- data.tar.gz: 4af53b5deea25b7afd2a95614b0fbef8e677eca5e3bf8d01ee03ccaf60c376d75388805bf6153a7f7789b89148f89f5b71697335820c51285598e3b12b7b8bc3
6
+ metadata.gz: 79b86b733f968da7bca93b29a9ca65486783bb814ebf396d3906ae7ca9646d3b952c36f65a26c99ba191d4edc954ce7af855999b51a320f46ce9d50d7472564c
7
+ data.tar.gz: 16b507af8635110bece74b61f433cc401ae4bf2140414f0ab0ac3c73abb07c9eedc7cb7191b4988660c5d94b760f67c3f648c74cfcbe90530704ec1bafdae804
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # CHANGELOG
2
+ ## [0.3.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.3.0) (July 22, 2026)
3
+ * [Test against Rails 6 through 8](https://github.com/yasaichi/gretel-jsonld/pull/18)
4
+ * [Drop support for Ruby 2.4 and earlier](https://github.com/yasaichi/gretel-jsonld/pull/16)
5
+
6
+ ## [0.2.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.2.0) (November 25, 2017)
7
+ * [Write README](https://github.com/yasaichi/gretel-jsonld/pull/7)
8
+ * [Use `JSONLD` as module name instead of `Jsonld`](https://github.com/yasaichi/gretel-jsonld/pull/6)
9
+ * [Specify the required Ruby version](https://github.com/yasaichi/gretel-jsonld/pull/5)
10
+
2
11
  ## [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
12
+ * [Cope with Rails 4.0 or former](https://github.com/yasaichi/gretel-jsonld/pull/4)
4
13
 
5
14
  ## [0.1.0](https://github.com/yasaichi/gretel-jsonld/releases/tag/v0.1.0) (November 23, 2017)
6
15
  * The initial release to reserve the gem name
data/README.md CHANGED
@@ -1,28 +1,133 @@
1
- # Gretel::Jsonld
2
- Short description and motivation.
1
+ # gretel-jsonld
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ [![Gem Version](https://badge.fury.io/rb/gretel-jsonld.svg)](http://badge.fury.io/rb/gretel-jsonld)
4
+ [![CI](https://github.com/yasaichi/gretel-jsonld/actions/workflows/ci.yml/badge.svg)](https://github.com/yasaichi/gretel-jsonld/actions/workflows/ci.yml)
5
+ [![Maintainability](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld/maintainability.svg)](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld)
6
+ [![Code Coverage](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld/coverage.svg)](https://qlty.sh/gh/yasaichi/projects/gretel-jsonld)
7
+
8
+ gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.
6
9
 
7
10
  ## Installation
8
- Add this line to your application's Gemfile:
11
+
12
+ Add this line to your application's `Gemfile`:
9
13
 
10
14
  ```ruby
11
15
  gem 'gretel-jsonld'
12
16
  ```
13
17
 
14
18
  And then execute:
19
+
15
20
  ```bash
16
21
  $ bundle
17
22
  ```
18
23
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install gretel-jsonld
24
+ ## Usage
25
+
26
+ First, run the installation generator with:
27
+
28
+ ```sh
29
+ $ rails generate gretel:install
30
+ ```
31
+
32
+ Next, define "crumbs" in `config/breadcrumbs.rb`:
33
+
34
+ ```ruby
35
+ # See also: https://github.com/lassebunk/gretel#more-examples
36
+
37
+ # Root crumb
38
+ crumb :root do
39
+ link 'Home', root_path
40
+ end
41
+
42
+ # Issue list
43
+ crumb :issues do
44
+ link 'All issues', issues_path
45
+ end
46
+
47
+ # Issue
48
+ crumb :issue do |issue|
49
+ link issue.title, issue
50
+ parent :issues
51
+ end
52
+ ```
53
+
54
+ Then, add this line to your application's layout:
55
+
56
+ ```erb
57
+ <%= jsonld_breadcrumbs %>
22
58
  ```
23
59
 
60
+ Finally, specify a current breadcrumb in each view:
61
+
62
+ ```erb
63
+ <% breadcrumb :issue, @issue %>
64
+ ```
65
+
66
+ This will generate the following breadcrumbs, marked up with JSON-LD (indented for readability):
67
+
68
+ ```html
69
+ <script type="application/ld+json">
70
+ {
71
+ "@context": "http://schema.org",
72
+ "@type": "BreadcrumbList",
73
+ "itemListElement": [
74
+ {
75
+ "@type": "ListItem",
76
+ "position": 1,
77
+ "item": {
78
+ "@id": "/",
79
+ "name": "Home"
80
+ }
81
+ },
82
+ {
83
+ "@type": "ListItem",
84
+ "position": 2,
85
+ "item": {
86
+ "@id": "/issues",
87
+ "name": "All issues"
88
+ }
89
+ },
90
+ {
91
+ "@type": "ListItem",
92
+ "position": 3,
93
+ "item": {
94
+ "@id": "/issues/46",
95
+ "name": "My Issue"
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ </script>
101
+ ```
102
+
103
+ ## Options
104
+
105
+ You can pass `jsonld_breadcrumbs` the same options as `breadcrumbs`:
106
+
107
+ ```erb
108
+ <%= jsonld_breadcrumbs link_current_to_request_path: false %>
109
+ ```
110
+
111
+ For further information, please see [gretel's documentation](https://github.com/WilHall/gretel/blob/develop/README.md#options).
112
+
113
+ ## Supported versions
114
+
115
+ Note that gretel-jsonld doesn't support all versions of gretel, Ruby and Rails:
116
+
117
+ - gretel: gretel-jsonld supports **only 3.x** for now
118
+ - Ruby: gretel 3.x supports **1.9.3 or later**, but gretel-jsonld does **only 2.5 or later**
119
+ - Rails: gretel 3.x supports **3.1 or later**, but gretel-jsonld does **only 5 or later**
120
+
24
121
  ## Contributing
25
- Contribution directions go here.
122
+
123
+ You should follow the steps below:
124
+
125
+ 1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
126
+ 2. Create a feature branch: `git checkout -b add-new-feature`
127
+ 3. Commit your changes: `git commit -am 'Add new feature'`
128
+ 4. Push the branch: `git push origin add-new-feature`
129
+ 5. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
26
130
 
27
131
  ## License
132
+
28
133
  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.3.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,13 @@
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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasaichi
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: gretel
@@ -94,6 +93,20 @@ dependencies:
94
93
  - - ">="
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop-performance
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: simplecov
99
112
  requirement: !ruby/object:Gem::Requirement
@@ -126,12 +139,10 @@ files:
126
139
  - lib/gretel/jsonld/renderer.rb
127
140
  - lib/gretel/jsonld/version.rb
128
141
  - lib/gretel/jsonld/view_helpers.rb
129
- - lib/tasks/gretel/jsonld_tasks.rake
130
142
  homepage: https://github.com/yasaichi/gretel-jsonld
131
143
  licenses:
132
144
  - MIT
133
145
  metadata: {}
134
- post_install_message:
135
146
  rdoc_options: []
136
147
  require_paths:
137
148
  - lib
@@ -139,16 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
150
  requirements:
140
151
  - - ">="
141
152
  - !ruby/object:Gem::Version
142
- version: '0'
153
+ version: '2.5'
143
154
  required_rubygems_version: !ruby/object:Gem::Requirement
144
155
  requirements:
145
156
  - - ">="
146
157
  - !ruby/object:Gem::Version
147
158
  version: '0'
148
159
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.5.2.1
151
- signing_key:
160
+ rubygems_version: 4.0.16
152
161
  specification_version: 4
153
162
  summary: Gretel extension for supporting JSON-LD breadcrumbs
154
163
  test_files: []
@@ -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