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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 948fab3c8b8bda77a94f6a69efaf79d4529a2bd26d5183eea758e143bac819d6
4
- data.tar.gz: 0f8dfaf771f9d50926b1c8042da5e1a121c6f42ad0af5b2ba4879fd8d7663b67
3
+ metadata.gz: 61b5987684f1e89d4348aa5498aec599ef0c2e7b2af7519ac854ea478f824580
4
+ data.tar.gz: 60bc127f9dc347dad45886e384b252d2d3db49385cc12debf266429c6c70eace
5
5
  SHA512:
6
- metadata.gz: b8a73aa645e540e01355ebc3d75445cafe611b33e3e610bc3b327472f5ed608ea0839f21977348dd8d9a6b69b2c1369f450ae15a9ae7917103c1835e5da0bf1f
7
- data.tar.gz: dfe0afb290abd658c8a2fef352e36aa0141b63e17282bfb476b1829dd32229ffa157eb7b1ba40d77e084a2d3897a3b6cd304545f1058b95a44464f594a3f8a2f
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
@@ -3,7 +3,7 @@ require "faraday"
3
3
  module Jahuty
4
4
  module Service
5
5
  class Connect
6
- URL = "https://www.jahuty.com/api/snippets"
6
+ URL = "https://www.jahuty.com/api"
7
7
 
8
8
  HEADERS = {
9
9
  "Accept": "application/json;q=0.9,*/*;q=0.8",
@@ -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.to_s)
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
 
@@ -1,13 +1,15 @@
1
1
  module Jahuty
2
2
  class Snippet
3
- @@get
3
+ @get
4
4
 
5
- def self.get(id)
6
- raise "API key not set. Did you use Jahuty.key?" unless Jahuty.key?
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
- @@get ||= Service::Get.new(Service::Connect.new.call(Jahuty.key))
9
+ @get ||= Service::Get.new(Service::Connect.new.call(Jahuty.key))
9
10
 
10
- @@get.call(id)
11
+ @get.call(id, params)
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,3 @@
1
1
  module Jahuty
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  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: 1.0.0
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-09 00:00:00.000000000 Z
11
+ date: 2020-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday