fastly_nsq 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f152c638769443e0a5a05d21222eeb4830d4873
4
- data.tar.gz: d7bf933bf02602023f81c09480064745baf547cb
3
+ metadata.gz: 950954fc2bf0edcea6b24e7c364003e49c9e63e4
4
+ data.tar.gz: c38bb4c70dc6f506f6c9a34f69bde87f52c5ca81
5
5
  SHA512:
6
- metadata.gz: 987c9d1a7c2e654c8fcd540c6cd78f8d819a9b1723cabc74aee1a7ac27937d045c3c0ce2b80676dc171cb7b84e73d656d0b5b087618aff1dc67b4028f72847d2
7
- data.tar.gz: e2e808a1f5daea8da64331e47b5097a1b33efd43376adbe7da14f906d3ac51f88d987b4c81a073f965a35f42b1b672fd37d15a90890dc05b3f78e83681a061d4
6
+ metadata.gz: da7ead45aae0e4f3d60ce118f72caff6f5c3aa51906a22de672a76e232a18803d9ee1a63c9f2e362710239a611ba302ad63bf398414136921b7f6441e4031e50
7
+ data.tar.gz: 2fef46fb498b71900ad877ccfcd614f9e1b8dafc2efd48e8cbfef0cd4e438ae831299142c26036f6336f8ecaf4c77feeffe62663a526036bdac4a25fb499c583
data/.overcommit.yml ADDED
@@ -0,0 +1,34 @@
1
+ PreCommit:
2
+ ALL:
3
+ quiet: true
4
+ verify_signatures: false
5
+
6
+ MergeConflicts:
7
+ description: 'Checking for unaddressed merge conflicts'
8
+ enabled: true
9
+ quiet: true
10
+ required_executable: 'grep'
11
+ flags: ['-IHn', "^<<<<<<<[ \t]"]
12
+
13
+ RuboCop:
14
+ description: 'Checking Ruby style'
15
+ enabled: true
16
+ problem_on_unmodified_line: ignore
17
+ quiet: true
18
+ on_warn: fail
19
+
20
+ CommitMsg:
21
+ ALL:
22
+ quiet: true
23
+ CapitalizedSubject:
24
+ description: 'Ensuring commit message subjects are capitalized'
25
+ enabled: false
26
+ EmptyMessage:
27
+ description: 'Prevent empty commit messages'
28
+ enabled: true
29
+ TextWidth:
30
+ description: 'Ensure commit message subjects are <60 chars'
31
+ enabled: true
32
+ description: 'Checking text width'
33
+ max_subject_width: 60
34
+ max_body_width: 1000
data/.rubocop.yml ADDED
@@ -0,0 +1,72 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/Rakefile'
4
+ Exclude:
5
+ - 'db/schema.rb'
6
+ - 'vendor/**/*'
7
+ TargetRubyVersion: 2.1
8
+
9
+ LineLength:
10
+ Enabled: false
11
+
12
+ HashSyntax:
13
+ Enabled: false
14
+
15
+ BracesAroundHashParameters:
16
+ Enabled: false
17
+
18
+ CollectionMethods:
19
+ Enabled: false
20
+
21
+ CyclomaticComplexity:
22
+ Enabled: true
23
+
24
+ Style/DotPosition:
25
+ Enabled: true
26
+ EnforcedStyle: trailing
27
+ SupportedStyles:
28
+ - leading
29
+ - trailing
30
+
31
+ MethodLength:
32
+ Enabled: false
33
+
34
+ PerlBackrefs:
35
+ Enabled: false
36
+
37
+ RescueModifier:
38
+ Enabled: false
39
+
40
+ GuardClause:
41
+ Enabled: false
42
+
43
+ IfUnlessModifier:
44
+ Enabled: false
45
+
46
+ ClassLength:
47
+ Enabled: false
48
+
49
+ Style/ClassVars:
50
+ Description: 'Avoid the use of class variables.'
51
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
52
+ Enabled: false
53
+
54
+ Documentation:
55
+ Enabled: false
56
+
57
+ RegexpLiteral:
58
+ Enabled: false
59
+
60
+ SignalException:
61
+ EnforcedStyle: only_raise
62
+
63
+ Style/ClassAndModuleChildren:
64
+ Enabled: false
65
+
66
+ Style/TrailingCommaInLiteral:
67
+ EnforcedStyleForMultiline: comma
68
+ Enabled: true
69
+
70
+ Style/TrailingCommaInArguments:
71
+ EnforcedStyleForMultiline: comma
72
+ Enabled: true
data/Rakefile CHANGED
@@ -17,8 +17,10 @@ require 'rdoc/task'
17
17
  RDoc::Task.new
