mshard 0.5.1 → 0.6.0

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
- SHA1:
3
- metadata.gz: de175ccd52325447343f0fc921f9a179ce00781c
4
- data.tar.gz: 66842743f204b3dc2b4edfc4eac63f05905e9dd4
2
+ SHA256:
3
+ metadata.gz: c1c3402edf233d0507268a414888a70b2ba1f34ebfdfe340ed85d41ae301ac4a
4
+ data.tar.gz: 984aa0b58c23299638b77f2cb3ecd03d7a1e98e410cfd86ae1738068f0ad8399
5
5
  SHA512:
6
- metadata.gz: d8fa017c7ee81f5453dfa6e0155d489ec2057b4dff4a22154fd261fdefbb7e5c846278731e6222e60e96836334fe8ae2ea72d95bcd3bc0b113d51bb316be7ce7
7
- data.tar.gz: 84ac787249a1d035c94e397184ebc84d5fbb89c1f1b9dc3ae68b8f925ae90cd9538d185b12666619ce2c715f9d0dee9c1d409c684698687bac4c6fe4e447ede5
6
+ metadata.gz: b47ea5e4e1dad5c263139deb310cd9a92624857f89a06f0216bb0079cd7d6d6bff81fb338bd189280cfb5799fe976d18764e7367115ede3ca7715876bed06f89
7
+ data.tar.gz: bd62b6289966690e80297fd72d4d9245754edde823342f47461db12daa8929777fdb7da6c5f76d87db5bf27fcb53c5e0609da9bfc1399b5f59e8c762c32ac764
@@ -0,0 +1,2 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
data/.rubocop.yml CHANGED
@@ -1,15 +1,5 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- Style/RegexpLiteral:
4
- Exclude:
5
- - 'Guardfile'
6
- - 'mshard.gemspec'
7
-
8
- Metrics/LineLength:
9
- Exclude:
10
- - 'spec/spec_helper.rb'
11
-
12
- Metrics/BlockLength:
13
- Exclude:
14
- - '*.gemspec'
15
- - 'spec/**/*'
1
+ inherit_gem:
2
+ mbs: rubocop.yml
3
+ inherit_from:
4
+ - .rubocop_todo.yml
5
+ - .rubocop.local.yml
data/.rubocop_todo.yml CHANGED
@@ -1,10 +0,0 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-07-30 20:01:55 +0900 using RuboCop version 0.29.1.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Offense count: 3
9
- Style/Documentation:
10
- Enabled: false
data/.travis.yml CHANGED
@@ -2,9 +2,11 @@ language: ruby
2
2
  sudo: false
3
3
  rvm:
4
4
  - ruby-head
5
- - 2.2.5
6
- - 2.3.1
7
- - 2.4.0
5
+ - '2.2.5'
6
+ - '2.3.1'
7
+ - '2.4.0'
8
+ - '2.4.2'
9
+ - '2.5.0'
8
10
  before_install:
9
11
  - gem update --system
10
12
  - gem install bundler
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in mshard.gemspec
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mshard (0.5.1)
5
- haml
4
+ mshard (0.6.0)
6
5
  httparty
7
6
  no_proxy_fix
7
+ slack-notifier
8
8
  thor
9
9
 
10
10
  GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
- ast (2.3.0)
14
- codecov (0.1.9)
13
+ ast (2.4.0)
14
+ codecov (0.1.10)
15
15
  json
16
16
  simplecov
17
17
  url
18
- coderay (1.1.1)
18
+ coderay (1.1.2)
19
19
  diff-lcs (1.3)
20
20
  docile (1.1.5)
21
- ffi (1.9.17)
21
+ ffi (1.9.23)
22
22
  formatador (0.2.5)
23
- guard (2.14.1)
23
+ guard (2.14.2)
24
24
  formatador (>= 0.2.4)
25
25
  listen (>= 2.7, < 4.0)
26
- lumberjack (~> 1.0)
26
+ lumberjack (>= 1.0.12, < 2.0)
27
27
  nenv (~> 0.1)
28
28
  notiffany (~> 0.0)
29
29
  pry (>= 0.9.12)
@@ -34,69 +34,69 @@ GEM
34
34
  guard (~> 2.1)
