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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8283a0484e69a02427e400c08cc8e2723f7a11eef457f484b2b034877f0fa619
4
- data.tar.gz: 39dc8d9fa3b6dda285095f11b493fac616da2bdd65d389e4b14982eef90c8f7e
3
+ metadata.gz: 7cdcfe3b468b95ac736006e23eb2a1f92859d35cdd87bd0d83f6d7b945953060
4
+ data.tar.gz: bafa130368f18840c8cd0e8d07762ca186a075235f86bea6336058080d5532ee
5
5
  SHA512:
6
- metadata.gz: b0dbdb7a346792e757e24f9d133d5fee3b40c6fb82e713b1978170d26c514da77331e3bd7b1010d9506a0d32bf99a6b59f98f851258f1d16177b2dc8de7ef93e
7
- data.tar.gz: 139189a993d8ff8b111af0c4c4edb3016202344db3771a73b30d022c65a6bdedbf89f32acdcff492a9d998ae498a41fc1a2ae22d0c9d6ce3ab093c3001831c67
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
- # Specify which files should be added to the gem when it is released.
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
@@ -3,5 +3,5 @@ require 'canto/version'
3
3
  module Canto
4
4
  DEFAULTS = {
5
5
  environment: nil
6
- }.freeze
6
+ }
7
7
  end
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
- class Canto
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(launcher, boot_app: true)
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
- Canto.logger.info 'Shutting down'
47
- Canto.logger.info 'Bye!'
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
- Canto.logger.info 'Received TSTP, no longer accepting new work'
66
+ CLI.logger.info 'Received TSTP, no longer accepting new work'
66
67
  },
67
68
  'TTIN' => ->(_) {
68
69
  Thread.list.each do |thread|
69
- Canto.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
70
+ CLI.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
70
71
  if thread.backtrace
71
- Canto.logger.warn thread.backtrace.join("\n")
72
+ CLI.logger.warn thread.backtrace.join("\n")
72
73
  else
73
- Canto.logger.warn '<no backtrace available>'
74
+ CLI.logger.warn '<no backtrace available>'
74
75
  end
75
76
  end
76
77
  }
77
- }.freeze
78
- UNHANDLED_SIGNAL_HANDLER = ->(_) { Canto.logger.info 'No signal handler registered, ignoring' }
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
- Canto.logger.debug "Got #{sig} signal"
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
- Canto.logger = Logger.new($stdout, level: Logger::INFO)
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
- Canto.logger.info '=================================================================='
120
- Canto.logger.info ' Please point Canto to Ruby file '
121
- Canto.logger.info ' to load your classes with -r [FILE].'
122
- Canto.logger.info '=================================================================='
123
- Canto.logger.info @parser
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
- Canto.logger.info parser
153
+ CLI.logger.info parser
147
154
  die 1
148
155
  end
149
156
 
data/lib/canto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Canto
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
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.2
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
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- *.gem
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
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in canto.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "minitest", "~> 5.0"
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
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task default: :test