18
18
  task doc: :rdoc
19
19
 
20
- require 'bundler/audit/cli'
20
+ require 'rspec/core/rake_task'
21
+ RSpec::Core::RakeTask.new(:spec)
21
22
 
23
+ require 'bundler/audit/cli'
22
24
  namespace :bundler do
23
25
  desc 'Updates the ruby-advisory-db and runs audit'
24
26
  task :audit do
@@ -28,8 +30,8 @@ namespace :bundler do
28
30
  end
29
31
  end
30
32
 
31
- require 'rspec/core/rake_task'
32
- RSpec::Core::RakeTask.new(:spec)
33
+ require 'rubocop/rake_task'
34
+ RuboCop::RakeTask.new
33
35
 
34
36
  task(:default).clear
35
- task default: ['spec', 'bundler:audit']
37
+ task default: ['spec', 'rubocop', 'bundler:audit']
data/examples/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'fastly_nsq/rake_task'
5
5
 
6
6
  class MessageProcessor
7
7
  def self.topics
8
- ['customer_created', 'customer_deleted']
8
+ %w(customer_created customer_deleted)
9
9
  end
10
10
 
11
11
  # ...
data/fastly_nsq.gemspec CHANGED
@@ -21,12 +21,14 @@ Gem::Specification.new do |gem|
21
21
  gem.require_paths = ['lib']
22
22
 
23
23
  gem.add_development_dependency 'awesome_print', '~> 1.6'
24
- gem.add_development_dependency 'bundler', '~> 1.10'
25
- gem.add_development_dependency 'bundler-audit', '~> 0.4'
24
+ gem.add_development_dependency 'bundler', '~> 1.11.2'
25
+ gem.add_development_dependency 'bundler-audit', '~> 0.5.0'
26
+ gem.add_development_dependency 'overcommit', '~> 0.32.0'
26
27
  gem.add_development_dependency 'pry-byebug', '~> 3.3'
27
- gem.add_development_dependency 'rake', '~> 10.5'
28
- gem.add_development_dependency 'rdoc', '~> 4.2'
29
- gem.add_development_dependency 'rspec', '~> 3.4'
28
+ gem.add_development_dependency 'rake', '~> 11.1.2'
29
+ gem.add_development_dependency 'rdoc', '~> 4.2.2'
30
+ gem.add_development_dependency 'rspec', '~> 3.4.0'
31
+ gem.add_development_dependency 'rubocop', '~> 0.39.0'
30
32
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
31
33
 
32
34
  gem.add_dependency 'nsq-ruby', '~> 1.5.0', '>= 1.5.0'
@@ -50,7 +50,7 @@ module FakeMessageQueue
50
50
  def pop
51
51
  message = nil
52
52
 
53
- until message do
53
+ until message
54
54
  message = queue.pop
55
55
  sleep SECONDS_BETWEEN_QUEUE_CHECKS
56
56
  end
@@ -6,8 +6,8 @@ require_relative 'message_queue/consumer'
6
6
  require_relative 'message_queue/strategy'
7
7
 
8
8
  module MessageQueue
9
- FALSY_VALUES = [false, 0, '0', 'false', 'FALSE', 'off', 'OFF', nil]
10
- TRUTHY_VALUES = [true, 1, '1', 'true', 'TRUE', 'on', 'ON']
9
+ FALSY_VALUES = [false, 0, '0', 'false', 'FALSE', 'off', 'OFF', nil].freeze
10
+ TRUTHY_VALUES = [true, 1, '1', 'true', 'TRUE', 'on', 'ON'].freeze
11
11
 
12
12
  def self.logger=(logger)
13
13
  strategy.logger = logger
@@ -1,4 +1,4 @@
1
- class InvalidParameterError < StandardError; end;
1
+ class InvalidParameterError < StandardError; end
2
2
 
3
3
  module MessageQueue
4
4
  class Consumer
@@ -1,4 +1,4 @@
1
- class InvalidParameterError < StandardError; end;
1
+ class InvalidParameterError < StandardError; end
2
2
 
3
3
  module MessageQueue
4
4
  class Producer
@@ -7,10 +7,7 @@ module MessageQueue
7
7
 
8
8
  def initialize(*args, &task_block)
9
9
  @name = args.shift || :begin_listening
