canto 0.1.2 → 0.1.8
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/canto.gemspec +1 -6
- data/lib/canto.rb +1 -1
- data/lib/canto/cli.rb +25 -18
- data/lib/canto/version.rb +1 -1
- metadata +1 -8
- data/.circleci/config.yml +0 -39
- data/.gitignore +0 -9
- data/.ruby-version +0 -1
- data/.standard.yml +0 -22
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -21
- data/Rakefile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cdcfe3b468b95ac736006e23eb2a1f92859d35cdd87bd0d83f6d7b945953060
|
4
|
+
data.tar.gz: bafa130368f18840c8cd0e8d07762ca186a075235f86bea6336058080d5532ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d33abf5fd2285e6eb44059d416480653c6b746332e8d9538986fe797e83bc6e458e30d7d567b23590de2a9735a826b0dc2a917a45fcf2fc65c95802caf81da
|
7
|
+
data.tar.gz: d27027fa51fb1c58faa5940f3e5fcc1e1a6fbb704a04f7c50606efbdc8ece1ce8d6931c8829a81c89bc01e05ce730dbfee55f5f1a64dc5cdc72bfe87ee3dbf1d
|
data/canto.gemspec
CHANGED
@@ -15,13 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.metadata['homepage_uri'] = spec.homepage
|
16
16
|
spec.metadata['source_code_uri'] = 'https://github.com/merqloveu/canto'
|
17
17
|
|
18
|
-
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
end
|
18
|
+
spec.files = %w[canto.gemspec README.md CODE_OF_CONDUCT.md LICENSE.txt] + `git ls-files | grep -E '^(bin|lib)'`.split("\n")
|
23
19
|
|
24
|
-
spec.bindir = 'bin'
|
25
20
|
spec.executables = ['canto']
|
26
21
|
spec.require_paths = ['lib']
|
27
22
|
end
|
data/lib/canto.rb
CHANGED
data/lib/canto/cli.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require 'optparse'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'logger'
|
4
5
|
|
5
6
|
$stdout.sync = true
|
6
7
|
|
7
|
-
|
8
|
+
module Canto
|
8
9
|
class CLI
|
9
10
|
include Singleton
|
10
11
|
|
@@ -20,7 +21,7 @@ class Canto
|
|
20
21
|
validate!
|
21
22
|
end
|
22
23
|
|
23
|
-
def run(
|
24
|
+
def run(boot_app: true)
|
24
25
|
boot_application if boot_app
|
25
26
|
|
26
27
|
self_read, self_write = IO.pipe
|
@@ -43,8 +44,8 @@ class Canto
|
|
43
44
|
handle_signal(signal)
|
44
45
|
end
|
45
46
|
rescue Interrupt
|
46
|
-
|
47
|
-
|
47
|
+
CLI.logger.info 'Shutting down'
|
48
|
+
CLI.logger.info 'Bye!'
|
48
49
|
|
49
50
|
# Explicitly exit so busy Processor threads won't block process shutdown.
|
50
51
|
#
|
@@ -62,27 +63,31 @@ class Canto
|
|
62
63
|
# Heroku sends TERM and then waits 30 seconds for process to exit.
|
63
64
|
'TERM' => ->(_) { raise Interrupt },
|
64
65
|
'TSTP' => ->(_) {
|
65
|
-
|
66
|
+
CLI.logger.info 'Received TSTP, no longer accepting new work'
|
66
67
|
},
|
67
68
|
'TTIN' => ->(_) {
|
68
69
|
Thread.list.each do |thread|
|
69
|
-
|
70
|
+
CLI.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
|
70
71
|
if thread.backtrace
|
71
|
-
|
72
|
+
CLI.logger.warn thread.backtrace.join("\n")
|
72
73
|
else
|
73
|
-
|
74
|
+
CLI.logger.warn '<no backtrace available>'
|
74
75
|
end
|
75
76
|
end
|
76
77
|
}
|
77
|
-
}
|
78
|
-
UNHANDLED_SIGNAL_HANDLER = ->(_) {
|
78
|
+
}
|
79
|
+
UNHANDLED_SIGNAL_HANDLER = ->(_) { CLI.logger.info 'No signal handler registered, ignoring' }
|
79
80
|
SIGNAL_HANDLERS.default = UNHANDLED_SIGNAL_HANDLER
|
80
81
|
|
81
82
|
def handle_signal(sig)
|
82
|
-
|
83
|
+
CLI.logger.debug "Got #{sig} signal"
|
83
84
|
SIGNAL_HANDLERS[sig].call(self)
|
84
85
|
end
|
85
86
|
|
87
|
+
def options
|
88
|
+
@options ||= Canto::DEFAULTS
|
89
|
+
end
|
90
|
+
|
86
91
|
def setup_options(args)
|
87
92
|
# parse CLI options
|
88
93
|
opts = parse_options(args)
|
@@ -99,12 +104,14 @@ class Canto
|
|
99
104
|
opts
|
100
105
|
end
|
101
106
|
|
107
|
+
alias_method :die, :exit
|
108
|
+
|
102
109
|
def set_environment(cli_env)
|
103
110
|
@environment = cli_env || ENV['APP_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
104
111
|
end
|
105
112
|
|
106
113
|
def initialize_logger
|
107
|
-
|
114
|
+
CLI.logger = Logger.new($stdout, level: Logger::INFO)
|
108
115
|
end
|
109
116
|
|
110
117
|
def boot_application
|
@@ -116,11 +123,11 @@ class Canto
|
|
116
123
|
def validate!
|
117
124
|
if !File.exist?(options[:require]) ||
|
118
125
|
(File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
126
|
+
CLI.logger.info '=================================================================='
|
127
|
+
CLI.logger.info ' Please point Canto to Ruby file '
|
128
|
+
CLI.logger.info ' to load your classes with -r [FILE].'
|
129
|
+
CLI.logger.info '=================================================================='
|
130
|
+
CLI.logger.info @parser
|
124
131
|
die(1)
|
125
132
|
end
|
126
133
|
end
|
@@ -143,7 +150,7 @@ class Canto
|
|
143
150
|
|
144
151
|
parser.banner = 'canto [options]'
|
145
152
|
parser.on_tail '-h', '--help', 'Show help' do
|
146
|
-
|
153
|
+
CLI.logger.info parser
|
147
154
|
die 1
|
148
155
|
end
|
149
156
|
|
data/lib/canto/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Merkulov
|
@@ -19,16 +19,9 @@ executables:
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- ".circleci/config.yml"
|
23
|
-
- ".gitignore"
|
24
|
-
- ".ruby-version"
|
25
|
-
- ".standard.yml"
|
26
22
|
- CODE_OF_CONDUCT.md
|
27
|
-
- Gemfile
|
28
|
-
- Gemfile.lock
|
29
23
|
- LICENSE.txt
|
30
24
|
- README.md
|
31
|
-
- Rakefile
|
32
25
|
- bin/canto
|
33
26
|
- canto.gemspec
|
34
27
|
- lib/canto.rb
|
data/.circleci/config.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
orbs:
|
3
|
-
ruby: circleci/ruby@1.0.0
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
build:
|
7
|
-
docker:
|
8
|
-
- image: circleci/ruby:2.7.2
|
9
|
-
|
10
|
-
steps:
|
11
|
-
- checkout
|
12
|
-
- ruby/install-deps
|
13
|
-
|
14
|
-
minitest:
|
15
|
-
docker:
|
16
|
-
- image: circleci/ruby:2.7.2
|
17
|
-
environment:
|
18
|
-
BUNDLE_JOBS: 3
|
19
|
-
BUNDLE_RETRY: 3
|
20
|
-
BUNDLE_PATH: vendor/bundle
|
21
|
-
|
22
|
-
steps:
|
23
|
-
- checkout
|
24
|
-
- ruby/install-deps
|
25
|
-
|
26
|
-
- run:
|
27
|
-
name: Stale code fix
|
28
|
-
command: git fetch && git reset --hard origin/${CIRCLE_BRANCH}
|
29
|
-
- run:
|
30
|
-
name: Minitest
|
31
|
-
command: bundle exec rake test
|
32
|
-
|
33
|
-
workflows:
|
34
|
-
tests:
|
35
|
-
jobs:
|
36
|
-
- build
|
37
|
-
- minitest:
|
38
|
-
requires:
|
39
|
-
- build
|
data/.gitignore
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.7.2
|
data/.standard.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#fix: true # default: false
|
2
|
-
parallel: true # default: false
|
3
|
-
#format: progress # default: Standard::Formatter
|
4
|
-
#ruby_version: 2.3.3 # default: RUBY_VERSION
|
5
|
-
#default_ignores: false # default: true
|
6
|
-
#
|
7
|
-
ignore:
|
8
|
-
- './**/*':
|
9
|
-
- Style/RescueModifier
|
10
|
-
- Style/StringLiterals
|
11
|
-
- Style/StringLiteralsInInterpolation
|
12
|
-
- Lint/AssignmentInCondition
|
13
|
-
- Security/YAMLLoad
|
14
|
-
- Layout/SpaceInsideHashLiteralBraces
|
15
|
-
- Layout/ArgumentAlignment
|
16
|
-
- Standard/SemanticBlocks
|
17
|
-
# - 'db/schema.rb'
|
18
|
-
# - 'vendor/**/*'
|
19
|
-
- 'config/**/*'
|
20
|
-
- 'spec/**/*':
|
21
|
-
- Layout/EmptyLinesAroundBlockBody
|
22
|
-
# - Layout/AlignHash
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
canto (0.1.2)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
minitest (5.14.3)
|
10
|
-
rake (12.3.3)
|
11
|
-
|
12
|
-
PLATFORMS
|
13
|
-
ruby
|
14
|
-
|
15
|
-
DEPENDENCIES
|
16
|
-
canto!
|
17
|
-
minitest (~> 5.0)
|
18
|
-
rake (~> 12.0)
|
19
|
-
|
20
|
-
BUNDLED WITH
|
21
|
-
2.1.4
|