rubiclifier 1.0.0 → 2.0.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/bin/rubiclifier +1 -1
- data/lib/base_application.rb +12 -17
- data/lib/cli/rubiclifier_cli.rb +2 -1
- data/lib/cli/template_hydrator.rb +2 -1
- 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
- data/project_template/PROJECT_NAME.gemspec.erb +1 -1
- data/project_template/bin/PROJECT_NAME.erb +2 -2
- data/project_template/lib/PROJECT_NAME.rb.erb +0 -4
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55728a2ee2075c6e1f9dff351518b86f3fa3723697724e690bfd42d5e88a86e4
|
|
4
|
+
data.tar.gz: e506ac9933ce858270541697e10242c6cbd7b1f030174da731036d22dd276e6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79b1be94b2c6cdfba1c356cd8ed0e17e12e2ab36b07e1f4b528cb23f024edb2a5af565de5220fb878bdeb3c7ccd7813a9783512ca463816da366886b2555f51a
|
|
7
|
+
data.tar.gz: 1234dc02fc367519b1713ac1987bc76b6c3c4b9d28cf1678a9aa2846644a239367f9c8599c1c65ce3e540efd21e8763401c6d8a846599eb4fa166f7142ff6974
|
data/bin/rubiclifier
CHANGED
data/lib/base_application.rb
CHANGED
|
@@ -5,12 +5,14 @@ require_relative "./setting.rb"
|
|
|
5
5
|
|
|
6
6
|
module Rubiclifier
|
|
7
7
|
class BaseApplication
|
|
8
|
-
attr_reader :args
|
|
9
|
-
private :args
|
|
8
|
+
attr_reader :args, :executable_name
|
|
9
|
+
private :args, :executable_name
|
|
10
10
|
|
|
11
|
-
def initialize(args)
|
|
11
|
+
def initialize(args, executable_name)
|
|
12
12
|
@args = Args.new(args)
|
|
13
|
-
|
|
13
|
+
@executable_name = executable_name
|
|
14
|
+
Feature.set_enabled(all_features)
|
|
15
|
+
DB.hydrate(data_directory, migrations_location) if Feature.enabled?(Feature::DATABASE)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def call
|
|
@@ -41,12 +43,8 @@ module Rubiclifier
|
|
|
41
43
|
[]
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
def executable_name
|
|
45
|
-
raise NotImplementedError
|
|
46
|
-
end
|
|
47
|
-
|
|
48
46
|
def data_directory
|
|
49
|
-
raise NotImplementedError if
|
|
47
|
+
raise NotImplementedError if Feature.enabled?(Feature::DATABASE)
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
def migrations_location
|
|
@@ -61,8 +59,9 @@ module Rubiclifier
|
|
|
61
59
|
|
|
62
60
|
def all_brew_dependencies
|
|
63
61
|
@abd ||= [
|
|
64
|
-
("sqlite" if
|
|
65
|
-
("terminal-notifier" if
|
|
62
|
+
("sqlite" if Feature.enabled?(Feature::DATABASE)),
|
|
63
|
+
("terminal-notifier" if Feature.enabled?(Feature::NOTIFICATIONS)),
|
|
64
|
+
("sleepwatcher" if Feature.enabled?(Feature::IDLE_DETECTION))
|
|
66
65
|
].concat(brew_dependencies).compact
|
|
67
66
|
end
|
|
68
67
|
|
|
@@ -88,7 +87,7 @@ module Rubiclifier
|
|
|
88
87
|
end
|
|
89
88
|
|
|
90
89
|
def needs_setup?
|
|
91
|
-
!all_brew_dependencies.empty? || !settings.empty? ||
|
|
90
|
+
!all_brew_dependencies.empty? || !settings.empty? || Feature.enabled?(Feature::BACKGROUND)
|
|
92
91
|
end
|
|
93
92
|
|
|
94
93
|
def setup_or_fail
|
|
@@ -109,7 +108,7 @@ module Rubiclifier
|
|
|
109
108
|
|
|
110
109
|
puts
|
|
111
110
|
|
|
112
|
-
if
|
|
111
|
+
if Feature.enabled?(Feature::BACKGROUND)
|
|
113
112
|
setup_as_background_service
|
|
114
113
|
else
|
|
115
114
|
puts("Finished setup! Run with `".green + "#{executable_name}" + "`".green)
|
|
@@ -141,9 +140,5 @@ module Rubiclifier
|
|
|
141
140
|
puts("Finished setup!".green)
|
|
142
141
|
end
|
|
143
142
|
end
|
|
144
|
-
|
|
145
|
-
def feature_enabled?(feature)
|
|
146
|
-
all_features.include?(feature)
|
|
147
|
-
end
|
|
148
143
|
end
|
|
149
144
|
end
|
data/lib/cli/rubiclifier_cli.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "../rubiclifier.rb"
|
|
2
2
|
|
|
3
3
|
class RubiclifierCli < Rubiclifier::BaseApplication
|
|
4
4
|
attr_reader :project_name
|
|
@@ -14,6 +14,7 @@ class RubiclifierCli < Rubiclifier::BaseApplication
|
|
|
14
14
|
puts(" --background | Generate with background service setup steps")
|
|
15
15
|
puts(" --database | Generate with a persistent database")
|
|
16
16
|
puts(' --homebrew "[first [second]]" | Require specific homebrew kegs')
|
|
17
|
+
puts(" --idle-detection | Generate with ability to detect if user is idle")
|
|
17
18
|
puts(" --notifications | Generate with notification functionality")
|
|
18
19
|
puts(" --settings | Generate with persistent setting functionality")
|
|
19
20
|
puts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "../rubiclifier.rb"
|
|
2
2
|
|
|
3
3
|
class TemplateHydrator
|
|
4
4
|
attr_reader :args, :project_name
|
|
@@ -33,6 +33,7 @@ class TemplateHydrator
|
|
|
33
33
|
@features ||= [
|
|
34
34
|
(Rubiclifier::Feature::BACKGROUND if args.boolean("background")),
|
|
35
35
|
(Rubiclifier::Feature::DATABASE if (args.boolean("database") || include_settings?)),
|
|
36
|
+
(Rubiclifier::Feature::IDLE_DETECTION if args.boolean("idle-detection")),
|
|
36
37
|
(Rubiclifier::Feature::NOTIFICATIONS if args.boolean("notifications")),
|
|
37
38
|
].compact
|
|
38
39
|
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,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubiclifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kyle Grinstead
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-07-
|
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: kyleag@hey.com
|
|
@@ -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
|