rogu 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +59 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rogu.rb +49 -0
- data/lib/rogu/concern/logging.rb +29 -0
- data/lib/rogu/version.rb +5 -0
- data/rogu.gemspec +32 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5bd80b86c8daad56652b0a5298b37df9e396be75655e5226974aec216c6f5a55
|
4
|
+
data.tar.gz: ac4324946ca3fd3a54aab559211578b0777d667aa885ee361a9ae8ac1defa332
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ee5db321c6106c89f2877ade2d0ef401e843e816c7c5a4857e5ea639ede776de818a157a124470d8081b07dc9c36d89b422593fe6a832608f8a390887c0f5c1
|
7
|
+
data.tar.gz: 26618493b92d7feda38ab24a355434a86326fc25943917fc1a491a349c0a7c7f97504a7ab65e9f465092700fa0aa63049a8f790eef41fbf07968079de10b2af0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- '**/tmp/**/*'
|
4
|
+
- '**/script/**/*'
|
5
|
+
- Rakefile
|
6
|
+
- Gemfile
|
7
|
+
UseCache: true
|
8
|
+
TargetRubyVersion: 2.5
|
9
|
+
|
10
|
+
Layout/EmptyLinesAroundBlockBody:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/EmptyLinesAroundClassBody:
|
14
|
+
EnforcedStyle: empty_lines_except_namespace
|
15
|
+
|
16
|
+
Layout/EmptyLinesAroundModuleBody:
|
17
|
+
EnforcedStyle: empty_lines_except_namespace
|
18
|
+
|
19
|
+
Layout/MultilineMethodCallIndentation:
|
20
|
+
EnforcedStyle: indented_relative_to_receiver
|
21
|
+
|
22
|
+
Layout/SpaceInsidePercentLiteralDelimiters:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Metrics/BlockLength:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
|
29
|
+
# You can generally fit two splits/panes side by side plus a navigator window
|
30
|
+
# on a 1920x1080 display, using a decent font size (14px or 16px) as long as
|
31
|
+
# there's a 80 char limit.
|
32
|
+
Metrics/LineLength:
|
33
|
+
Max: 80
|
34
|
+
|
35
|
+
# Based on "How Long Can a Routine Be?" from Code Complete 2, which specifies
|
36
|
+
# 200 lines as a limit, adjusted for the the Ruby language, which is a lot
|
37
|
+
# more terse than Java or C++.
|
38
|
+
Metrics/MethodLength:
|
39
|
+
Max: 30
|
40
|
+
|
41
|
+
Style/FrozenStringLiteralComment:
|
42
|
+
EnforcedStyle: never
|
43
|
+
|
44
|
+
Style/GuardClause:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# By default Rubocop checks for literals, but since JRuby has immutable strings,
|
48
|
+
# all literals are already frozen.
|
49
|
+
Style/MutableConstant:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Style/NumericPredicate:
|
53
|
+
EnforcedStyle: comparison
|
54
|
+
|
55
|
+
Style/SymbolArray:
|
56
|
+
EnforcedStyle: brackets
|
57
|
+
|
58
|
+
Style/SymbolProc:
|
59
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rogu (0.0.1)
|
5
|
+
concurrent-ruby (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
concurrent-ruby (1.1.6)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
rake (13.0.1)
|
13
|
+
rspec (3.9.0)
|
14
|
+
rspec-core (~> 3.9.0)
|
15
|
+
rspec-expectations (~> 3.9.0)
|
16
|
+
rspec-mocks (~> 3.9.0)
|
17
|
+
rspec-core (3.9.2)
|
18
|
+
rspec-support (~> 3.9.3)
|
19
|
+
rspec-expectations (3.9.2)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.9.0)
|
22
|
+
rspec-mocks (3.9.1)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.9.0)
|
25
|
+
rspec-support (3.9.3)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 1.17)
|
32
|
+
rake (~> 13.0)
|
33
|
+
rogu!
|
34
|
+
rspec (~> 3.0)
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Andrei Maxim
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Rogu
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rogu`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rogu'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rogu
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rogu.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rogu'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rogu.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'concurrent'
|
2
|
+
|
3
|
+
require 'rogu/concern/logging'
|
4
|
+
|
5
|
+
module Rogu
|
6
|
+
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def create_logger(level = Logger::FATAL, output = $stderr)
|
10
|
+
lambda do |severity, progname, message = nil, &block|
|
11
|
+
return false if severity < level
|
12
|
+
|
13
|
+
message = block ? block.call : message
|
14
|
+
formatted_message = case message
|
15
|
+
when String
|
16
|
+
message
|
17
|
+
when Exception
|
18
|
+
format "%s (%s)\n%s",
|
19
|
+
message.message,
|
20
|
+
message.class,
|
21
|
+
(message.backtrace || []).join("\n")
|
22
|
+
else
|
23
|
+
message.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
output.print format "%5s -- %s: %s\n",
|
27
|
+
Logger::SEV_LABEL[severity],
|
28
|
+
progname,
|
29
|
+
formatted_message
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Use logger created by #create_logger to log messages.
|
35
|
+
def use_logger(level = Logger::FATAL, output = $stderr)
|
36
|
+
Rogu.logger = create_logger(level, output)
|
37
|
+
end
|
38
|
+
|
39
|
+
GLOBAL_LOGGER = Concurrent::AtomicReference.new(create_logger(Logger::WARN))
|
40
|
+
|
41
|
+
def logger
|
42
|
+
GLOBAL_LOGGER.value
|
43
|
+
end
|
44
|
+
|
45
|
+
def logger=(log)
|
46
|
+
GLOBAL_LOGGER.value = log
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Rogu
|
4
|
+
module Concern
|
5
|
+
# Enable logging where needed.
|
6
|
+
#
|
7
|
+
# Modified version of the Concurrent::Concern::Logging module, without
|
8
|
+
# the timestamp field as it is automatically added by Heroku.
|
9
|
+
module Logging
|
10
|
+
|
11
|
+
include Logger::Severity
|
12
|
+
|
13
|
+
# Logs through {Concurrent.global_logger}, it can be overridden by setting @logger
|
14
|
+
# @param [Integer] level one of Logger::Severity constants
|
15
|
+
# @param [String] progname e.g. a path of an Actor
|
16
|
+
# @param [String, nil] message when nil block is used to generate the message
|
17
|
+
# @yieldreturn [String] a message
|
18
|
+
def log(level, progname, message = nil, &block)
|
19
|
+
logger = ::Rogu.logger
|
20
|
+
|
21
|
+
logger.call(level, progname, message, &block)
|
22
|
+
rescue => error
|
23
|
+
$stderr.puts "`Rogu.logger` failed to log #{[level, progname, message, block]}\n" +
|
24
|
+
"#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/rogu/version.rb
ADDED
data/rogu.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rogu/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rogu'
|
9
|
+
spec.version = Rogu::VERSION
|
10
|
+
spec.authors = ['Andrei Maxim']
|
11
|
+
spec.email = ['andrei@andreimaxim.ro']
|
12
|
+
|
13
|
+
spec.summary = %q{Simple and thread-safe logging library for Heroku projects}
|
14
|
+
spec.homepage = 'https://github.com/andreimaxim/rogu'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
28
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
|
31
|
+
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rogu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrei Maxim
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: concurrent-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- andrei@andreimaxim.ro
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/rogu.rb
|
88
|
+
- lib/rogu/concern/logging.rb
|
89
|
+
- lib/rogu/version.rb
|
90
|
+
- rogu.gemspec
|
91
|
+
homepage: https://github.com/andreimaxim/rogu
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.0.3
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Simple and thread-safe logging library for Heroku projects
|
114
|
+
test_files: []
|