rubiclifier 2.0.0 → 2.1.3

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: 55728a2ee2075c6e1f9dff351518b86f3fa3723697724e690bfd42d5e88a86e4
4
- data.tar.gz: e506ac9933ce858270541697e10242c6cbd7b1f030174da731036d22dd276e6c
3
+ metadata.gz: 968bd3787bc49db6d701faae3a1c325eb33ac5efa8f0842f978cb6a6fed2b0f4
4
+ data.tar.gz: aad58334d2272e3741b90045f71d1aab50ae99b597bcdc7af31a4d63bfb75d1e
5
5
  SHA512:
6
- metadata.gz: 79b1be94b2c6cdfba1c356cd8ed0e17e12e2ab36b07e1f4b528cb23f024edb2a5af565de5220fb878bdeb3c7ccd7813a9783512ca463816da366886b2555f51a
7
- data.tar.gz: 1234dc02fc367519b1713ac1987bc76b6c3c4b9d28cf1678a9aa2846644a239367f9c8599c1c65ce3e540efd21e8763401c6d8a846599eb4fa166f7142ff6974
6
+ metadata.gz: 073baf0f68fba15496f41daf5912657f08d046d8434760de34ce99045f024d7574f84cde11ca1e71280342ba12134010a5ec6dcfd0adccd0e97514121539a88f
7
+ data.tar.gz: 7352b51728777587902fda0cbe7f360f25f072295082835e59186ff174fce87b9adc0728d844f487e610af13598cf03d5aafb6a6e936d49ca1a0fb2d8bf2fce9
data/Gemfile CHANGED
@@ -4,3 +4,9 @@ gemspec
4
4
 
5
5
  gem "httparty"
6
6
  gem "sqlite3"
7
+ gem "sinatra"
8
+
9
+ group :test do
10
+ gem "byebug"
11
+ gem "rspec"
12
+ end
@@ -18,20 +18,36 @@ module Rubiclifier
18
18
  def call
19
19
  show_help if args.command == "help" || args.boolean("help", "h")
20
20
  setup_or_fail if needs_setup?
21
- run_application
21
+ if Feature.enabled?(Feature::SERVER)
22
+ run_server
23
+ else
24
+ run_application
25
+ end
22
26
  end
23
27
 
24
28
  def show_help
25
29
  raise NotImplementedError
26
30
  end
27
31
 
32
+ def run_server
33
+ raise NotImplementedError
34
+ end
35
+
28
36
  def run_application
29
37
  raise NotImplementedError
30
38
  end
31
39
 
40
+ def run_server
41
+ server_class.hydrate
42
+ server_class.run!
43
+ end
44
+
32
45
  def additional_setup
33
46
  end
34
47
 
48
+ def post_setup_message
49
+ end
50
+
35
51
  def not_setup
36
52
  end
37
53
 
@@ -67,7 +83,7 @@ module Rubiclifier
67
83
 
68
84
  def brew_dependencies_installed?
69
85
  all_brew_dependencies.all? do |dep|
70
- system("brew list #{dep} &> /dev/null")
86
+ system("/usr/local/bin/brew list #{dep} &> /dev/null")
71
87
  end
72
88
  end
73
89
 
@@ -112,6 +128,7 @@ module Rubiclifier
112
128
  setup_as_background_service
113
129
  else
114
130
  puts("Finished setup! Run with `".green + "#{executable_name}" + "`".green)
131
+ post_setup_message
115
132
  end
116
133
  exit
117
134
  elsif !settings.all?(&:is_setup?) || !brew_dependencies_installed?
@@ -129,15 +146,19 @@ module Rubiclifier
129
146
  puts
130
147
  print("Would you like this script to set it up for you? (y/n) ")
131
148
  if STDIN.gets.chomp.downcase == "y"
132
- puts "Installing serviceman..."
133
- system("curl -sL https://webinstall.dev/serviceman | bash")
149
+ unless system("ls \"$HOME/.local/bin/serviceman\" &> /dev/null")
150
+ puts "Installing serviceman..."
151
+ system("-sL https://webinstall.dev/serviceman | bash")
152
+ end
134
153
  puts "Adding #{executable_name} as a service..."
135
- system("serviceman add --name #{executable_name} #{executable_name}")
154
+ system("$HOME/.local/bin/serviceman add --name #{executable_name} #{executable_name}")
136
155
  puts
137
156
  puts("Finished setup! The service is set to run in the background!".green)
157
+ post_setup_message
138
158
  else
139
159
  puts
140
160
  puts("Finished setup!".green)
161
+ post_setup_message
141
162
  end
142
163
  end
143
164
  end
@@ -16,6 +16,7 @@ class RubiclifierCli < Rubiclifier::BaseApplication
16
16
  puts(' --homebrew "[first [second]]" | Require specific homebrew kegs')
17
17
  puts(" --idle-detection | Generate with ability to detect if user is idle")
18
18
  puts(" --notifications | Generate with notification functionality")
19
+ puts(" --server | Generate with server")
19
20
  puts(" --settings | Generate with persistent setting functionality")
20
21
  puts
21
22
  exit
@@ -45,6 +46,10 @@ class RubiclifierCli < Rubiclifier::BaseApplication
45
46
  unless template_hydrator.feature_enabled?(Rubiclifier::Feature::DATABASE)
46
47
  system("rm #{project_name}/migrations.rb")