10
-
11
- unless ::Rake.application.last_comment
12
- desc 'Listen to NSQ on topic using channel'
13
- end
10
+ add_rake_task_description_if_one_needed
14
11
 
15
12
  task(name, *args) do |_, task_args|
16
13
  RakeFileUtils.send(:verbose, verbose) do
@@ -30,6 +27,12 @@ module MessageQueue
30
27
 
31
28
  private
32
29
 
30
+ def add_rake_task_description_if_one_needed
31
+ unless ::Rake.application.last_description
32
+ desc 'Listen to NSQ on topic using channel'
33
+ end
34
+ end
35
+
33
36
  def run_tasks
34
37
  topics.each do |topic|
35
38
  Thread.new do
@@ -1,3 +1,3 @@
1
1
  module FastlyNsq
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'.freeze
3
3
  end
@@ -141,11 +141,11 @@ RSpec.describe FakeMessageQueue::Consumer do
141
141
  channel: channel,
142
142
  )
143
143
 
144
- expect {
145
- Timeout::timeout(delay) do
144
+ expect do
145
+ Timeout.timeout(delay) do
146
146
  consumer.pop
147
147
  end
148
- }.to raise_error(Timeout::Error)
148
+ end.to raise_error(Timeout::Error)
149
149
  end
150
150
  end
151
151
  end
@@ -15,7 +15,7 @@ RSpec.describe MessageQueue::Consumer do
15
15
  nsqlookupd: ENV.fetch('NSQLOOKUPD_HTTP_ADDRESS'),
16
16
  topic: topic,
17
17
  channel: channel,
18
- ).at_least(:once)
18
+ ).at_least(:once)
19
19
  end
20
20
  end
21
21
 
@@ -32,7 +32,7 @@ RSpec.describe MessageQueue::Consumer do
32
32
  nsqlookupd: ENV.fetch('NSQLOOKUPD_HTTP_ADDRESS'),
33
33
  topic: topic,
34
34
  channel: channel,
35
- ).at_least(:once)
35
+ ).at_least(:once)
36
36
  end
37
37
  end
38
38
  end
@@ -45,7 +45,7 @@ RSpec.describe MessageQueue::Consumer do
45
45
 
46
46
  consumer = MessageQueue::Consumer.new(topic: topic, channel: channel)
47
47
 
48
- expect{ consumer.connection }.to raise_error(InvalidParameterError)
48
+ expect { consumer.connection }.to raise_error(InvalidParameterError)
49
49
  end
50
50
  end
51
51
 
@@ -21,7 +21,7 @@ RSpec.describe MessageQueue::Listener do
21
21
  it 'processes the message' do
22
22
  process_message = double(go: nil)
23
23
  allow(MessageProcessor).to receive(:new).and_return(process_message)
24
- message_body = { data: 'value' }.to_json
24
+ message_body = { data: 'value' }.to_json
25
25
  message = double('Message', finish: nil, body: message_body)
26
26
  connection = double('Connection', pop: message, terminate: nil)
27
27
  consumer = double('Consumer', connection: connection)
@@ -58,12 +58,12 @@ RSpec.describe MessageQueue::Listener do
58
58
  channel = 'testing_channel'
59
59
  delay = FakeMessageQueue::Consumer::SECONDS_BETWEEN_QUEUE_CHECKS + 0.1
60
60
 
61
- expect {
62
- Timeout::timeout(delay) do
61
+ expect do
62
+ Timeout.timeout(delay) do
63
63
  MessageQueue::Listener.new(topic: topic, channel: channel).
64
64
  process_next_message
65
65
  end
66
- }.to raise_error(Timeout::Error)
66
+ end.to raise_error(Timeout::Error)
67
67
  end
68
68
  end
69
69
  end
@@ -13,7 +13,7 @@ RSpec.describe MessageQueue::Producer do
13
13
  with(
14
14
  nsqd: ENV.fetch('NSQD_TCP_ADDRESS'),
15
15
  topic: topic,
16
- ).at_least(:once)
16
+ ).at_least(:once)
17
17
  end
18
18
  end
19
19
 
@@ -28,7 +28,7 @@ RSpec.describe MessageQueue::Producer do
28
28
  with(
29
29
  nsqd: ENV.fetch('NSQD_TCP_ADDRESS'),
30
30
  topic: topic,
31
- ).at_least(:once)
31
+ ).at_least(:once)
32
32
  end
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ RSpec.describe MessageQueue::Producer do
39
39
 
40
40
  producer = MessageQueue::Producer.new(topic: topic)
