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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4444d134e1ae1d10b948ae6432691f99c1c22498aea2f0530359b0c93a1df967
4
- data.tar.gz: b276c6b4a680c546b2b34366b5e28cd1af620ef7800ae7f2964bbded6235eff8
3
+ metadata.gz: 26fe62245cbbcf826c49ee9f89fa3d889ebbb27a662c6076777a17ab181b8715
4
+ data.tar.gz: 59ddf6a1f3450188862019d37e7e75cab558c4948b3be3a1e08997318a108505
5
5
  SHA512:
6
- metadata.gz: 2e9a2254136c1886d20e7f164bbf1cf9d06d1a6191ed7522df717db580b6eea1b48f9ab5c9caebb9b84c75bc24f8467e0c92b30d5bae5f1131a99b7a6bb93b94
7
- data.tar.gz: 5b930019d90be80fb751a487c2b71b0021278dc1952fd2a61baac57b7e88a4bcfc33be612699193bd6caeeb1c43a5fb0b7a231fce555d41c32e6d69a6cb93185
6
+ metadata.gz: b51a6b441c836d9073bbb7312238beee8f902e48b16a87d4e84723db31f661e31a2adb180792e8c0c51020373b43ed67b6afbc4736bd522391a5cbe1cf8890f3
7
+ data.tar.gz: 7d11525734de217266e14b3b49adb8b177adfe8b9d50a20bcb19aea3929029c701fc9bac9188a1a5b223f828fb4a4a57e642b45de074b10abd5b5c01ddb9ea85
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuck_facebook (0.4.1)
4
+ fuck_facebook (0.5.1)
5
5
  activesupport (~> 6.1)
6
6
  highline (~> 2.0)
7
7
  mail (~> 2.7)
@@ -1,3 +1,3 @@
1
1
  module FuckFacebook
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
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
- return value if value
10
+ value = config.dig(*path_strings)
11
+ value = ENV[env_var] if ENV[env_var]
12
+ value = default if value.nil?
14
13
 
15
- default
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
@@ -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(:errors, :include_screenshot) && facebook_connection.present?
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(:errors, :min_minutes_between_reports, default: 0)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuck_facebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keeyan Nejad