fuck_facebook 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fuck_facebook/version.rb +1 -1
- data/src/config.rb +22 -6
- data/src/error_reporter.rb +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26fe62245cbbcf826c49ee9f89fa3d889ebbb27a662c6076777a17ab181b8715
|
4
|
+
data.tar.gz: 59ddf6a1f3450188862019d37e7e75cab558c4948b3be3a1e08997318a108505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b51a6b441c836d9073bbb7312238beee8f902e48b16a87d4e84723db31f661e31a2adb180792e8c0c51020373b43ed67b6afbc4736bd522391a5cbe1cf8890f3
|
7
|
+
data.tar.gz: 7d11525734de217266e14b3b49adb8b177adfe8b9d50a20bcb19aea3929029c701fc9bac9188a1a5b223f828fb4a4a57e642b45de074b10abd5b5c01ddb9ea85
|
data/Gemfile.lock
CHANGED
data/src/config.rb
CHANGED
@@ -3,16 +3,15 @@ require 'yaml'
|
|
3
3
|
class Config
|
4
4
|
CONFIG_FILE_PATH = "#{ENV['HOME']}/.local/share/fuck-facebook/config.yaml".freeze
|
5
5
|
|
6
|
-
def self.option(*path, default: nil)
|
6
|
+
def self.option(*path, default: nil, type: nil)
|
7
7
|
env_var = "FF_#{path.join('_').upcase}"
|
8
|
-
return ENV[env_var] if ENV[env_var]
|
9
|
-
|
10
8
|
path_strings = path.map(&:to_s)
|
11
|
-
value = config.dig(*path_strings)
|
12
9
|
|
13
|
-
|
10
|
+
value = config.dig(*path_strings)
|
11
|
+
value = ENV[env_var] if ENV[env_var]
|
12
|
+
value = default if value.nil?
|
14
13
|
|
15
|
-
|
14
|
+
cast_value_to_type(value, type)
|
16
15
|
end
|
17
16
|
|
18
17
|
def self.config
|
@@ -26,4 +25,21 @@ class Config
|
|
26
25
|
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
27
26
|
File.write(CONFIG_FILE_PATH, '{}') unless File.exist?(CONFIG_FILE_PATH)
|
28
27
|
end
|
28
|
+
|
29
|
+
private_class_method def self.cast_value_to_type(value, type)
|
30
|
+
case type
|
31
|
+
when :boolean
|
32
|
+
cast_value_to_boolean(value)
|
33
|
+
when :float
|
34
|
+
value.to_f
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private_class_method def self.cast_value_to_boolean(value)
|
39
|
+
if [true, false].include?(value)
|
40
|
+
value
|
41
|
+
elsif value.is_a?(String)
|
42
|
+
value == 'true'
|
43
|
+
end
|
44
|
+
end
|
29
45
|
end
|
data/src/error_reporter.rb
CHANGED
@@ -11,7 +11,14 @@ class ErrorReporter
|
|
11
11
|
end
|
12
12
|
|
13
13
|
private_class_method def self.include_screenshot?(facebook_connection)
|
14
|
-
Config.option(
|
14
|
+
include_screenshot_config = Config.option(
|
15
|
+
:errors,
|
16
|
+
:include_screenshot,
|
17
|
+
default: false,
|
18
|
+
type: :boolean
|
19
|
+
)
|
20
|
+
|
21
|
+
include_screenshot_config && facebook_connection.present?
|
15
22
|
end
|
16
23
|
|
17
24
|
private_class_method def self.create_screenshot(facebook_connection)
|
@@ -21,7 +28,12 @@ class ErrorReporter
|
|
21
28
|
end
|
22
29
|
|
23
30
|
private_class_method def self.report_error?
|
24
|
-
min_minutes_between_reports = Config.option(
|
31
|
+
min_minutes_between_reports = Config.option(
|
32
|
+
:errors,
|
33
|
+
:min_minutes_between_reports,
|
34
|
+
default: 0,
|
35
|
+
type: :float
|
36
|
+
)
|
25
37
|
|
26
38
|
last_error_reported_time = Storage.get(:last_error_reported_time, default: Time.new(2000))
|
27
39
|
|