35
35
  guard-compat (~> 1.1)
36
36
  rspec (>= 2.99.0, < 4.0)
37
- guard-rubocop (1.2.0)
37
+ guard-rubocop (1.3.0)
38
38
  guard (~> 2.0)
39
39
  rubocop (~> 0.20)
40
- haml (4.0.7)
41
- tilt
42
- httparty (0.14.0)
40
+ httparty (0.16.0)
43
41
  multi_xml (>= 0.5.2)
44
- json (2.0.3)
42
+ json (2.1.0)
45
43
  listen (3.1.5)
46
44
  rb-fsevent (~> 0.9, >= 0.9.4)
47
45
  rb-inotify (~> 0.9, >= 0.9.7)
48
46
  ruby_dep (~> 1.2)
49
- lumberjack (1.0.11)
50
- method_source (0.8.2)
47
+ lumberjack (1.0.12)
48
+ mbs (0.0.2)
49
+ thor
50
+ method_source (0.9.0)
51
51
  multi_xml (0.6.0)
52
52
  nenv (0.3.0)
53
- no_proxy_fix (0.1.0)
53
+ no_proxy_fix (0.1.2)
54
54
  notiffany (0.1.1)
55
55
  nenv (~> 0.1)
56
56
  shellany (~> 0.0)
57
- parser (2.3.3.1)
58
- ast (~> 2.2)
57
+ parallel (1.12.1)
58
+ parser (2.5.0.3)
59
+ ast (~> 2.4.0)
59
60
  powerpack (0.1.1)
60
- pry (0.10.4)
61
+ pry (0.11.3)
61
62
  coderay (~> 1.1.0)
62
- method_source (~> 0.8.1)
63
- slop (~> 3.4)
64
- rainbow (2.2.1)
63
+ method_source (~> 0.9.0)
64
+ rainbow (3.0.0)
65
65
  rake (10.5.0)
66
- rb-fsevent (0.9.8)
67
- rb-inotify (0.9.8)
68
- ffi (>= 0.5.0)
69
- rspec (3.5.0)
70
- rspec-core (~> 3.5.0)
71
- rspec-expectations (~> 3.5.0)
72
- rspec-mocks (~> 3.5.0)
73
- rspec-core (3.5.4)
74
- rspec-support (~> 3.5.0)
75
- rspec-expectations (3.5.0)
66
+ rb-fsevent (0.10.3)
67
+ rb-inotify (0.9.10)
68
+ ffi (>= 0.5.0, < 2)
69
+ rspec (3.7.0)
70
+ rspec-core (~> 3.7.0)
71
+ rspec-expectations (~> 3.7.0)
72
+ rspec-mocks (~> 3.7.0)
73
+ rspec-core (3.7.1)
74
+ rspec-support (~> 3.7.0)
75
+ rspec-expectations (3.7.0)
76
76
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.5.0)
78
- rspec-mocks (3.5.0)
77
+ rspec-support (~> 3.7.0)
78
+ rspec-mocks (3.7.0)
79
79
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.5.0)
81
- rspec-support (3.5.0)
82
- rubocop (0.47.1)
83
- parser (>= 2.3.3.1, < 3.0)
80
+ rspec-support (~> 3.7.0)
81
+ rspec-support (3.7.1)
82
+ rubocop (0.53.0)
83
+ parallel (~> 1.10)
84
+ parser (>= 2.5)
84
85
  powerpack (~> 0.1)
85
- rainbow (>= 1.99.1, < 3.0)
86
+ rainbow (>= 2.2.2, < 4.0)
86
87
  ruby-progressbar (~> 1.7)
87
88
  unicode-display_width (~> 1.0, >= 1.0.1)
88
- ruby-progressbar (1.8.1)
89
+ ruby-progressbar (1.9.0)
89
90
  ruby_dep (1.5.0)
90
91
  shellany (0.0.1)
91
- simplecov (0.13.0)
92
+ simplecov (0.15.1)
92
93
  docile (~> 1.1.0)
93
94
  json (>= 1.8, < 3)
94
95
  simplecov-html (~> 0.10.0)
