restify 2.0.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/restify/relation.rb +6 -2
- data/lib/restify/version.rb +1 -1
- data/spec/restify/relation_spec.rb +54 -1
- data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/README.md +23 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/CHANGELOG.md +255 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/README.rdoc +40 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
- data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/README.md +48 -0
- data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/README.md +138 -0
- data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/LICENSE +56 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
- data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/README.md +167 -0
- data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/CHANGELOG.md +375 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/README.md +118 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/CHANGELOG.md +473 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE +24 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE.SPECS +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/README.md +137 -0
- data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/LICENSE.txt +16 -0
- data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/README.md +187 -0
- data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/README.md +127 -0
- data/vendor/bundle/ruby/3.4.0/gems/little-plugger-1.1.4/README.rdoc +53 -0
- data/vendor/bundle/ruby/3.4.0/gems/logger-1.7.0/README.md +104 -0
- data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/LICENSE +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/README.md +140 -0
- data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.5/README.rdoc +842 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/ChangeLog +368 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/LICENSE +177 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/README.md +302 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/CHANGELOG.md +275 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/README.md +121 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/CHANGELOG.md +193 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/LICENSE +201 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/README.md +68 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/CHANGELOG.md +98 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/LICENSE +201 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/README.md +62 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/CHANGELOG.md +498 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/README.md +222 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/CHANGELOG.md +1146 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/README.md +355 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/README.rdoc +155 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
- data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/CHANGELOG.md +410 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/LICENSE +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/README.md +588 -0
- data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
- data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
- data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.3/README.md +55 -0
- metadata +66 -4
- data/doc/file.README.html +0 -192
@@ -0,0 +1,187 @@
|
|
1
|
+
# Hitimes
|
2
|
+
[](https://copiousfreetime.semaphoreci.com/projects/hitimes)
|
3
|
+
|
4
|
+
* [Homepage](http://github.com/copiousfreetime/hitimes)
|
5
|
+
* [Github project](http://github.com/copiousfreetime/hitimes)
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
|
9
|
+
A fast, high resolution timer library for recording performance metrics.
|
10
|
+
|
11
|
+
## TABLE OF CONTENTS
|
12
|
+
|
13
|
+
* [Requirements](#requirements)
|
14
|
+
* [Usage](#usage)
|
15
|
+
* [Contributing](#contributing)
|
16
|
+
* [Support](#support)
|
17
|
+
* [License](#license)
|
18
|
+
|
19
|
+
|
20
|
+
## REQUIREMENTS
|
21
|
+
|
22
|
+
Hitimes requires the following to run:
|
23
|
+
|
24
|
+
* Ruby
|
25
|
+
|
26
|
+
## USAGE
|
27
|
+
|
28
|
+
Hitimes easiest to use when installed with `rubygems`:
|
29
|
+
|
30
|
+
```sh
|
31
|
+
gem install hitimes
|
32
|
+
```
|
33
|
+
|
34
|
+
Or as part of your bundler `Gemfile`:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
gem "hitimes"
|
38
|
+
```
|
39
|
+
|
40
|
+
You can load it with the standard ruby require statement.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require "hitimes"
|
44
|
+
```
|
45
|
+
|
46
|
+
### Interval
|
47
|
+
|
48
|
+
Use `Hitimes::Interval` to calculate only the duration of a block of code.
|
49
|
+
Returns the time as seconds.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
duration = Hitimes::Interval.measure do
|
53
|
+
1_000_000.times do |x|
|
54
|
+
2 + 2
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
puts duration # => 0.047414297 (seconds)
|
59
|
+
```
|
60
|
+
|
61
|
+
### TimedMetric
|
62
|
+
|
63
|
+
Use a `Hitimes::TimedMetric` to calculate statistics about an iterative operation
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
timed_metric = Hitimes::TimedMetric.new("operation on items")
|
67
|
+
```
|
68
|
+
|
69
|
+
Explicitly use `start` and `stop`:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
collection.each do |item|
|
73
|
+
timed_metric.start
|
74
|
+
# .. do something with item
|
75
|
+
timed_metric.stop
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
Or use the block. In `TimedMetric` the return value of `measure` is the return
|
80
|
+
value of the block.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
collection.each do |item|
|
84
|
+
result_of_do_something = timed_metric.measure { do_something(item) }
|
85
|
+
# do something with result_of_do_something
|
86
|
+
end
|
87
|
+
```
|
88
|
+
And then look at the stats
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
puts timed_metric.mean
|
92
|
+
puts timed_metric.max
|
93
|
+
puts timed_metric.min
|
94
|
+
puts timed_metric.stddev
|
95
|
+
puts timed_metric.rate
|
96
|
+
```
|
97
|
+
|
98
|
+
### ValueMetric
|
99
|
+
|
100
|
+
Use a `Hitimes::ValueMetric` to calculate statistics about measured samples.
|
101
|
+
|
102
|
+
``` ruby
|
103
|
+
value_metric = Hitimes::ValueMetric.new("size of thing")
|
104
|
+
loop do
|
105
|
+
# ... do stuff changing sizes of 'thing'
|
106
|
+
value_metric.measure(thing.size)
|
107
|
+
# ... do other stuff that may change size of thing
|
108
|
+
end
|
109
|
+
|
110
|
+
puts value_metric.mean
|
111
|
+
puts value_metric.max
|
112
|
+
puts value_metric.min
|
113
|
+
puts value_metric.stddev
|
114
|
+
puts value_metric.rate
|
115
|
+
```
|
116
|
+
|
117
|
+
### TimedValueMetric
|
118
|
+
|
119
|
+
Use a `Hitimes::TimedValueMetric` to calculate statistics about batches of samples.
|
120
|
+
|
121
|
+
``` ruby
|
122
|
+
timed_value_metric = Hitimes::TimedValueMetric.new("batch times")
|
123
|
+
loop do
|
124
|
+
batch = ... # get a batch of things
|
125
|
+
timed_value_metric.start
|
126
|
+
# .. do something with batch
|
127
|
+
timed_value_metric.stop(batch.size)
|
128
|
+
end
|
129
|
+
|
130
|
+
puts timed_value_metric.rate
|
131
|
+
|
132
|
+
puts timed_value_metric.timed_stats.mean
|
133
|
+
puts timed_value_metric.timed_stats.max
|
134
|
+
puts timed_value_metric.timed_stats.min
|
135
|
+
puts timed_value_metric.timed_stats.stddev
|
136
|
+
|
137
|
+
puts timed_value_metric.value_stats.mean
|
138
|
+
puts timed_value_metric.value_stats.max
|
139
|
+
puts timed_value_metric.value_stats.min
|
140
|
+
puts timed_value_metric.value_stats.stddev
|
141
|
+
```
|
142
|
+
|
143
|
+
### Implementation details
|
144
|
+
|
145
|
+
Hitimes uses the internal ruby `Process::clock_gettime()` to
|
146
|
+
get the highest granularity time increment possible. Generally this is
|
147
|
+
nanosecond resolution, or whatever the hardware in the CPU supports.
|
148
|
+
|
149
|
+
## SUPPORT
|
150
|
+
|
151
|
+
Hitimes is supported on whatever versions of ruby are currently supported.
|
152
|
+
Hitimes also follows [semantic versioning](http://semver.org/).
|
153
|
+
|
154
|
+
The current officially supported versions of Ruby are:
|
155
|
+
|
156
|
+
* MRI Ruby (all platforms) 3.0 - current
|
157
|
+
* JRuby 9.4.x.x
|
158
|
+
* Truffleruby 24
|
159
|
+
|
160
|
+
Unofficially supported versions, any version of MRI from Ruby 2.1 and up. Since
|
161
|
+
the C Extension has been removed Hitimes should work with any ruby that is 2.1
|
162
|
+
or greater as that is when `Process.clock_gettime()` was implemented.
|
163
|
+
|
164
|
+
For versions of Ruby before 2.1 please use Hitimes 1.3, the extension code is
|
165
|
+
still in there and they should still work.
|
166
|
+
|
167
|
+
## CONTRIBUTING
|
168
|
+
|
169
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on development
|
170
|
+
and bug reporting.
|
171
|
+
|
172
|
+
## Credits
|
173
|
+
|
174
|
+
* [Bruce Williams](https://github.com/bruce) for suggesting the idea.
|
175
|
+
* [Benoit Daloze](https://github.com/eregon) and [Thomas Hurst](https://github.com/Freaky) for conversations around clock_ids.
|
176
|
+
|
177
|
+
## License
|
178
|
+
|
179
|
+
Hitimes is licensed under the [ISC](https://opensource.org/licenses/ISC)
|
180
|
+
license.
|
181
|
+
|
182
|
+
## Related Works
|
183
|
+
|
184
|
+
* [monotime](https://github.com/Freaky/monotime) - A sensible interface to Ruby's monotonic clock.
|
185
|
+
* [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) - [Concurrent.monotonic_time](https://github.com/ruby-concurrency/concurrent-ruby) is a straight pass through to `Process.clock_gettime(Process::CLOCK_MONOTONIC,...)`.
|
186
|
+
* [Instant](https://doc.rust-lang.org/src/std/time.rs.html) - The rust equivalent.
|
187
|
+
* [time.Now](https://pkg.go.dev/time) - The go monotonic time interface is part of this package.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 The Ruby I18n team
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Ruby I18n
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/i18n)
|
4
|
+
[](https://github.com/ruby-i18n/i18n/actions?query=workflow%3ARuby)
|
5
|
+
|
6
|
+
Ruby internationalization and localization (i18n) solution.
|
7
|
+
|
8
|
+
Currently maintained by @radar.
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
### Rails
|
13
|
+
|
14
|
+
You will most commonly use this library within a Rails app.
|
15
|
+
|
16
|
+
We support Rails versions from 6.0 and up.
|
17
|
+
|
18
|
+
[See the Rails Guide](https://guides.rubyonrails.org/i18n.html) for an example of its usage.
|
19
|
+
|
20
|
+
### Ruby (without Rails)
|
21
|
+
|
22
|
+
We support Ruby versions from 3.0 and up.
|
23
|
+
|
24
|
+
If you want to use this library without Rails, you can simply add `i18n` to your `Gemfile`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'i18n'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then configure I18n with some translations, and a default locale:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
I18n.load_path += Dir[File.expand_path("config/locales") + "/*.yml"]
|
34
|
+
I18n.default_locale = :en # (note that `en` is already the default!)
|
35
|
+
```
|
36
|
+
|
37
|
+
A simple translation file in your project might live at `config/locales/en.yml` and look like:
|
38
|
+
|
39
|
+
```yml
|
40
|
+
en:
|
41
|
+
test: "This is a test"
|
42
|
+
```
|
43
|
+
|
44
|
+
You can then access this translation by doing:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
I18n.t(:test)
|
48
|
+
```
|
49
|
+
|
50
|
+
You can switch locales in your project by setting `I18n.locale` to a different value:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
I18n.locale = :de
|
54
|
+
I18n.t(:test) # => "Dies ist ein Test"
|
55
|
+
```
|
56
|
+
|
57
|
+
## Features
|
58
|
+
|
59
|
+
* Translation and localization
|
60
|
+
* Interpolation of values to translations
|
61
|
+
* Pluralization (CLDR compatible)
|
62
|
+
* Customizable transliteration to ASCII
|
63
|
+
* Flexible defaults
|
64
|
+
* Bulk lookup
|
65
|
+
* Lambdas as translation data
|
66
|
+
* Custom key/scope separator
|
67
|
+
* Custom exception handlers
|
68
|
+
* Extensible architecture with a swappable backend
|
69
|
+
|
70
|
+
## Pluggable Features
|
71
|
+
|
72
|
+
* Cache
|
73
|
+
* Pluralization: lambda pluralizers stored as translation data
|
74
|
+
* Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation)
|
75
|
+
* [Gettext support](https://github.com/ruby-i18n/i18n/wiki/Gettext)
|
76
|
+
* Translation metadata
|
77
|
+
|
78
|
+
## Alternative Backend
|
79
|
+
|
80
|
+
* Chain
|
81
|
+
* ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs)
|
82
|
+
* KeyValue (uses active_support/json and cannot store procs)
|
83
|
+
|
84
|
+
For more information and lots of resources see [the 'Resources' page on the wiki](https://github.com/ruby-i18n/i18n/wiki/Resources).
|
85
|
+
|
86
|
+
## Tests
|
87
|
+
|
88
|
+
You can run tests both with
|
89
|
+
|
90
|
+
* `rake test` or just `rake`
|
91
|
+
* run any test file directly, e.g. `ruby -Ilib:test test/api/simple_test.rb`
|
92
|
+
|
93
|
+
You can run all tests against all Gemfiles with
|
94
|
+
|
95
|
+
* `ruby test/run_all.rb`
|
96
|
+
|
97
|
+
The structure of the test suite is a bit unusual as it uses modules to reuse
|
98
|
+
particular tests in different test cases.
|
99
|
+
|
100
|
+
The reason for this is that we need to enforce the I18n API across various
|
101
|
+
combinations of extensions. E.g. the Simple backend alone needs to support
|
102
|
+
the same API as any combination of feature and/or optimization modules included
|
103
|
+
to the Simple backend. We test this by reusing the same API definition (implemented
|
104
|
+
as test methods) in test cases with different setups.
|
105
|
+
|
106
|
+
You can find the test cases that enforce the API in test/api. And you can find
|
107
|
+
the API definition test methods in test/api/tests.
|
108
|
+
|
109
|
+
All other test cases (e.g. as defined in test/backend, test/core_ext) etc.
|
110
|
+
follow the usual test setup and should be easy to grok.
|
111
|
+
|
112
|
+
## More Documentation
|
113
|
+
|
114
|
+
Additional documentation can be found here: https://github.com/ruby-i18n/i18n/wiki
|
115
|
+
|
116
|
+
## Contributors
|
117
|
+
|
118
|
+
* @radar
|
119
|
+
* @carlosantoniodasilva
|
120
|
+
* @josevalim
|
121
|
+
* @knapo
|
122
|
+
* @tigrish
|
123
|
+
* [and many more](https://github.com/ruby-i18n/i18n/graphs/contributors)
|
124
|
+
|
125
|
+
## License
|
126
|
+
|
127
|
+
MIT License. See the included MIT-LICENSE file.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
= Little Plugger
|
2
|
+
* by Tim Pease
|
3
|
+
* http://github.com/TwP/little-plugger/tree/master
|
4
|
+
|
5
|
+
=== DESCRIPTION:
|
6
|
+
|
7
|
+
LittlePlugger is a module that provides Gem based plugin management.
|
8
|
+
By extending your own class or module with LittlePlugger you can easily
|
9
|
+
manage the loading and initializing of plugins provided by other gems.
|
10
|
+
|
11
|
+
=== FEATURES:
|
12
|
+
|
13
|
+
* List of plugins so that some plugins can be excluded while others are
|
14
|
+
loaded by default.
|
15
|
+
* Loading and initializing of plugins.
|
16
|
+
* Access to the plugin classes and modules.
|
17
|
+
|
18
|
+
LittlePlugger is a distallation of the plugin system from Hoe. It has been
|
19
|
+
"genericized" and encapsulated into its own easy to use module.
|
20
|
+
|
21
|
+
=== REQUIREMENTS:
|
22
|
+
|
23
|
+
Since Little Plugger is a Gem based plugin system, Ruby Gems must be
|
24
|
+
installed on your system.
|
25
|
+
|
26
|
+
=== INSTALL:
|
27
|
+
|
28
|
+
gem install little-plugger
|
29
|
+
|
30
|
+
=== LICENSE:
|
31
|
+
|
32
|
+
(The MIT License)
|
33
|
+
|
34
|
+
Copyright (c) 2009-2011
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
37
|
+
a copy of this software and associated documentation files (the
|
38
|
+
'Software'), to deal in the Software without restriction, including
|
39
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
40
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
41
|
+
permit persons to whom the Software is furnished to do so, subject to
|
42
|
+
the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be
|
45
|
+
included in all copies or substantial portions of the Software.
|
46
|
+
|
47
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
48
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
49
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
50
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
51
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
52
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
53
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Logger
|
2
|
+
|
3
|
+
Logger is a simple but powerful logging utility to output messages in your Ruby program.
|
4
|
+
|
5
|
+
Logger has the following features:
|
6
|
+
|
7
|
+
* Print messages to different levels such as `info` and `error`
|
8
|
+
* Auto-rolling of log files
|
9
|
+
* Setting the format of log messages
|
10
|
+
* Specifying a program name in conjunction with the message
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'logger'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install logger
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### Simple Example
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'logger'
|
34
|
+
|
35
|
+
# Create a Logger that prints to STDOUT
|
36
|
+
log = Logger.new(STDOUT)
|
37
|
+
log.debug("Created Logger")
|
38
|
+
|
39
|
+
log.info("Program finished")
|
40
|
+
|
41
|
+
# Create a Logger that prints to STDERR
|
42
|
+
error_log = Logger.new(STDERR)
|
43
|
+
error_log = error_log.error("fatal error")
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run the following to install dependencies.
|
49
|
+
|
50
|
+
```
|
51
|
+
$ bin/setup
|
52
|
+
```
|
53
|
+
|
54
|
+
Then, run the tests as:
|
55
|
+
|
56
|
+
```
|
57
|
+
$ rake test
|
58
|
+
```
|
59
|
+
|
60
|
+
To install this gem onto your local machine, run
|
61
|
+
|
62
|
+
```
|
63
|
+
$ rake install
|
64
|
+
```
|
65
|
+
|
66
|
+
To release a new version, update the version number in `lib/logger/version.rb`, and then run
|
67
|
+
|
68
|
+
```
|
69
|
+
$ rake release
|
70
|
+
```
|
71
|
+
|
72
|
+
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).
|
73
|
+
|
74
|
+
## Advanced Development
|
75
|
+
|
76
|
+
### Run tests of a specific file
|
77
|
+
|
78
|
+
```
|
79
|
+
$ ruby test/logger/test_logger.rb
|
80
|
+
```
|
81
|
+
|
82
|
+
### Run tests filtering test methods by a name
|
83
|
+
|
84
|
+
`--name` option is available as:
|
85
|
+
|
86
|
+
```
|
87
|
+
$ ruby test/logger/test_logger.rb --name test_lshift
|
88
|
+
```
|
89
|
+
|
90
|
+
### Publish documents to GitHub Pages
|
91
|
+
|
92
|
+
```
|
93
|
+
$ rake gh-pages
|
94
|
+
```
|
95
|
+
|
96
|
+
Then, git commit and push the generated HTMLs onto `gh-pages` branch.
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/logger.
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
The gem is available as open source under the terms of the [BSD-2-Clause](BSDL).
|
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2007-2022 Tim Pease
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,140 @@
|
|
1
|
+
[](https://github.com/TwP/logging/actions/workflows/ruby.yml)
|
2
|
+
|
3
|
+
## Logging
|
4
|
+
by Tim Pease
|
5
|
+
|
6
|
+
* [Homepage](http://rubygems.org/gems/logging)
|
7
|
+
* [Github Project](https://github.com/TwP/logging)
|
8
|
+
|
9
|
+
### Description
|
10
|
+
|
11
|
+
**Logging** is a flexible logging library for use in Ruby programs based on the
|
12
|
+
design of Java's log4j library. It features a hierarchical logging system,
|
13
|
+
custom level names, multiple output destinations per log event, custom
|
14
|
+
formatting, and more.
|
15
|
+
|
16
|
+
### Installation
|
17
|
+
|
18
|
+
```
|
19
|
+
gem install logging
|
20
|
+
```
|
21
|
+
|
22
|
+
### Examples
|
23
|
+
|
24
|
+
This example configures a logger to output messages in a format similar to the
|
25
|
+
core ruby Logger class. Only log messages that are warnings or higher will be
|
26
|
+
logged.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'logging'
|
30
|
+
|
31
|
+
logger = Logging.logger(STDOUT)
|
32
|
+
logger.level = :warn
|
33
|
+
|
34
|
+
logger.debug "this debug message will not be output by the logger"
|
35
|
+
logger.warn "this is your last warning"
|
36
|
+
```
|
37
|
+
|
38
|
+
In this example, a single logger is created that will append to STDOUT and to a
|
39
|
+
file. Only log messages that are informational or higher will be logged.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'logging'
|
43
|
+
|
44
|
+
logger = Logging.logger['example_logger']
|
45
|
+
logger.level = :info
|
46
|
+
|
47
|
+
logger.add_appenders \
|
48
|
+
Logging.appenders.stdout,
|
49
|
+
Logging.appenders.file('example.log')
|
50
|
+
|
51
|
+
logger.debug "this debug message will not be output by the logger"
|
52
|
+
logger.info "just some friendly advice"
|
53
|
+
```
|
54
|
+
|
55
|
+
The Logging library was created to allow each class in a program to have its
|
56
|
+
own configurable logger. The logging level for a particular class can be
|
57
|
+
changed independently of all other loggers in the system. This example shows
|
58
|
+
the recommended way of accomplishing this.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
require 'logging'
|
62
|
+
|
63
|
+
Logging.logger['FirstClass'].level = :warn
|
64
|
+
Logging.logger['SecondClass'].level = :debug
|
65
|
+
|
66
|
+
class FirstClass
|
67
|
+
def initialize
|
68
|
+
@logger = Logging.logger[self]
|
69
|
+
end
|
70
|
+
|
71
|
+
def some_method
|
72
|
+
@logger.debug "some method was called on #{self.inspect}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class SecondClass
|
77
|
+
def initialize
|
78
|
+
@logger = Logging.logger[self]
|
79
|
+
end
|
80
|
+
|
81
|
+
def another_method
|
82
|
+
@logger.debug "another method was called on #{self.inspect}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
There are many more examples in the [examples folder](/examples) of the logging
|
88
|
+
package. The recommended reading order is the following:
|
89
|
+
|
90
|
+
* [simple.rb](/examples/simple.rb)
|
91
|
+
* [rspec_integration.rb](/examples/rspec_integration.rb)
|
92
|
+
* [loggers.rb](/examples/loggers.rb)
|
93
|
+
* [classes.rb](/examples/classes.rb)
|
94
|
+
* [hierarchies.rb](/examples/hierarchies.rb)
|
95
|
+
* [names.rb](/examples/names.rb)
|
96
|
+
* [lazy.rb](/examples/lazy.rb)
|
97
|
+
* [appenders.rb](/examples/appenders.rb)
|
98
|
+
* [layouts.rb](/examples/layouts.rb)
|
99
|
+
* [reusing_layouts.rb](/examples/reusing_layouts.rb)
|
100
|
+
* [formatting.rb](/examples/formatting.rb)
|
101
|
+
* [colorization.rb](/examples/colorization.rb)
|
102
|
+
* [fork.rb](/examples/fork.rb)
|
103
|
+
* [mdc.rb](/examples/mdc.rb)
|
104
|
+
|
105
|
+
### Extending
|
106
|
+
|
107
|
+
The Logging framework is extensible via the [little-plugger](https://github.com/twp/little-plugger)
|
108
|
+
gem-based plugin system. New appenders, layouts, or filters can be released as ruby
|
109
|
+
gems. When installed locally, the Logging framework will automatically detect
|
110
|
+
these gems as plugins and make them available for use.
|
111
|
+
|
112
|
+
The [logging-email](https://github.com/twp/logging-email) plugin is a good
|
113
|
+
example to follow. It includes a [`lib/logging/plugins/email.rb`](https://github.com/twp/logging-email/tree/master/lib/logging/plugins/email.rb)
|
114
|
+
file which is detected by the plugin framework. This file declares a
|
115
|
+
`Logging::Plugins::Email.initialize_email` method that is called when the plugin
|
116
|
+
is loaded.
|
117
|
+
|
118
|
+
The three steps for creating a plugin are:
|
119
|
+
|
120
|
+
* create a new Ruby gem: `logging-<name>`
|
121
|
+
* include a plugin file: `lib/logging/plugins/<name>.rb`
|
122
|
+
* define a plugin initializer: `Logging::Plugins::<Name>.initialize_<name>`
|
123
|
+
|
124
|
+
### Development
|
125
|
+
|
126
|
+
The Logging source code relies on the Mr Bones project for default rake tasks.
|
127
|
+
You will need to install the Mr Bones gem if you want to build or test the
|
128
|
+
logging gem. Conveniently there is a bootstrap script that you can run to setup
|
129
|
+
your development environment.
|
130
|
+
|
131
|
+
```
|
132
|
+
script/bootstrap
|
133
|
+
```
|
134
|
+
|
135
|
+
This will install the Mr Bones gem and the required Ruby gems for development.
|
136
|
+
After this is done you can rake `rake -T` to see the available rake tasks.
|
137
|
+
|
138
|
+
### License
|
139
|
+
|
140
|
+
The MIT License - see the [LICENSE](/LICENSE) file for the full text.
|