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 +4 -4
- data/lib/base_application.rb +8 -10
- data/lib/database.rb +1 -0
- data/lib/feature.rb +13 -0
- data/lib/idle_detector.rb +19 -0
- data/lib/notification.rb +4 -0
- 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: 8d6ce2340c532ee4fb852c7039096830969ea1e45e5de1ad61d1a127fb4b8cec
|
|
4
|
+
data.tar.gz: cd172e3bbafc3f12ab49e9604461925c663fa6a2beeb29dd98e0f44815171979
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26e52fec6adaa98607ff9f2c60452689918899dd3fb725a8fe77923682f50aea357327e843468668e000c93020b287111dd69c8516952fa76de777ea3d60cd69
|
|
7
|
+
data.tar.gz: a355033e4c0aac8214030b9be3fe1c58210a6578870b93b656186401cc43916f925ad968d2dd3556e75eb0297f8f4e259c9af64623766b8a5a338e23bf285081
|
data/lib/base_application.rb
CHANGED
|
@@ -10,7 +10,8 @@ module Rubiclifier
|
|
|
10
10
|
|
|
11
11
|
def initialize(args)
|
|
12
12
|
@args = Args.new(args)
|
|
13
|
-
|
|
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
|
|
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
|
|
65
|
-
("terminal-notifier" if
|
|
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? ||
|
|
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
|
|
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
|
data/lib/database.rb
CHANGED
data/lib/feature.rb
CHANGED
|
@@ -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
|
data/lib/notification.rb
CHANGED
|
@@ -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.
|
|
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
|