95
- simplecov-html (0.10.0)
96
- slop (3.6.0)
97
- thor (0.19.4)
98
- tilt (2.0.6)
99
- unicode-display_width (1.1.3)
96
+ simplecov-html (0.10.2)
97
+ slack-notifier (2.3.2)
98
+ thor (0.20.0)
99
+ unicode-display_width (1.3.0)
100
100
  url (0.3.2)
101
101
 
102
102
  PLATFORMS
@@ -108,6 +108,7 @@ DEPENDENCIES
108
108
  guard
109
109
  guard-rspec
110
110
  guard-rubocop
111
+ mbs
111
112
  mshard!
112
113
  pry
113
114
  rake (~> 10.0)
@@ -116,4 +117,4 @@ DEPENDENCIES
116
117
  simplecov
117
118
 
118
119
  BUNDLED WITH
119
- 1.14.3
120
+ 1.16.1
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A sample Guardfile
2
4
  # More info at https://github.com/guard/guard#readme
3
5
 
@@ -50,7 +52,7 @@ guard :rspec, cmd: 'bundle exec rspec' do
50
52
  end
51
53
 
52
54
  guard :rubocop do
53
- watch(%r{.+\.rb$})
55
+ watch(/.+\.rb$/)
54
56
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
55
57
  watch(%r{(?:.+/)?\.rubocop_todo\.yml$}) { |m| File.dirname(m[0]) }
56
58
  end
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rubocop/rake_task'
@@ -10,4 +12,4 @@ task :cov do
10
12
  Rake::Task[:spec].execute
11
13
  end
12
14
 
13
- task default: [:cov, :rubocop]
15
+ task default: %i[cov rubocop]
data/exe/ding CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'mshard'
4
5
  require 'mshard/ding'
data/exe/ting CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'mshard'
4
5
  require 'mshard/ting'
data/lib/mshard/ding.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
2
4
  require 'mshard'
3
5
 
@@ -6,12 +8,7 @@ module MShard
6
8
  namespace :''
7
9
  argument :text, default: 'Ding!', required: false
8
10
  def ding
9
- MShard.new.set_safe(
10
- slack: true,
11
- webhook_url: ENV['SLACK_WEBHOOK_URI'],
12
- channel: ENV['SLACK_CHANNEL'],
13
- text: text
14
- )
11
+ MShard.new.notify(text: text)
15
12
  end
16
13
  end
17
14
  end
data/lib/mshard/mshard.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'httparty'
2
4
  require 'no_proxy_fix'
3
- require 'haml'
5
+ require 'slack-notifier'
4
6
 
5
7
  module MShard
6
8
  class MShard
@@ -19,7 +21,7 @@ module MShard
19
21
  times.times do
20
22
  begin
21
23
  return yield
22
- rescue
24
+ rescue StandardError
23
25
  sleep delay
24
26
  end
25
27
  end
@@ -30,39 +32,20 @@ module MShard
30
32
  try { get(*args) }
31
33
  end
32
34
 
33
- def set_safe(*args) # rubocop:disable Style/AccessorMethodName
35
+ def set_safe(*args) # rubocop:disable Naming/AccessorMethodName
34
36
  try { set(*args) }
35
37
  end
36
38
 
37
- ERROR_TEMPLATE = <<-HAML.freeze
38
- !!! 5
39
- %html
40
- %head
41
- %meta{ name: 'viewport', content: 'width=device-width,initial-scale=1.0' }
42
- %title Error
43
- %body
44
- %p
45
- %pre
46
- &= e.inspect
47
- %p
48
- %pre
49
- &= e.backtrace.join("\\n")
50
- HAML
51
-
52
- def error_to_html(e)
53
- Haml::Engine.new(ERROR_TEMPLATE).render(Object.new, e: e)
39
+ def detour?
40
+ ENV['http_proxy']
54
41
  end
55
42
 
56
- def set_error(e, **opt)
57
- set_safe(
58
- {
59
- pushbullet: true,
60
- type: 'link',
61
- title: 'Error!',
62
- body: "#{e.class}\nClick here",
63
- contents: error_to_html(e)
64
- }.merge(opt)
65
- )
43
+ def notify(**args)
44
+ return set(args) if detour?
45
+ args[:slack] ||= true
46
+ args[:webhook_url] ||= ENV['SLACK_WEBHOOK_URI']
47
+ args[:channel] ||= ENV['SLACK_CHANNEL']
48
+ Slack::Notifier.new(args[:webhook_url], **args).ping(args[:text])
66
49
  end
