rubiclifier 1.2.0 → 2.1.2

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: 8d6ce2340c532ee4fb852c7039096830969ea1e45e5de1ad61d1a127fb4b8cec
4
- data.tar.gz: cd172e3bbafc3f12ab49e9604461925c663fa6a2beeb29dd98e0f44815171979
3
+ metadata.gz: ecbd1aec5afc842587c43cc413526cedc13f58468c09cf3ce415cc84bf800aee
4
+ data.tar.gz: 7d9b7298cbcd59aa13ee45507eb70ae2d9ac938dc581983880847f6e8d82d31b
5
5
  SHA512:
6
- metadata.gz: 26e52fec6adaa98607ff9f2c60452689918899dd3fb725a8fe77923682f50aea357327e843468668e000c93020b287111dd69c8516952fa76de777ea3d60cd69
7
- data.tar.gz: a355033e4c0aac8214030b9be3fe1c58210a6578870b93b656186401cc43916f925ad968d2dd3556e75eb0297f8f4e259c9af64623766b8a5a338e23bf285081
6
+ metadata.gz: 5b3c7fc9dd07510ec42fce69ec202f2de6a1640b5c24db6a8ad4b2871bf996ae59b63f65b362536c690663f49101741b85a3bb9e204a24d75e3283cebe75d808
7
+ data.tar.gz: b5d29256a4552a9b4cbd59c7b73cb0f1b161ac718f22f16de5f22963e0e3d3d5c7fcbde3110714bd268082b31e747c0d85c1a7fd81edca601e6f996608d62c05
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
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../lib/cli/rubiclifier_cli.rb"
4
4
 
5
- RubiclifierCli.new(ARGV).call
5
+ RubiclifierCli.new(ARGV, __FILE__.split("/").last).call
@@ -5,11 +5,12 @@ 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
+ @executable_name = executable_name
13
14
  Feature.set_enabled(all_features)
14
15
  DB.hydrate(data_directory, migrations_location) if Feature.enabled?(Feature::DATABASE)
15
16
  end
@@ -17,20 +18,36 @@ module Rubiclifier
17
18
  def call
18
19
  show_help if args.command == "help" || args.boolean("help", "h")
19
20
  setup_or_fail if needs_setup?
20
- run_application
21
+ if Feature.enabled?(Feature::SERVER)
22
+ run_server
23
+ else
24
+ run_application
25
+ end
21
26
  end
22
27
 
23
28
  def show_help
24
29
  raise NotImplementedError
25
30
  end
26
31
 
32
+ def run_server
33
+ raise NotImplementedError
34
+ end
35
+
27
36
  def run_application
28
37
  raise NotImplementedError
29
38
  end
30
39
 
40
+ def run_server
41
+ server_class.hydrate
42
+ server_class.run!
43
+ end
44
+
31
45
  def additional_setup
32
46
  end
33
47
 
48
+ def post_setup_message
49
+ end
50
+
34
51
  def not_setup
35
52
  end
36
53
 
@@ -42,10 +59,6 @@ module Rubiclifier
42
59
  []
43
60
  end
44
61
 
45
- def executable_name
46
- raise NotImplementedError
47
- end
48
-
49
62
  def data_directory
50
63
  raise NotImplementedError if Feature.enabled?(Feature::DATABASE)
51
64
  end
@@ -70,7 +83,7 @@ module Rubiclifier
70
83
 
71
84
  def brew_dependencies_installed?
72
85
  all_brew_dependencies.all? do |dep|
73
- system("brew list #{dep} &> /dev/null")
86
+ system("/usr/local/bin/brew list #{dep} &> /dev/null")
74
87
  end
75
88
  end
76
89
 
@@ -115,6 +128,7 @@ module Rubiclifier
115
128
  setup_as_background_service
116
129
  else
117
130
  puts("Finished setup! Run with `".green + "#{executable_name}" + "`".green)
131
+ post_setup_message
118
132
  end
119
133
  exit
120
134
  elsif !settings.all?(&:is_setup?) || !brew_dependencies_installed?
@@ -132,15 +146,19 @@ module Rubiclifier
132
146
  puts
133
147
  print("Would you like this script to set it up for you? (y/n) ")
134
148
  if STDIN.gets.chomp.downcase == "y"
135
- puts "Installing serviceman..."
136
- 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
137
153
  puts "Adding #{executable_name} as a service..."
138
- system("serviceman add --name #{executable_name} #{executable_name}")
154
+ system("$HOME/.local/bin/serviceman add --name #{executable_name} #{executable_name}")
139
155
  puts
140
156
  puts("Finished setup! The service is set to run in the background!".green)
157
+ post_setup_message
141
158
  else
142
159
  puts
143
160
  puts("Finished setup!".green)
161
+ post_setup_message
144
162
  end
145
163
  end
146
164
  end
@@ -1,4 +1,4 @@
1
- require "rubiclifier"
1
+ require_relative "../rubiclifier.rb"
2
2
 
3
3
  class RubiclifierCli < Rubiclifier::BaseApplication
4
4
  attr_reader :project_name
@@ -14,7 +14,9 @@ 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")
19
+ puts(" --server | Generate with server")
18
20
  puts(" --settings | Generate with persistent setting functionality")
19
21
  puts
20
22
  exit
@@ -44,6 +46,10 @@ class RubiclifierCli < Rubiclifier::BaseApplication
44
46
  unless template_hydrator.feature_enabled?(Rubiclifier::Feature::DATABASE)
45
47
  system("rm #{project_name}/migrations.rb")
46
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
47
53
  puts("Finished creating project #{project_name}! Build out the application in #{project_name}/lib/#{project_name}.rb".green)
48
54
  end
49
55
 
@@ -1,4 +1,4 @@
1
- require "rubiclifier"
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
 
@@ -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"
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../lib/<%= project_name %>.rb"
4
4
 
5
- <%= project_name_camel_case %>.new(ARGV).call
5
+ <%= project_name_camel_case %>.new(ARGV, __FILE__.split("/").last).call
@@ -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
@@ -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: 1.2.0
4
+ version: 2.1.2
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-15 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.