rubiclifier 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf1b8199e6b2fee2377bff63ad86d107274bfcc46b331ae5d4632c86403fad91
4
- data.tar.gz: 446e3fdba77b10bb618cc2708a542ee7b1371eff221b03940a8315c58db39918
3
+ metadata.gz: 8d6ce2340c532ee4fb852c7039096830969ea1e45e5de1ad61d1a127fb4b8cec
4
+ data.tar.gz: cd172e3bbafc3f12ab49e9604461925c663fa6a2beeb29dd98e0f44815171979
5
5
  SHA512:
6
- metadata.gz: 3c4c57ec314d300dabed106cbd00edf8579cf5e047078b50fd5ad002e64cd31bbb6674b97d8ebd06f2c2e043b82f57d51bf7109b6dd665a8a68084babfcd4d9a
7
- data.tar.gz: 60b00b7faea76268e6ddbcb755357720f768307a4f718a8c1b0909f19a0c128c7f5c3c705e63b3dd74b7f3f9873030ea1b0adde5b0bd46582bcd80567b24ed35
6
+ metadata.gz: 26e52fec6adaa98607ff9f2c60452689918899dd3fb725a8fe77923682f50aea357327e843468668e000c93020b287111dd69c8516952fa76de777ea3d60cd69
7
+ data.tar.gz: a355033e4c0aac8214030b9be3fe1c58210a6578870b93b656186401cc43916f925ad968d2dd3556e75eb0297f8f4e259c9af64623766b8a5a338e23bf285081
@@ -10,7 +10,8 @@ module Rubiclifier
10
10
 
11
11
  def initialize(args)
12
12
  @args = Args.new(args)
13
- DB.hydrate(data_directory, migrations_location) if feature_enabled?(Feature::DATABASE)
13
+ Feature.set_enabled(all_features)
14
+ DB.hydrate(data_directory, migrations_location) if Feature.enabled?(Feature::DATABASE)
14
15
  end
15
16
 
16
17
  def call
@@ -46,7 +47,7 @@ module Rubiclifier
46
47
  end
47
48
 
48
49
  def data_directory
49
- raise NotImplementedError if feature_enabled?(Feature::DATABASE)
50
+ raise NotImplementedError if Feature.enabled?(Feature::DATABASE)
50
51
  end
51
52
 
52
53
  def migrations_location
@@ -61,8 +62,9 @@ module Rubiclifier
61
62
 
62
63
  def all_brew_dependencies
63
64
  @abd ||= [
64
- ("sqlite" if feature_enabled?(Feature::DATABASE)),
65
- ("terminal-notifier" if feature_enabled?(Feature::NOTIFICATIONS))
65
+ ("sqlite" if Feature.enabled?(Feature::DATABASE)),
66
+ ("terminal-notifier" if Feature.enabled?(Feature::NOTIFICATIONS)),
67
+ ("sleepwatcher" if Feature.enabled?(Feature::IDLE_DETECTION))
66
68
  ].concat(brew_dependencies).compact
67
69
  end
68
70
 
@@ -88,7 +90,7 @@ module Rubiclifier
88
90
  end
89
91
 
90
92
  def needs_setup?
91
- !all_brew_dependencies.empty? || !settings.empty? || feature_enabled?(Feature::BACKGROUND)
93
+ !all_brew_dependencies.empty? || !settings.empty? || Feature.enabled?(Feature::BACKGROUND)
92
94
  end
93
95
 
94
96
  def setup_or_fail
@@ -109,7 +111,7 @@ module Rubiclifier
109
111
 
110
112
  puts
111
113
 
112
- if feature_enabled?(Feature::BACKGROUND)
114
+ if Feature.enabled?(Feature::BACKGROUND)
113
115
  setup_as_background_service
114
116
  else
115
117
  puts("Finished setup! Run with `".green + "#{executable_name}" + "`".green)
@@ -141,9 +143,5 @@ module Rubiclifier
141
143
  puts("Finished setup!".green)
142
144
  end
143
145
  end
144
-
145
- def feature_enabled?(feature)
146
- all_features.include?(feature)
147
- end
148
146
  end
149
147
  end
@@ -12,6 +12,7 @@ module Rubiclifier
12
12
  end
13
13
 
14
14
  def self.conn
15
+ Feature.fail_unless_enabled(Feature::DATABASE)
15
16
  @conn
16
17
  end
17
18
 
@@ -3,5 +3,18 @@ module Rubiclifier
3
3
  BACKGROUND = "BACKGROUND"
4
4
  DATABASE = "DATABASE"
5
5
  NOTIFICATIONS = "NOTIFICATIONS"
6
+ IDLE_DETECTION = "IDLE_DETECTION"
7
+
8
+ def self.set_enabled(features)
9
+ @enabled = features
10
+ end
11
+
12
+ def self.enabled?(feature)
13
+ @enabled.include?(feature)
14
+ end
15
+
16
+ def self.fail_unless_enabled(feature)
17
+ raise "Looks like you're trying to use feature 'Rubiclifier::Feature::#{feature}' without specifying it in your features." unless Feature.enabled?(feature)
18
+ end
6
19
  end
7
20
  end
@@ -0,0 +1,19 @@
1
+ require_relative "./feature.rb"
2
+
3
+ module Rubiclifier
4
+ class IdleDetector
5
+ def self.set_idle_seconds_threshold(idle_seconds_threshold)
6
+ @idle_seconds_threshold = idle_seconds_threshold
7
+ end
8
+
9
+ def self.idle_seconds_threshold
10
+ @idle_seconds_threshold || 120
11
+ end
12
+
13
+ def self.is_idle?
14
+ Feature.fail_unless_enabled(Feature::IDLE_DETECTION)
15
+ seconds_idle = `/usr/local/sbin/sleepwatcher -g`.to_i / 10
16
+ seconds_idle > idle_seconds_threshold
17
+ end
18
+ end
19
+ end
@@ -1,8 +1,12 @@
1
+ require_relative "./feature.rb"
2
+
1
3
  module Rubiclifier
2
4
  class Notification
3
5
  attr_reader :title, :message, :subtitle, :icon, :url
4
6
  private :title, :message, :subtitle, :icon, :url
7
+
5
8
  def initialize(title, message, subtitle = nil, icon = nil, url = nil)
9
+ Feature.fail_unless_enabled(Feature::NOTIFICATIONS)
6
10
  @title = title
7
11
  @message = message
8
12
  @subtitle = subtitle
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubiclifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Grinstead
@@ -28,6 +28,7 @@ files:
28
28
  - lib/colorized_strings.rb
29
29
  - lib/database.rb
30
30
  - lib/feature.rb
31
+ - lib/idle_detector.rb
31
32
  - lib/notification.rb
32
33
  - lib/rubiclifier.rb
33
34
  - lib/setting.rb