67
50
  end
68
51
  end
data/lib/mshard/ting.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
2
4
  require 'mshard'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MShard
2
- VERSION = '0.5.1'.freeze
4
+ VERSION = '0.6.0'
3
5
  end
data/lib/mshard.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mshard/version'
2
4
 
3
5
  module MShard
data/mshard.gemspec CHANGED
@@ -1,9 +1,11 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'mshard/version'
5
7
 
6
- Gem::Specification.new do |spec|
8
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
7
9
  spec.name = 'mshard'
8
10
  spec.version = MShard::VERSION
9
11
  spec.authors = ['Minwoo Lee']
@@ -20,16 +22,17 @@ Gem::Specification.new do |spec|
20
22
  spec.require_paths = ['lib']
21
23
 
22
24
  spec.add_dependency 'httparty'
23
- spec.add_dependency 'haml'
24
- spec.add_dependency 'thor'
25
25
  spec.add_dependency 'no_proxy_fix'
26
+ spec.add_dependency 'slack-notifier'
27
+ spec.add_dependency 'thor'
26
28
  spec.add_development_dependency 'bundler', '~> 1.7'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec'
29
- spec.add_development_dependency 'rubocop'
30
- spec.add_development_dependency 'simplecov'
31
29
  spec.add_development_dependency 'guard'
32
30
  spec.add_development_dependency 'guard-rspec'
33
31
  spec.add_development_dependency 'guard-rubocop'
32
+ spec.add_development_dependency 'mbs'
34
33
  spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rspec'
36
+ spec.add_development_dependency 'rubocop'
37
+ spec.add_development_dependency 'simplecov'
35
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mshard'
2
4
 
3
5
  describe MShard::MShard do
@@ -35,21 +37,4 @@ describe MShard::MShard do
35
37
  expect(subject.set_safe(:params)).to eq(:id)
36
38
  end
37
39
  end
38
-
39
- it '#set_error works' do
40
- expect(described_class).to receive(:post).and_return('id' => :id)
41
- e = double(inspect: :inspect, backtrace: [:a, :b])
42
- expect(subject.set_error(e)).to eq(:id)
43
- end
44
-
45
- it '#error_to_html works' do
46
- e = begin
47
- raise
48
- rescue => e
49
- e
50
- end
51
- html = subject.error_to_html(e)
52
- expect(html).to include('<title>Error</title>')
53
- expect(html).to include('<pre>RuntimeError</pre>')
54
- end
55
40
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by the `rspec --init` command. Conventionally, all
2
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
5
  # The generated `.rspec` file contains `--require spec_helper` which will cause
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mshard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minwoo Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2018-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: haml
28
+ name: no_proxy_fix
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: thor
42
+ name: slack-notifier
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: no_proxy_fix
56
+ name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -81,21 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: guard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rspec
98
+ name: guard-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rubocop
112
+ name: guard-rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: simplecov
126
+ name: mbs
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: guard
140
+ name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,21 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: guard-rspec
154
+ name: rake
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '10.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '10.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - ">="
@@ -165,7 +179,7 @@ dependencies:
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
- name: guard-rubocop
182
+ name: rubocop
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - ">="
@@ -179,7 +193,7 @@ dependencies:
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
- name: pry
196
+ name: simplecov
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
@@ -203,6 +217,7 @@ extra_rdoc_files: []
203
217
  files:
204
218
  - ".gitignore"
205
219
  - ".rspec"
220
+ - ".rubocop.local.yml"
206
221
  - ".rubocop.yml"
207
222
  - ".rubocop_todo.yml"
208
223
  - ".travis.yml"
@@ -244,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
259
  version: '0'
245
260
  requirements: []
246
261
  rubyforge_project:
247
- rubygems_version: 2.6.8
262
+ rubygems_version: 2.7.3
248
263
  signing_key:
249
264
  specification_version: 4
250
265
  summary: MShard