jahuty 3.3.1 → 3.4.0

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
  SHA256:
3
- metadata.gz: b7f9dd15bdc516d3e7249bba915822f742642f59c7209f47151b963ba34b53d1
4
- data.tar.gz: 11bb09b250f358f13d5cafb3a585a1db525ddf988b6fea70dd19c7586a5a77a3
3
+ metadata.gz: dc03377d980089b275af98c4bbd57d56c9a5a7e017bd9bce90dd53c299340be7
4
+ data.tar.gz: d7b0463dbfd93a713cf4c718e3ef175926af4228a69d72c6798ae7ae033e1b06
5
5
  SHA512:
6
- metadata.gz: 42ee47a4e2e936a10c4e14bee9990db9c170e53e852d257190cf7636d8c27ce6e7f4da04eeb1cf1ea333e00f65ffc7ed1847b0a47ec4c7ea024d067ee9bca196
7
- data.tar.gz: e1ec48bb180b4f81145f4a6b939bc3a9fe64a792bbb7a513b705b49e61b4ac379dfbc0c38fb12880122282d12816d90c8798ca6b283bb8fce6befe5777eb3174
6
+ metadata.gz: ae1da4327c9e6e5c8bcc91f95e10f37c8d2eed73cd9b569d6b9f369f4261c2b73ee78f693b2b7d60274b33e40bb0417743638c92a2130bb9bd05492c4cd78f27
7
+ data.tar.gz: 9bdc2c24d3b666d17106329bd34ba18cc6643322b1b45905ef9dd1e3503f1889fb1bf7320e55e4ffca864300f39643c273782a27f7b4c0c8902730dc427d47fe
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.4.0] - 2021-07-29
9
+
10
+ ### Added
11
+
12
+ - Support for Ruby 3.
13
+ - Builds for the latest versions of Ruby 2.6.x, 2.7.x, and 3.0.x.
14
+ - A `location` parameter to the `render` method to enable display tracking.
15
+
8
16
  ## 3.3.1 - 2021-05-02
9
17
 
10
18
  ### Fixed
