umami-ruby 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/umami/client.rb +3 -0
- data/lib/umami/configuration.rb +8 -5
- data/lib/umami/ruby.rb +1 -0
- data/lib/umami/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c1694e34f1d6aa0a0c3a29e1a2974102acf06e6080073b24821c067e04017ac
|
4
|
+
data.tar.gz: 6e8d775b7b7e9d68302f61ff17efb97898eef143520be9cc0c9f46f0cc40da44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 835bf75155867e6fb31d27eace33760ab4969b267543af9df66db6c7d1c8bbab25f2f25ccf487748bb083534d3ceda1d0287dd7bad5b06db85d054d37e925fa7
|
7
|
+
data.tar.gz: cf11c314d097bd25bbfa5c92f9a34c8a5628df745a2a9b569eba1fd5fb7690eddeae0025d445010065b7026aa7681cb4228fb034981e939b1ed7e0eb714ba163
|
data/README.md
CHANGED
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
|
data/lib/umami/configuration.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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/ruby.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "../umami"
|
data/lib/umami/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umami-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rameerez
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/umami/client.rb
|
124
124
|
- lib/umami/configuration.rb
|
125
125
|
- lib/umami/errors.rb
|
126
|
+
- lib/umami/ruby.rb
|
126
127
|
- lib/umami/version.rb
|
127
128
|
- sig/umami/ruby.rbs
|
128
129
|
homepage: https://github.com/rameerez/umami-ruby
|