canto 0.1.1 → 0.1.7

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: 1ba9fa4b8f3343f632b9e27d1e0c2f120f1da9153a26246fd17841dc01be0168
4
- data.tar.gz: aca81b3cdba80fc1a30058b26a893220767b3c7d5d2b700b84b1d1e334dfb535
3
+ metadata.gz: b22df70bad61c5ef02d4686deb6f156dc9da82a81708776feefeb3937b18a57d
4
+ data.tar.gz: 3301bcce470c49c9518fb2dee686f226a9ea242be44a34560906c5792e2082af
5
5
  SHA512:
6
- metadata.gz: 848321171b428cc4cd4c273fe91be75b8f83d9997fda96ddcadfbdb8bfb552fb99e5d9b2cef05b39d491b2bc2d34e129b61998bcf76221f888194b8a90076cc4
7
- data.tar.gz: 932942e844a8db0b665f94e8d12c4f827ad5eaf0604f5167fedb4849158eed2c7637edf9045e55ce211eb15a99d17795ff77af7253efb18517f72343b8ba9045
6
+ metadata.gz: 982d66bfce451a5a9336d2c1b2c3287e983463fb1208f7415a3280feecd056cbd48bcf2a2c0a3bbaf258b67098fbf45dcc4f80b223670e11c0d5a52400cd5a37
7
+ data.tar.gz: 3dbb6bac4b6063196d9a6a5b3ae836648ebc57b08d0e558f06d824dbaae77c4c2062ba8e24a4f5576da9ad438d977ba0cb4120c3af76e480b8c1bccb79a25c16
data/canto.gemspec CHANGED
@@ -15,12 +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.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.executables = ['canto']
25
21
  spec.require_paths = ['lib']
26
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,24 +63,24 @@ 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
 
@@ -99,12 +100,14 @@ class Canto
99
100
  opts
100
101
  end
101
102
 
103
+ alias_method :die, :exit
104
+
102
105
  def set_environment(cli_env)
103
106
  @environment = cli_env || ENV['APP_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
104
107
  end
105
108
 
106
109
  def initialize_logger
107
- Canto.logger = Logger.new($stdout, level: Logger::INFO)
110
+ CLI.logger = Logger.new($stdout, level: Logger::INFO)
108
111
  end
109
112
 
110
113
  def boot_application
@@ -116,11 +119,11 @@ class Canto
116
119
  def validate!
117
120
  if !File.exist?(options[:require]) ||
118
121
  (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
122
+ CLI.logger.info '=================================================================='
123
+ CLI.logger.info ' Please point Canto to Ruby file '
124
+ CLI.logger.info ' to load your classes with -r [FILE].'
125
+ CLI.logger.info '=================================================================='
126
+ CLI.logger.info @parser
124
127
  die(1)
125
128
  end
126
129
  end
@@ -143,7 +146,7 @@ class Canto
143
146
 
144
147
  parser.banner = 'canto [options]'
145
148
  parser.on_tail '-h', '--help', 'Show help' do
146
- Canto.logger.info parser
149
+ CLI.logger.info parser
147
150
  die 1
148
151
  end
149
152
 
data/lib/canto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Canto
2
- VERSION = "0.1.1".freeze
2
+ VERSION = '0.1.7'.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.1
4
+ version: 0.1.7
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.1)
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