jahuty 1.0.0 → 1.1.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +28 -0
- data/lib/jahuty/service/connect.rb +1 -1
- data/lib/jahuty/service/get.rb +2 -3
- data/lib/jahuty/snippet.rb +7 -5
- data/lib/jahuty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61b5987684f1e89d4348aa5498aec599ef0c2e7b2af7519ac854ea478f824580
|
4
|
+
data.tar.gz: 60bc127f9dc347dad45886e384b252d2d3db49385cc12debf266429c6c70eace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a44d6531dae4b32a3f988e2fdfc1b5c0e28e36823858b47c83fd77a30de09cd73508fbeeb7be1128508fce5d0ec2d6781f5f2e9c5d5b91de14937b886ff686
|
7
|
+
data.tar.gz: 30de9caa1cb3175938899c698f4ab5d0acf8f526b59a213a5450bb87d9c24e9561a0176de18f69a1625d4d2e44b6037082b47d05e1542672107bceae4eb59145
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ 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
|
+
## 1.1.0 - 2020-03-14
|
9
|
+
|
10
|
+
- Add snippet parameters.
|
11
|
+
|
8
12
|
## 1.0.0 - 2020-03-08
|
9
13
|
|
10
14
|
- Update `rake` version.
|
data/README.md
CHANGED
@@ -65,6 +65,34 @@ Jahuty.key = "YOUR_API_KEY"
|
|
65
65
|
</body>
|
66
66
|
```
|
67
67
|
|
68
|
+
## Parameters
|
69
|
+
|
70
|
+
You can [pass parameters](https://www.jahuty.com/docs/passing-a-parameter) into your snippet with an optional second argument:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
require "jahuty"
|
74
|
+
|
75
|
+
Snippet.get(YOUR_SNIPPET_ID, {
|
76
|
+
foo: "bar",
|
77
|
+
baz: ["qux", "quux"],
|
78
|
+
corge: {
|
79
|
+
grault: {
|
80
|
+
garply: "waldo"
|
81
|
+
}
|
82
|
+
}
|
83
|
+
});
|
84
|
+
```
|
85
|
+
|
86
|
+
The parameters above would be equivalent to [assigning the variables](https://www.jahuty.com/docs/assigning-a-variable) below in your snippet:
|
87
|
+
|
88
|
+
```html
|
89
|
+
{% assign foo = "bar" %}
|
90
|
+
{% assign baz = ["qux", "quux"] %}
|
91
|
+
{% assign corge.grault.garply = "waldo" %}
|
92
|
+
```
|
93
|
+
|
94
|
+
## Errors
|
95
|
+
|
68
96
|
If you don't set your API key before calling `Snippet.get`, a `StandardError` will be raised. If an error occurs with [Jahuty's API](https://www.jahuty.com/docs/api), a `NotOk` exception will be raised:
|
69
97
|
|
70
98
|
```ruby
|
data/lib/jahuty/service/get.rb
CHANGED
@@ -6,11 +6,10 @@ module Jahuty
|
|
6
6
|
|
7
7
|
def initialize(connection)
|
8
8
|
@connection = connection
|
9
|
-
|
10
9
|
end
|
11
10
|
|
12
|
-
def call(id)
|
13
|
-
response = @connection.get(id
|
11
|
+
def call(id, params = {})
|
12
|
+
response = @connection.get("snippets/#{id}", { params: params })
|
14
13
|
|
15
14
|
payload = JSON.parse(response.body, symbolize_names: true)
|
16
15
|
|
data/lib/jahuty/snippet.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module Jahuty
|
2
2
|
class Snippet
|
3
|
-
|
3
|
+
@get
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
class << self
|
6
|
+
def get(id, params = {})
|
7
|
+
raise "API key not set. Did you use Jahuty.key?" unless Jahuty.key?
|
7
8
|
|
8
|
-
|
9
|
+
@get ||= Service::Get.new(Service::Connect.new.call(Jahuty.key))
|
9
10
|
|
10
|
-
|
11
|
+
@get.call(id, params)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/jahuty/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Clayton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|