47
48
  end
49
+ unless template_hydrator.feature_enabled?(Rubiclifier::Feature::SERVER)
50
+ system("rm #{project_name}/lib/server.rb")
51
+ system("rm -rf #{project_name}/public")
52
+ end
48
53
  puts("Finished creating project #{project_name}! Build out the application in #{project_name}/lib/#{project_name}.rb".green)
49
54
  end
50
55
 
@@ -35,6 +35,7 @@ class TemplateHydrator
35
35
  (Rubiclifier::Feature::DATABASE if (args.boolean("database") || include_settings?)),
36
36
  (Rubiclifier::Feature::IDLE_DETECTION if args.boolean("idle-detection")),
37
37
  (Rubiclifier::Feature::NOTIFICATIONS if args.boolean("notifications")),
38
+ (Rubiclifier::Feature::SERVER if args.boolean("server")),
38
39
  ].compact
39
40
  end
40
41
 
@@ -38,13 +38,14 @@ module Rubiclifier
38
38
 
39
39
  def self.save_setting(key, value, is_secret:)
40
40
  salt = "NULL"
41
- if is_secret
41
+ output_value = "NULL"
42
+ if is_secret && value
42
43
  salt, encrypted = Cipher.encrypt(value)
43
44
  salt = "'#{salt}'"
44
- value = encrypted
45
+ output_value = "'#{encrypted}'"
45
46
  end
46
47
  conn.execute("DELETE FROM settings WHERE key = '#{key}';")
47
- conn.execute("INSERT INTO settings (key, value, salt) VALUES('#{key}', '#{value}', #{salt});")
48
+ conn.execute("INSERT INTO settings (key, value, salt) VALUES('#{key}', #{output_value}, #{salt});")
48
49
  end
49
50
 
50
51
  def self.migrate_if_needed(migrations_location)
@@ -4,6 +4,7 @@ module Rubiclifier
4
4
  DATABASE = "DATABASE"
5
5
  NOTIFICATIONS = "NOTIFICATIONS"
6
6
  IDLE_DETECTION = "IDLE_DETECTION"
7
+ SERVER = "SERVER"
7
8
 
8
9
  def self.set_enabled(features)
9
10
  @enabled = features
@@ -0,0 +1,13 @@
1
+ require 'sinatra/base'
2
+
3
+ module Rubiclifier
4
+ class Server < Sinatra::Base
5
+ def self.hydrate
6
+ raise NotImplementedError
7
+ end
8
+
9
+ get "/" do
10
+ redirect("/index.html")
11
+ end
12
+ end
13
+ end
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.summary = "SUMMARY HERE"
6
6
  s.authors = ["AUTHOR NAME"]
7
7
  s.email = "AUTHOR EMAIL"
8
- s.files = Dir.glob("{lib}/**/*") + ["Gemfile"]
8
+ s.files = Dir.glob("{lib<%= ",public" if feature_enabled?(Rubiclifier::Feature::SERVER) %>}/**/*") + ["Gemfile"]
9
9
  s.homepage = "https://rubygems.org/gems/<%= project_name %>"
10
10
  s.metadata = { "source_code_uri" => "https://github.com/PATH_TO_PROJECT" }
11
11
  s.require_path = "lib"
@@ -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
@@ -0,0 +1,8 @@
1
+ require "rubiclifier"
2
+
3
+ class Server < Rubiclifier::Server
4
+ def self.hydrate
5
+ set :public_folder, "#{File.expand_path(File.dirname(__FILE__) + "/..")}/public"
6
+ set :port, 5000
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title><%= project_name %></title>
7
+ </head>
8
+
9
+ <body>
10
+ <h1><%= project_name %></h1>
11
+ </body>
12
+ </html>
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: 2.0.0
4
+ version: 2.1.3
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-10 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email: kyleag@hey.com
15
15
  executables:
16
16
  - rubiclifier
@@ -31,6 +31,7 @@ files:
31
31
  - lib/idle_detector.rb
32
32
  - lib/notification.rb
33
33
  - lib/rubiclifier.rb
34
+ - lib/server.rb
34
35
  - lib/setting.rb
35
36
  - project_template/.gitignore
36
37
  - project_template/Gemfile
@@ -40,13 +41,15 @@ files:
40
41
  - project_template/bin/PROJECT_NAME.erb
41
42
  - project_template/lib/PROJECT_NAME.rb.erb
42
43
  - project_template/lib/api.rb
44
+ - project_template/lib/server.rb
43
45
  - project_template/migrations.rb
46
+ - project_template/public/index.html.erb
44
47
  homepage: https://rubygems.org/gems/rubiclifier
45
48
  licenses:
46
49
  - MIT
47
50
  metadata:
48
51
  source_code_uri: https://github.com/MrGrinst/rubiclifier
49
- post_install_message:
52
+ post_install_message:
50
53
  rdoc_options: []
51
54
  require_paths:
52
55
  - lib
@@ -61,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
64
  - !ruby/object:Gem::Version
62
65
  version: '0'
63
66
  requirements: []
64
- rubyforge_project:
67
+ rubyforge_project:
65
68
  rubygems_version: 2.7.6.2
66
- signing_key:
69
+ signing_key:
67
70
  specification_version: 4
68
71
  summary: Easily spin up new Ruby CLI applications with built-in backgrounding and
69
72
  data storage.