data/README.md CHANGED
@@ -6,14 +6,18 @@ Welcome to the [Ruby SDK](https://docs.jahuty.com/sdks/ruby) for [Jahuty's API](
6
6
 
7
7
  ## Installation
8
8
 
9
- This library requires [Ruby 2.6+](https://www.ruby-lang.org/en/downloads/releases/).
9
+ This library is tested with the following [Ruby versions](https://www.ruby-lang.org/en/downloads/releases/):
10
+
11
+ * MRI 2.6.8
12
+ * MRI 2.7.4
13
+ * MRI 3.0.2
10
14
 
11
15
  It is multi-platform, and we strive to make it run equally well on Windows, Linux, and OSX.
12
16
 
13
17
  To install, add this line to your application's `Gemfile` and run `bundle install`:
14
18
 
15
19
  ```ruby
16
- gem 'jahuty', '~> 3.3'
20
+ gem 'jahuty', '~> 3.4'
17
21
  ```
18
22
 
19
23
  ## Usage
@@ -33,11 +37,8 @@ jahuty = Jahuty::Client.new(api_key: 'YOUR_API_KEY')
33
37
 
34
38
  render = jahuty.snippets.render YOUR_SNIPPET_ID
35
39
 
36
- a = render.to_s
37
-
38
- b = render.content
39
-
40
- a == b # returns true
40
+ render.to_s
41
+ render.content
41
42
  ```
42
43
 
43
44
  In an HTML view:
@@ -61,16 +62,14 @@ jahuty = Jahuty::Client.new(api_key: 'YOUR_API_KEY')
61
62
 
62
63
  renders = jahuty.snippets.all_renders 'YOUR_TAG'
63
64
 
64
- renders.each { |render| puts render }
65
+ renders.each { |r| puts r }
65
66
  ```
66
67
 
67
68
  ## Rendering content
68
69
 
69
- You can use the `prefer_latest` configuration option to render a snippet's _latest_ content to your team in _development_ and its _published_ content to your customers in _production_.
70
-
71
70
  By default, Jahuty will render a snippet's _published_ content, the content that existed the last time someone clicked the "Publish" button, to avoid exposing your creative process to customers.
72
71
 
73
- To render a snippet's _latest_ content, the content that currently exists in the editor, you can use the `prefer_latest` configuration option at the library or render level:
72
+ You can use the `prefer_latest` configuration option, however, to render a snippet's _latest_ content, the content that currently exists in the editor. This allows you to render a snippet's _latest_ content to your team in _development_ and its _published_ content to your customers in _production_.
74
73
 
75
74
  ```ruby
76
75
  jahuty = Jahuty::Client.new api_key: 'YOUR_API_KEY', prefer_latest: true
@@ -134,6 +133,19 @@ jahuty.snippets.all_renders 'YOUR_TAG', params: {
134
133
  }
135
134
  ```
136
135
 
136
+ ## Tracking renders
137
+
138
+ You can record where snippets are rendered using the `location` configuration option. This helps your team preview their changes, and it helps you find and replace deprecated snippets.
139
+
140
+ ```ruby
141
+ jahuty = Jahuty::Client.new(api_key: 'YOUR_API_KEY')
142
+
143
+ render = jahuty.snippets.render YOUR_SNIPPET_ID, location: 'https://example.com'
144
+ ]);
145
+ ```
146
+
147
+ Note, this configuration option is only supported by the `render` method, not the `all_renders` method, and locations are only reported when a request is sent to Jahuty's API. As a result of this limitation, locations may not be reported in all scenarios. For example, if a call to `render` results in a cache hit, the location will not be reported.
148
+
137
149
  ## Caching for performance
138
150
 
139
151
  You can use caching to control how frequently this library requests the latest content from Jahuty's API.
@@ -165,10 +177,7 @@ A persistent cache allows renders to be cached across multiple requests. This re
165
177
  To configure Jahuty to use your persistent cache, pass a cache implementation to the client via the `cache` configuration option:
166
178
 
167
179
  ```ruby
168
- jahuty = new Jahuty::Client.new(
169
- api_key: 'YOUR_API_KEY',
170
- cache: cache
171
- )
180
+ jahuty = new Jahuty::Client.new(api_key: 'YOUR_API_KEY', cache: cache)
172
181
  ```
173
182
 
174
183
  The persistent cache implementation you choose and configure is up to you. There are many libraries available, and most frameworks provide their own. At this time, we support any object which responds to `get(key)`/`set(key, value, expires_in:)` or `read(key)`/`write(key, value, expires_in:)` including [ActiveSupport::Cache::Store](https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-fetch).
@@ -190,11 +199,8 @@ You can usually configure your caching implementation with a default `:expires_i
190
199
  You can configure a default `:expires_in` for all of this library's renders by passing an integer number of seconds via the client's `:expires_in` configuration option:
191
200
 
192
201
  ```ruby
193
- jahuty = Jahuty::Client.new(
194
- api_key: 'YOUR_API_KEY',
195
- cache: cache,
196
- expires_in: 60 # <- Cache all renders for sixty seconds
197
- )
202
+ # Cache all renders for sixty seconds.
203
+ jahuty = Jahuty::Client.new(api_key: 'YOUR_API_KEY', cache: cache, expires_in: 60)
198
204
  ```
199
205
 
200
206
  If this library's default `:expires_in` is set, it will take precedence over the default `:expires_in` of the caching implementation.
@@ -224,11 +230,11 @@ By default, this library will cache each render returned by `all_renders`:
224
230
  jahuty = Jahuty::Client.new(api_key: 'YOUR_API_KEY', cache: cache)
225
231
 
226
232
  # Sends a network request, caches each render, and returns the collection.
227
- jahuty.snippets.all_renders 'YOUR_TAG';
233
+ jahuty.snippets.all_renders 'YOUR_TAG'
228
234
 
229
235
  # If this reder exists in the collection, the cached value will be used instead
230
236
  # of sending a network request for the latest version.
231
- jahuty.snippets.render YOUR_SNIPPET_ID;
237
+ jahuty.snippets.render YOUR_SNIPPET_ID
232
238
  ```
233
239
 
234
240
  This is a powerful feature, especially when combined with a persistent cache. Using the `all_renders` method, you can render and cache an arbitrarily large chunk of content with a single network request. Because any subsequent call to `render` a snippet in the collection will use its cached version, you can reduce the number of network requests to load your content.
@@ -18,7 +18,7 @@ module Jahuty
18
18
  raise ArgumentError.new, 'Key :type missing' unless data.key?(:type)
19
19
  raise ArgumentError.new, 'Key :detail missing' unless data.key?(:detail)
20
20
 
21
- Problem.new(data.slice(:status, :type, :detail))
21
+ Problem.new(**data.slice(:status, :type, :detail))
22
22
  end
23
23
  end
24
24
  end
@@ -15,7 +15,7 @@ module Jahuty
15
15
  raise ArgumentError.new, 'Key :content missing' unless data.key?(:content)
16
16
  raise ArgumentError.new, 'Key :snippet_id missing' unless data.key?(:snippet_id)
17
17
 
18
- Render.new(data.slice(:content, :snippet_id))
18
+ Render.new(**data.slice(:content, :snippet_id))
19
19
  end
20
20
 
21
21
  def to_s
@@ -20,15 +20,15 @@ module Jahuty
20
20
  renders
21
21
  end
22
22
 
23
- def render(snippet_id, params: {}, expires_in: @expires_in, prefer_latest: @prefer_latest)
23
+ def render(snippet_id, params: {}, expires_in: @expires_in, prefer_latest: @prefer_latest, location: nil)
24
24
  key = cache_key snippet_id: snippet_id, params: params, latest: prefer_latest
25
25
 
26
- render = @cache.read(key)
26
+ render = @cache.read key
27
27
 
28
28
  @cache.delete key unless render.nil? || cacheable?(expires_in)
29
29
 
30
30
  if render.nil?
31
- render = show_render snippet_id: snippet_id, params: params, prefer_latest: prefer_latest
31
+ render = show_render snippet_id: snippet_id, params: params, prefer_latest: prefer_latest, location: location
32
32
 
33
33
  @cache.write key, render, expires_in: expires_in if cacheable?(expires_in)
34
34
  end
@@ -81,10 +81,11 @@ module Jahuty
81
81
  @client.request action
82
82
  end
83
83
 
84
- def show_render(snippet_id:, params: {}, prefer_latest: false)
84
+ def show_render(snippet_id:, params: {}, prefer_latest: false, location: nil)
85
85
  request_params = {}
86
86
  request_params[:params] = params.to_json unless params.empty?
87
87
  request_params[:latest] = 1 if prefer_latest
88
+ request_params[:location] = location unless location.nil?
88
89
 
89
90
  action = ::Jahuty::Action::Show.new(
90
91
  id: snippet_id,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jahuty
4
- VERSION = '3.3.1'
4
+ VERSION = '3.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jahuty
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Clayton
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-02 00:00:00.000000000 Z
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-packaging
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.5'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rubocop-performance
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -185,18 +199,9 @@ executables: []
185
199
  extensions: []
186
200
  extra_rdoc_files: []
187
201
  files:
188
- - ".circleci/config.yml"
189
- - ".gitignore"
190
- - ".rspec"
191
- - ".rubocop.yml"
192
202
  - CHANGELOG.md
193
- - Gemfile
194
203
  - LICENSE
195
204
  - README.md
196
- - Rakefile
197
- - bin/console
198
- - bin/setup
199
- - jahuty.gemspec
200
205
  - lib/jahuty.rb
201
206
  - lib/jahuty/action/base.rb
202
207
  - lib/jahuty/action/index.rb
@@ -223,13 +228,13 @@ metadata:
223
228
  homepage_uri: https://www.jahuty.com
224
229
  source_code_uri: https://github.com/jahuty/jahuty-ruby
225
230
  changelog_uri: https://github.com/jahuty/jahuty-ruby/blob/master/CHANGELOG.md
226
- post_install_message:
231
+ post_install_message:
227
232
  rdoc_options: []
228
233
  require_paths:
229
234
  - lib
230
235
  required_ruby_version: !ruby/object:Gem::Requirement
231
236
  requirements:
232
- - - "~>"
237
+ - - ">="
233
238
  - !ruby/object:Gem::Version
234
239
  version: '2.6'
235
240
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -238,8 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
243
  - !ruby/object:Gem::Version
239
244
  version: '0'
240
245
  requirements: []
241
- rubygems_version: 3.1.6
242
- signing_key:
246
+ rubygems_version: 3.2.22
247
+ signing_key:
243
248
  specification_version: 4
244
249
  summary: Jahuty's Ruby SDK.
245
250
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,33 +0,0 @@
1
- version: 2.1
2
- orbs:
3
- ruby: circleci/ruby@0.1.2
4
- codecov: codecov/codecov@1.1.3
5
- jobs:
6
- build:
7
- docker:
8
- - image: circleci/ruby:2.6.3-stretch-node
9
- executor: ruby/default
10
- steps:
11
- - checkout
12
- - run:
13
- name: Update bundler
14
- command: gem install bundler
15
- - run:
16
- name: Which bundler?
17
- command: bundle -v
18
- - ruby/bundle-install
19
- - run:
20
- name: Run rubocop
21
- command: bundle exec rake rubocop
22
- - run:
23
- name: Run specs
24
- command: |
25
- bundle exec rspec --profile 10 \
26
- --format RspecJunitFormatter \
27
- --out test_results/rspec.xml \
28
- --format progress \
29
- $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
30
- - store_test_results:
31
- path: test_results
32
- - codecov/upload:
33
- file: ./coverage/coverage.xml
data/.gitignore DELETED
@@ -1,45 +0,0 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
- /tmp/
12
-
13
- # RSpec artifacts
14
- .rspec_status
15
-
16
- # Used by dotenv library to load environment variables.
17
- .env
18
-
19
- ## Specific to RubyMotion:
20
- .dat*
21
- .repl_history
22
- build/
23
- *.bridgesupport
24
- build-iPhoneOS/
25
- build-iPhoneSimulator/
26
-
27
- ## Documentation cache and generated files:
28
- /.yardoc/
29
- /_yardoc/
30
- /doc/
31
- /rdoc/
32
-
33
- ## Environment normalization:
34
- /.bundle/
35
- /vendor/bundle
36
- /lib/bundler/man/
37
-
38
- # for a library or gem, you might want to ignore these files since the code is
39
- # intended to run in multiple environments; otherwise, check them in:
40
- Gemfile.lock
41
- .ruby-version
42
- .ruby-gemset
43
-
44
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
45
- .rvmrc
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,23 +0,0 @@
1
- require:
2
- - rubocop-performance
3
- - rubocop-rspec
4
- AllCops:
5
- TargetRubyVersion: 2.6
6
- NewCops: enable
7
- Exclude:
8
- - vendor/bundle/**/*
9
- Metrics/BlockLength:
10
- Exclude:
11
- - 'jahuty.gemspec'
12
- - 'Rakefile'
13
- - '**/*.rake'
14
- - 'spec/**/*.rb'
15
- Metrics/ModuleLength:
16
- Exclude:
17
- - 'spec/**/*.rb'
18
- RSpec/ExampleLength:
19
- Exclude:
20
- - 'spec/jahuty/system_spec.rb'
21
- RSpec/MultipleExpectations:
22
- Exclude:
23
- - 'spec/jahuty/system_spec.rb'
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in jahuty.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
-
9
- task default: :spec
10
-
11
- RuboCop::RakeTask.new do |task|
12
- task.requires << 'rubocop-performance'
13
- task.requires << 'rubocop-rspec'
14
- end
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'jahuty/snippets'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- # frozen_string_literal: true
3
-
4
- set -euo pipefail
5
- IFS=$'\n\t'
6
- set -vx
7
-
8
- bundle install
9
-
10
- # Do any other automated setup that you need to do here
data/jahuty.gemspec DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'jahuty/version'
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = 'jahuty'
10
- spec.version = Jahuty::VERSION
11
- spec.authors = ['Jack Clayton']
12
- spec.email = ['jack@jahuty.com']
13
-
14
- spec.summary = 'Jahuty\'s Ruby SDK.'
15
- spec.description = 'Turn any page into a content-managed page.'
16
- spec.homepage = 'https://www.jahuty.com'
17
- spec.license = 'MIT'
18
-
19
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
-
21
- spec.metadata['homepage_uri'] = spec.homepage
22
- spec.metadata['source_code_uri'] = 'https://github.com/jahuty/jahuty-ruby'
23
- spec.metadata['changelog_uri'] = 'https://github.com/jahuty/jahuty-ruby/blob/master/CHANGELOG.md'
24
-
25
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- end
28
- spec.bindir = 'exe'
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ['lib']
31
-
32
- spec.required_ruby_version = '~> 2.6'
33
-
34
- spec.add_dependency 'faraday', '~> 1.0'
35
- spec.add_dependency 'mini_cache', '~> 1.1'
36
-
37
- spec.add_development_dependency 'bundler', '~> 2.0'
38
- spec.add_development_dependency 'rake', '~> 12.3'
39
- spec.add_development_dependency 'rspec', '~> 3.0'
40
- spec.add_development_dependency 'rspec_junit_formatter', '~>0.4'
41
- spec.add_development_dependency 'rubocop', '~> 1.7'
42
- spec.add_development_dependency 'rubocop-performance', '~> 1.9'
43
- spec.add_development_dependency 'rubocop-rspec', '~> 2.1'
44
- spec.add_development_dependency 'simplecov', '~>0.20'
45
- spec.add_development_dependency 'simplecov-cobertura', '~> 1.4'
46
- spec.add_development_dependency 'webmock', '~> 3.11'
47
- end