plants 0.1.0 → 0.3.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: b8e9b712b2177d93408282db2d2b6efc283fb9fbfb84d17d6fc80efcc58a710b
4
- data.tar.gz: e51872144774793b602adac46640d515ae2a353a07e89fa3beb70d33b50a4ffc
3
+ metadata.gz: 0aa2440db1c107756d88cca164f0dbdb0258dab428bb3c28ab282b09c0dfdbf7
4
+ data.tar.gz: ff4cd3faf204460a05376632b42e762518a7dbdd71d754f7d28f2207433385c1
5
5
  SHA512:
6
- metadata.gz: 3df27aab14d6ed43639c9837cbaa53b4ccf18790929af2f5966d25608735535057f43969c5185d7e4c4b0d7e578acf815ce2b7e30c144f1193760bed8a15ca9f
7
- data.tar.gz: c3094796cde53a394b4b819047e1d1d38c492efb2e20d0b5c736f7ee891a46ce5eca065f43b2a063237fb215fdbf0a8921de19421b68b5cd2ad349c06ea7d31a
6
+ metadata.gz: ba78c624f382d3d63ffba79e2d9774de426057dfcde4209d537915e2ba9a0a7ac1baee303b04fc9653a1e19ed7cff5e95f69874facde550c25bf740cca288dfb
7
+ data.tar.gz: 6b1a5de74246ace188e2c0156325f0aa4c19698c8e9e876083171a9b1bbec0322d54185dd239a6d4f4f82dd429164a49061ae251ab6413229931690165d0c6de
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2024-02-28
3
+ ## [0.3.0] - 2024-03-07
4
+ - allow user to override http timeout
5
+
6
+ ## [0.2.0] - 2024-02-29
7
+ - allow user to override logger
4
8
 
9
+ ## [0.1.0] - 2024-02-28
5
10
  - Initial release
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem to interact with the [trefle](https://docs.trefle.io/reference) API.
3
3
 
4
4
  ## Install
5
- `spec.add_dependency 'plants', ~> 0`
5
+ `spec.add_dependency 'plants', '~> 0'`
6
6
 
7
7
  ## Usage
8
8
  You need an authorization token, [see this](https://docs.trefle.io/docs/guides/getting-started).
@@ -11,7 +11,19 @@ Plants.token = 'your token here'
11
11
  Plants.list_plants # ...
12
12
  ```
13
13
 
14
+ If you wish to override the log:
15
+ ```ruby
16
+ Plants::Log.instance = logger # Your logger here
17
+ ```
18
+
14
19
  ### Endpoints
20
+ All methods return an instance of [`HTTP::Response`](https://github.com/httprb/http/wiki/Response-Handling)
21
+
22
+ The HTTP timeout is by default 10 seconds, you can override this by:
23
+ ```ruby
24
+ Plants.timeout = 5 # new value here
25
+ ```
26
+
15
27
  #### Corrections
16
28
  ```ruby
17
29
  # List
data/lib/plants/client.rb CHANGED
@@ -35,7 +35,7 @@ module Plants
35
35
  # @return [::HTTP::Client]
36
36
  def http
37
37
  HTTP
38
- .timeout(10)
38
+ .timeout(config.timeout)
39
39
  .use(logging: { logger: Log.instance })
40
40
  .headers({ 'User-Agent' => "Plants #{Plants::VERSION} ruby-#{RUBY_VERSION}" })
41
41
  end
data/lib/plants/config.rb CHANGED
@@ -3,11 +3,14 @@ module Plants
3
3
  #
4
4
  # @!attribute token
5
5
  # @return [String]
6
+ # @!attribute timeout
7
+ # @return [Integer]
6
8
  #
7
9
  class Config
8
10
  def initialize
9
11
  @token = nil
12
+ @timeout = 10
10
13
  end
11
- attr_accessor :token
14
+ attr_accessor :token, :timeout
12
15
  end
13
16
  end
data/lib/plants/log.rb CHANGED
@@ -48,6 +48,12 @@ module Plants
48
48
  def instance
49
49
  @_instance ||= new
50
50
  end
51
+
52
+ # @param other_logger [#debug, #info, #warn, #error, #fatal]
53
+ # @return [void]
54
+ def instance=(other_logger)
55
+ @_instance = other_logger
56
+ end
51
57
  end
52
58
  end
53
59
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Plants
4
4
  # @return [String]
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
data/lib/plants.rb CHANGED
@@ -17,6 +17,12 @@ module Plants
17
17
  client.config.token = new_value
18
18
  end
19
19
 
20
+ # @param new_value [Integer]
21
+ # @return [void]
22
+ def timeout=(new_value)
23
+ client.config.timeout = new_value
24
+ end
25
+
20
26
  # @return [Plants::Config]
21
27
  def config
22
28
  client.config
data/plants.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Xero"]
9
9
  spec.email = ["vhector.1337@gmail.com"]
10
10
 
11
- spec.summary = "Plants API gem."
11
+ spec.summary = "Trefle API gem."
12
12
  spec.description = "Gem to interact with Trefle API."
13
13
  spec.homepage = "https://github.com/one-m1nd/plants"
14
14
  spec.required_ruby_version = ">= 3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-28 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -81,5 +81,5 @@ requirements: []
81
81
  rubygems_version: 3.4.10
82
82
  signing_key:
83
83
  specification_version: 4
84
- summary: Plants API gem.
84
+ summary: Trefle API gem.
85
85
  test_files: []