rubiclifier 1.1.0 → 2.1.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/Gemfile +6 -0
- data/bin/rubiclifier +1 -1
- data/lib/base_application.rb +27 -19
- data/lib/cli/rubiclifier_cli.rb +6 -1
- data/lib/cli/template_hydrator.rb +3 -1
- data/lib/database.rb +1 -0
- data/lib/feature.rb +14 -0
- data/lib/idle_detector.rb +19 -0
- data/lib/notification.rb +4 -0
- data/lib/server.rb +13 -0
- data/project_template/bin/PROJECT_NAME.erb +2 -2
- data/project_template/lib/PROJECT_NAME.rb.erb +9 -6
- data/project_template/lib/server.rb +8 -0
- data/project_template/public/index.html.erb +12 -0
- metadata +11 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 28017918c897dbe2c073355b9a7fb68b868a76c7d171089fab957b63943bb106
|
|
4
|
+
data.tar.gz: f183ea8e536a1a889c3c210aa88f3b103276858bbb8e713b7a84d95e23f272a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 397b8a9dceedab109ef2335e6ad0d243bd355b1b776ef39120efbe181e075baba6cc55d597af05651feaada5ef3dff69572cabab4395437b24988dc058a0865a
|
|
7
|
+
data.tar.gz: 37f1383afa0fcd7d9a62803af517ef7136e8c546c9721a89be07500ef5e56ae9eafcd23c764fc27c087230852dbf0d374f9957f4cfbbe59918dab18ce7a4bb30
|
data/Gemfile
CHANGED
data/bin/rubiclifier
CHANGED
data/lib/base_application.rb
CHANGED
|
@@ -5,28 +5,43 @@ 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
|
|
17
19
|
show_help if args.command == "help" || args.boolean("help", "h")
|
|
18
20
|
setup_or_fail if needs_setup?
|
|
19
|
-
|
|
21
|
+
if Feature.enabled?(Feature::SERVER)
|
|
22
|
+
run_server
|
|
23
|
+
else
|
|
24
|
+
run_application
|
|
25
|
+
end
|
|
20
26
|
end
|
|
21
27
|
|
|
22
28
|
def show_help
|
|
23
29
|
raise NotImplementedError
|
|
24
30
|
end
|
|
25
31
|
|
|
32
|
+
def run_server
|
|
33
|
+
raise NotImplementedError
|
|
34
|
+
end
|
|
35
|
+
|
|
26
36
|
def run_application
|
|
27
37
|
raise NotImplementedError
|
|
28
38
|
end
|
|
29
39
|
|
|
40
|
+
def run_server
|
|
41
|
+
server_class.hydrate
|
|
42
|
+
server_class.run!
|
|
43
|
+
end
|
|
44
|
+
|
|
30
45
|
def additional_setup
|
|
31
46
|
end
|
|
32
47
|
|
|
@@ -41,12 +56,8 @@ module Rubiclifier
|
|
|
41
56
|
[]
|
|
42
57
|
end
|
|
43
58
|
|
|
44
|
-
def executable_name
|
|
45
|
-
raise NotImplementedError
|
|
46
|
-
end
|
|
47
|
-
|
|
48
59
|
def data_directory
|
|
49
|
-
raise NotImplementedError if
|
|
60
|
+
raise NotImplementedError if Feature.enabled?(Feature::DATABASE)
|
|
50
61
|
end
|
|
51
62
|
|
|
52
63
|
def migrations_location
|
|
@@ -61,14 +72,15 @@ module Rubiclifier
|
|
|
61
72
|
|
|
62
73
|
def all_brew_dependencies
|
|
63
74
|
@abd ||= [
|
|
64
|
-
("sqlite" if
|
|
65
|
-
("terminal-notifier" if
|
|
75
|
+
("sqlite" if Feature.enabled?(Feature::DATABASE)),
|
|
76
|
+
("terminal-notifier" if Feature.enabled?(Feature::NOTIFICATIONS)),
|
|
77
|
+
("sleepwatcher" if Feature.enabled?(Feature::IDLE_DETECTION))
|
|
66
78
|
].concat(brew_dependencies).compact
|
|
67
79
|
end
|
|
68
80
|
|
|
69
81
|
def brew_dependencies_installed?
|
|
70
82
|
all_brew_dependencies.all? do |dep|
|
|
71
|
-
system("brew list #{dep} &> /dev/null")
|
|
83
|
+
system("/usr/local/bin/brew list #{dep} &> /dev/null")
|
|
72
84
|
end
|
|
73
85
|
end
|
|
74
86
|
|
|
@@ -88,7 +100,7 @@ module Rubiclifier
|
|
|
88
100
|
end
|
|
89
101
|
|
|
90
102
|
def needs_setup?
|
|
91
|
-
!all_brew_dependencies.empty? || !settings.empty? ||
|
|
103
|
+
!all_brew_dependencies.empty? || !settings.empty? || Feature.enabled?(Feature::BACKGROUND)
|
|
92
104
|
end
|
|
93
105
|
|
|
94
106
|
def setup_or_fail
|
|
@@ -109,7 +121,7 @@ module Rubiclifier
|
|
|
109
121
|
|
|
110
122
|
puts
|
|
111
123
|
|
|
112
|
-
if
|
|
124
|
+
if Feature.enabled?(Feature::BACKGROUND)
|
|
113
125
|
setup_as_background_service
|
|
114
126
|
else
|
|
115
127
|
puts("Finished setup! Run with `".green + "#{executable_name}" + "`".green)
|
|
@@ -141,9 +153,5 @@ module Rubiclifier
|
|
|
141
153
|
puts("Finished setup!".green)
|
|
142
154
|
end
|
|
143
155
|
end
|
|
144
|
-
|
|
145
|
-
def feature_enabled?(feature)
|
|
146
|
-
all_features.include?(feature)
|
|
147
|
-
end
|
|
148
156
|
end
|
|
149
157
|
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
|
|
@@ -44,6 +45,10 @@ class RubiclifierCli < Rubiclifier::BaseApplication
|
|
|
44
45
|
unless template_hydrator.feature_enabled?(Rubiclifier::Feature::DATABASE)
|
|
45
46
|
system("rm #{project_name}/migrations.rb")
|
|
46
47
|
end
|
|
48
|
+
unless template_hydrator.feature_enabled?(Rubiclifier::Feature::SERVER)
|
|
49
|
+
system("rm #{project_name}/lib/server.rb")
|
|
50
|
+
system("rm -rf #{project_name}/public")
|
|
51
|
+
end
|
|
47
52
|
puts("Finished creating project #{project_name}! Build out the application in #{project_name}/lib/#{project_name}.rb".green)
|
|
48
53
|
end
|
|
49
54
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "../rubiclifier.rb"
|
|
2
2
|
|
|
3
3
|
class TemplateHydrator
|
|
4
4
|
attr_reader :args, :project_name
|
|
@@ -33,7 +33,9 @@ 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")),
|
|
38
|
+
(Rubiclifier::Feature::SERVER if args.boolean("server")),
|
|
37
39
|
].compact
|
|
38
40
|
end
|
|
39
41
|
|
data/lib/database.rb
CHANGED
data/lib/feature.rb
CHANGED
|
@@ -3,5 +3,19 @@ module Rubiclifier
|
|
|
3
3
|
BACKGROUND = "BACKGROUND"
|
|
4
4
|
DATABASE = "DATABASE"
|
|
5
5
|
NOTIFICATIONS = "NOTIFICATIONS"
|
|
6
|
+
IDLE_DETECTION = "IDLE_DETECTION"
|
|
7
|
+
SERVER = "SERVER"
|
|
8
|
+
|
|
9
|
+
def self.set_enabled(features)
|
|
10
|
+
@enabled = features
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.enabled?(feature)
|
|
14
|
+
@enabled.include?(feature)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.fail_unless_enabled(feature)
|
|
18
|
+
raise "Looks like you're trying to use feature 'Rubiclifier::Feature::#{feature}' without specifying it in your features." unless Feature.enabled?(feature)
|
|
19
|
+
end
|
|
6
20
|
end
|
|
7
21
|
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
|
data/lib/server.rb
ADDED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
require "rubiclifier"
|
|
2
|
+
<%- if feature_enabled?(Rubiclifier::Feature::SERVER) -%>
|
|
3
|
+
require_relative "./server.rb"
|
|
4
|
+
<%- end -%>
|
|
2
5
|
|
|
3
6
|
class <%= project_name_camel_case %> < Rubiclifier::BaseApplication
|
|
4
7
|
def show_help
|
|
@@ -15,12 +18,18 @@ class <%= project_name_camel_case %> < Rubiclifier::BaseApplication
|
|
|
15
18
|
exit
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
<%- if feature_enabled?(Rubiclifier::Feature::SERVER) -%>
|
|
22
|
+
def server_class
|
|
23
|
+
Server
|
|
24
|
+
end
|
|
25
|
+
<%- else -%>
|
|
18
26
|
def run_application
|
|
19
27
|
while true
|
|
20
28
|
puts "Running!"
|
|
21
29
|
sleep 5
|
|
22
30
|
end
|
|
23
31
|
end
|
|
32
|
+
<%- end -%>
|
|
24
33
|
<%- if !features.empty? -%>
|
|
25
34
|
|
|
26
35
|
def features
|
|
@@ -36,12 +45,6 @@ class <%= project_name_camel_case %> < Rubiclifier::BaseApplication
|
|
|
36
45
|
]
|
|
37
46
|
end
|
|
38
47
|
<%- end -%>
|
|
39
|
-
<%- if needs_setup? -%>
|
|
40
|
-
|
|
41
|
-
def executable_name
|
|
42
|
-
"<%= project_name %>"
|
|
43
|
-
end
|
|
44
|
-
<%- end -%>
|
|
45
48
|
<%- if feature_enabled?(Rubiclifier::Feature::DATABASE) -%>
|
|
46
49
|
|
|
47
50
|
def data_directory
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubiclifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kyle Grinstead
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-07-
|
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description:
|
|
14
14
|
email: kyleag@hey.com
|
|
15
15
|
executables:
|
|
16
16
|
- rubiclifier
|
|
@@ -28,8 +28,10 @@ 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
|
|
34
|
+
- lib/server.rb
|
|
33
35
|
- lib/setting.rb
|
|
34
36
|
- project_template/.gitignore
|
|
35
37
|
- project_template/Gemfile
|
|
@@ -39,13 +41,15 @@ files:
|
|
|
39
41
|
- project_template/bin/PROJECT_NAME.erb
|
|
40
42
|
- project_template/lib/PROJECT_NAME.rb.erb
|
|
41
43
|
- project_template/lib/api.rb
|
|
44
|
+
- project_template/lib/server.rb
|
|
42
45
|
- project_template/migrations.rb
|
|
46
|
+
- project_template/public/index.html.erb
|
|
43
47
|
homepage: https://rubygems.org/gems/rubiclifier
|
|
44
48
|
licenses:
|
|
45
49
|
- MIT
|
|
46
50
|
metadata:
|
|
47
51
|
source_code_uri: https://github.com/MrGrinst/rubiclifier
|
|
48
|
-
post_install_message:
|
|
52
|
+
post_install_message:
|
|
49
53
|
rdoc_options: []
|
|
50
54
|
require_paths:
|
|
51
55
|
- lib
|
|
@@ -60,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
64
|
- !ruby/object:Gem::Version
|
|
61
65
|
version: '0'
|
|
62
66
|
requirements: []
|
|
63
|
-
rubyforge_project:
|
|
67
|
+
rubyforge_project:
|
|
64
68
|
rubygems_version: 2.7.6.2
|
|
65
|
-
signing_key:
|
|
69
|
+
signing_key:
|
|
66
70
|
specification_version: 4
|
|
67
71
|
summary: Easily spin up new Ruby CLI applications with built-in backgrounding and
|
|
68
72
|
data storage.
|