red_line 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f28a484d6e1a64173dd1e123894ca2708157237893b6498b8de38a4cdc3c2bb4
4
+ data.tar.gz: 458d5eb18e3e63254a793d497a21b42200274cef43a02f050e6b4937be992434
5
+ SHA512:
6
+ metadata.gz: dba0b8d914ab8684f9bd52333ea820a00985f37ffe785b87ea7a599c40bc8296d21a7767989ed945c12c4fa01437c46ef7b410c861230904cf3e4cadde81b8eb
7
+ data.tar.gz: 4ee5e7ff1a561a83784eccded8321ac7c638116eee6e0b35db128dedd0920bec96d2d836b6fd4edada9b7d5fcb22e8f20fc24525d77a6792a3de1cb70d9080d2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ gemspec
2
+
3
+ source 'https://rubygems.org'
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ varsity (0.0.1)
5
+ async (~> 1.20)
6
+ async-container (~> 0.14)
7
+ async-io (~> 1.24)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ async (1.20.1)
13
+ console (~> 1.0)
14
+ nio4r (~> 2.3)
15
+ timers (~> 4.1)
16
+ async-container (0.14.1)
17
+ async (~> 1.0)
18
+ async-io (~> 1.4)
19
+ process-group
20
+ async-io (1.24.0)
21
+ async (~> 1.14)
22
+ console (1.4.0)
23
+ diff-lcs (1.3)
24
+ nio4r (2.4.0)
25
+ process-group (1.1.0)
26
+ rspec (3.8.0)
27
+ rspec-core (~> 3.8.0)
28
+ rspec-expectations (~> 3.8.0)
29
+ rspec-mocks (~> 3.8.0)
30
+ rspec-core (3.8.2)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-expectations (3.8.4)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-mocks (3.8.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-support (3.8.2)
39
+ timers (4.3.0)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ rspec (= 3.8.0)
46
+ varsity!
47
+
48
+ BUNDLED WITH
49
+ 1.17.2
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2020 Mauricio Gomes
2
+
3
+ Varsity is an Open Source project licensed under the terms of
4
+ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
+ for license text.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # RedLine
data/lib/red_line.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'red_line/version'
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedLine
4
+ class Logger
5
+
6
+ COLORS = ::Hash[
7
+ black: 30,
8
+ red: 31,
9
+ green: 32,
10
+ yellow: 33,
11
+ blue: 34,
12
+ magenta: 35,
13
+ cyan: 36,
14
+ gray: 37,
15
+ light_cyan: 96,
16
+ white: 97
17
+ ].freeze
18
+
19
+ def self.color_code(code)
20
+ COLORS.fetch(code) { raise(ArgumentError, "Color #{code} not supported.") }
21
+ end
22
+
23
+ def self.colorize(input, color:)
24
+ "\e[#{color_code(color)}m#{input}\e[0m"
25
+ end
26
+
27
+ def self.log(topic:, message:)
28
+ puts "#{print_topic(topic)} #{message}"
29
+ end
30
+
31
+ def self.print_topic(topic)
32
+ topic_string = "[#{topic}]"
33
+
34
+ color = case topic.to_sym
35
+ when :primary_session
36
+ :green
37
+ when :previous_session, :back_to_session
38
+ :yellow
39
+ when :facebook, :twilio, :bandwidth
40
+ :blue
41
+ when :smooch
42
+ :magenta
43
+ when :alexa
44
+ :light_cyan
45
+ when :catch_all
46
+ :red
47
+ when :user
48
+ :white
49
+ else
50
+ :gray
51
+ end
52
+
53
+ colorize(topic_string, color: color)
54
+ end
55
+
56
+ class << self
57
+ alias_method :l, :log
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedLine
4
+ VERSION = "0.0.1"
5
+ end
data/red_line.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ require_relative "lib/red_line/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'red_line'
5
+ s.version = RedLine::VERSION
6
+ s.summary = 'RedLine'
7
+ s.description = 'Rate limiters backed by Redis.'
8
+ s.authors = ['Mauricio Gomes']
9
+ s.email = 'mauricio@edge14.com'
10
+ s.files = `git ls-files`.split("\n")
11
+ s.homepage = 'http://github.com/mgomes/red_line'
12
+ s.license = 'LGPL-3.0-only'
13
+ s.required_ruby_version = ">= 2.4.0"
14
+
15
+ s.add_dependency 'redis', '>= 4.0.2'
16
+
17
+ s.add_development_dependency 'rspec', '= 3.8.0'
18
+
19
+ end
@@ -0,0 +1,83 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |expectations|
8
+ # This option will default to `true` in RSpec 4. It makes the `description`
9
+ # and `failure_message` of custom matchers include text for helper methods
10
+ # defined using `chain`, e.g.:
11
+ # be_bigger_than(2).and_smaller_than(4).description
12
+ # # => "be bigger than 2 and smaller than 4"
13
+ # ...rather than:
14
+ # # => "be bigger than 2"
15
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16
+ end
17
+
18
+ # rspec-mocks config goes here. You can use an alternate test double
19
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
20
+ config.mock_with :rspec do |mocks|
21
+ # Prevents you from mocking or stubbing a method that does not exist on
22
+ # a real object. This is generally recommended, and will default to
23
+ # `true` in RSpec 4.
24
+ mocks.verify_partial_doubles = true
25
+ end
26
+
27
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
28
+ # have no way to turn it off -- the option exists only for backwards
29
+ # compatibility in RSpec 3). It causes shared context metadata to be
30
+ # inherited by the metadata hash of host groups and examples, rather than
31
+ # triggering implicit auto-inclusion in groups with matching metadata.
32
+ config.shared_context_metadata_behavior = :apply_to_host_groups
33
+
34
+ # The settings below are suggested to provide a good initial experience
35
+ # with RSpec, but feel free to customize to your heart's content.
36
+ =begin
37
+ # This allows you to limit a spec run to individual examples or groups
38
+ # you care about by tagging them with `:focus` metadata. When nothing
39
+ # is tagged with `:focus`, all examples get run. RSpec also provides
40
+ # aliases for `it`, `describe`, and `context` that include `:focus`
41
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
42
+ config.filter_run_when_matching :focus
43
+
44
+ # Allows RSpec to persist some state between runs in order to support
45
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
46
+ # you configure your source control system to ignore this file.
47
+ config.example_status_persistence_file_path = "spec/examples.txt"
48
+
49
+ # Limits the available syntax to the non-monkey patched syntax that is
50
+ # recommended. For more details, see:
51
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
52
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
53
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
54
+ config.disable_monkey_patching!
55
+
56
+ # Many RSpec users commonly either run the entire suite or an individual
57
+ # file, and it's useful to allow more verbose output when running an
58
+ # individual spec file.
59
+ if config.files_to_run.one?
60
+ # Use the documentation formatter for detailed output,
61
+ # unless a formatter has already been configured
62
+ # (e.g. via a command-line flag).
63
+ config.default_formatter = 'doc'
64
+ end
65
+
66
+ # Print the 10 slowest examples and example groups at the
67
+ # end of the spec run, to help surface which specs are running
68
+ # particularly slow.
69
+ config.profile_examples = 10
70
+
71
+ # Run specs in random order to surface order dependencies. If you find an
72
+ # order dependency and want to debug it, you can fix the order by providing
73
+ # the seed, which is printed after each run.
74
+ # --seed 1234
75
+ config.order = :random
76
+
77
+ # Seed global randomization in this process using the `--seed` CLI option.
78
+ # Setting this allows you to use `--seed` to deterministically reproduce
79
+ # test failures related to randomization by passing the same `--seed` value
80
+ # as the one that triggered the failure.
81
+ Kernel.srand config.seed
82
+ =end
83
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: red_line
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mauricio Gomes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redis
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.8.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.8.0
41
+ description: Rate limiters backed by Redis.
42
+ email: mauricio@edge14.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - Gemfile
48
+ - Gemfile.lock
49
+ - LICENSE
50
+ - README.md
51
+ - lib/red_line.rb
52
+ - lib/red_line/logger.rb
53
+ - lib/red_line/version.rb
54
+ - red_line.gemspec
55
+ - spec/spec_helper.rb
56
+ homepage: http://github.com/mgomes/red_line
57
+ licenses:
58
+ - LGPL-3.0-only
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.4.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.1.2
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: RedLine
79
+ test_files: []