41
41
 
42
- expect{ producer.connection }.to raise_error(InvalidParameterError)
42
+ expect { producer.connection }.to raise_error(InvalidParameterError)
43
43
  end
44
44
  end
45
45
  end
@@ -22,7 +22,7 @@ RSpec.describe Strategy do
22
22
  it 'raises with a helpful error' do
23
23
  allow(ENV).to receive(:[]).with('FAKE_QUEUE').and_return('taco')
24
24
 
25
- expect{ Strategy.for_queue }.to raise_error(InvalidParameterError)
25
+ expect { Strategy.for_queue }.to raise_error(InvalidParameterError)
26
26
  end
27
27
  end
28
28
  end
@@ -37,7 +37,7 @@ RSpec.describe MessageQueue::RakeTask do
37
37
  context 'when multiple topics are defined' do
38
38
  it 'creates a listener for each' do
39
39
  channel = 'clown_generating_service'
40
- topics = ['customer_created', 'customer_now_awesome']
40
+ topics = %w(customer_created customer_now_awesome)
41
41
  allow(SampleMessageProcessor).to receive(:topics).and_return(topics)
42
42
  message_queue_listener = double('listener', go: nil)
43
43
  allow(MessageQueue::Listener).to receive(:new).
@@ -105,23 +105,24 @@ RSpec.describe MessageQueue::RakeTask do
105
105
  topics = ['customer_created']
106
106
  allow(SampleMessageProcessor).to receive(:topics).and_return(topics)
107
107
 
108
- expect {
108
+ expect do
109
109
  MessageQueue::RakeTask.new(:begin_listening, [:channel])
110
110
  Rake::Task['begin_listening'].execute
111
- }.to raise_error(ArgumentError, /channel is required/)
111
+ end.to raise_error(ArgumentError, /channel is required/)
112
112
  end
113
113
  end
114
114
 
115
115
  context 'when MessageProcessor.topics is not defined' do
116
116
  it 'raises an error' do
117
117
  channel = 'best_server_number_1'
118
+ error_message = /MessageProcessor.topics is not defined/
118
119
  allow(SampleMessageProcessor).to receive(:topics).
119
120
  and_raise(NoMethodError, "undefined method `topics'")
120
121
 
121
- expect {
122
+ expect do
122
123
  MessageQueue::RakeTask.new(:begin_listening, [:channel])
123
124
  Rake::Task['begin_listening'].execute(channel: channel)
124
- }.to raise_error(ArgumentError, /MessageProcessor.topics is not defined/)
125
+ end.to raise_error(ArgumentError, error_message)
125
126
  end
126
127
  end
127
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastly_nsq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy O'Neil
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-17 00:00:00.000000000 Z
12
+ date: 2016-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print
@@ -31,28 +31,42 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.10'
34
+ version: 1.11.2
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.10'
41
+ version: 1.11.2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler-audit
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.4'
48
+ version: 0.5.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0.4'
55
+ version: 0.5.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: overcommit
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.32.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.32.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: pry-byebug
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -73,42 +87,56 @@ dependencies:
73
87
  requirements:
74
88
  - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: '10.5'
90
+ version: 11.1.2
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '10.5'
97
+ version: 11.1.2
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rdoc
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - "~>"
89
103
  - !ruby/object:Gem::Version
90
- version: '4.2'
104
+ version: 4.2.2
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - "~>"
96
110
  - !ruby/object:Gem::Version
97
- version: '4.2'
111
+ version: 4.2.2
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: rspec
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - "~>"
103
117
  - !ruby/object:Gem::Version
104
- version: '3.4'
118
+ version: 3.4.0
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 3.4.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 0.39.0
105
133
  type: :development
106
134
  prerelease: false
107
135
  version_requirements: !ruby/object:Gem::Requirement
108
136
  requirements:
109
137
  - - "~>"
110
138
  - !ruby/object:Gem::Version
111
- version: '3.4'
139
+ version: 0.39.0
112
140
  - !ruby/object:Gem::Dependency
113
141
  name: rubygems-tasks
114
142
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +180,9 @@ files:
152
180
  - ".document"
153
181
  - ".github/PULL_REQUEST_TEMPLATE.md"
154
182
  - ".gitignore"
183
+ - ".overcommit.yml"
155
184
  - ".rdoc_options"
185
+ - ".rubocop.yml"
156
186
  - ".ruby-version"
157
187
  - ".travis.yml"
158
188
  - ChangeLog.md