umami-ruby 0.1.1 → 0.1.3

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: fb2a8c38961a59c6fc583a724d47326f3a230fedada57ae3bea4343e9b96b9b2
4
- data.tar.gz: 2dc2d0d3fac1cdb3ac0591984cff125fcfa537638c33726d0f8992f595077559
3
+ metadata.gz: 6864cffba61396afd181c29d69bf8f3676c4836b70acc06d309fb7d95c1e1e02
4
+ data.tar.gz: 619f861f73eb0388813d6252cc5869f3c53246e799d90d912d9cde8e8118cb97
5
5
  SHA512:
6
- metadata.gz: a961b60e89b5a5ac18405d83644931f35263cb506fb100998295c0e2a333e4c19fbac86b8ac38e8afbf66537a03e681ecb5b0777eaca9ff64d763ed920652132
7
- data.tar.gz: d048998b818bba3c4720c7393396bcce3f69da08df94074e4611369d8c34d218bbc2d01a5ff1d4b53df04f549ee87d3999cb51452ec158327c958ee9aefef1ef
6
+ metadata.gz: 809be5c3afeacf57451b33218c9e7f4cf49045148ac41b1efd0970ddcf597dff99a7adf12c9f3ddb4beb47209d94e55da211857b3d7fd9901fbead106b454a1d
7
+ data.tar.gz: 3abcca6c471a3353b8a7ca257f3583d6ede3cc5477b16f2d1abf546dd26b9a81a3720947cfbee0277e9ce7a7eb00005d084816d681ef0dbe6a1f4b53dd93e23a
data/README.md CHANGED
@@ -9,7 +9,7 @@ A Ruby wrapper for the Umami analytics API.
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'umami-ruby', require: 'umami'
12
+ gem 'umami-ruby'
13
13
  ```
14
14
 
15
15
  And then execute:
data/lib/umami/client.rb CHANGED
@@ -18,6 +18,8 @@ module Umami
18
18
  # @option options [String] :password Password for authentication (only for self-hosted instances)
19
19
  def initialize(options = {})
20
20
  @config = options[:config] || Umami.configuration
21
+ @config.validate! # Validate the configuration before using it
22
+
21
23
  @uri_base = options[:uri_base] || @config.uri_base
22
24
  @request_timeout = options[:request_timeout] || @config.request_timeout
23
25
  @access_token = options[:access_token] || @config.access_token
@@ -595,5 +597,6 @@ module Umami
595
597
  raise Umami::ConfigurationError, "Authentication is required for self-hosted instances"
596
598
  end
597
599
  end
600
+
598
601
  end
599
602
  end
@@ -10,18 +10,19 @@ module Umami
10
10
  @access_token = nil
11
11
  @username = nil
12
12
  @password = nil
13
+ @dirty = false
13
14
  end
14
15
 
15
16
  def uri_base=(url)
16
17
  @uri_base = url&.chomp('/')
17
- validate_configuration
18
+ @dirty = true
18
19
  end
19
20
 
20
21
  def access_token=(token)
21
22
  @access_token = token
22
23
  @username = nil
23
24
  @password = nil
24
- validate_configuration
25
+ @dirty = true
25
26
  end
26
27
 
27
28
  def credentials=(creds)
@@ -30,16 +31,16 @@ module Umami
30
31
  @username = creds[:username]
31
32
  @password = creds[:password]
32
33
  @access_token = nil
33
- validate_configuration
34
+ @dirty = true
34
35
  end
35
36
 
36
37
  def cloud?
37
38
  @access_token && @uri_base.nil?
38
39
  end
39
40
 
40
- private
41
+ def validate!
42
+ return unless @dirty
41
43
 
42
- def validate_configuration
43
44
  if cloud?
44
45
  @uri_base = UMAMI_CLOUD_URL
45
46
  Umami.logger.info "Using Umami Cloud (#{UMAMI_CLOUD_URL})"
@@ -58,6 +59,8 @@ module Umami
58
59
  if @uri_base && @uri_base != UMAMI_CLOUD_URL && !@access_token && !@username && !@password
59
60
  raise Umami::ConfigurationError, "Authentication is required for self-hosted instances"
60
61
  end
62
+
63
+ @dirty = false
61
64
  end
62
65
  end
63
66
  end
data/lib/umami/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Umami
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/umami-ruby.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "umami"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umami-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rameerez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-22 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -119,6 +119,7 @@ files:
119
119
  - docs/js/jquery.js
120
120
  - docs/method_list.html
121
121
  - docs/top-level-namespace.html
122
+ - lib/umami-ruby.rb
122
123
  - lib/umami.rb
123
124
  - lib/umami/client.rb
124
125
  - lib/umami/configuration.rb