mshard 0.7.1 → 0.8.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
2
  SHA256:
3
- metadata.gz: 0a533debc16fe3c2f1dad4735b5bb6307b991c1a4bf79f7462112767566a21c9
4
- data.tar.gz: 0f7c2af7de0c54fca819cb4da824508d5ce4f5aff94dd066cda03dbfc1f5efe4
3
+ metadata.gz: d40b4f1c40ef73418d1a893ea4e1f458eb026ea4ccfc2dd7607d1defabe8c24d
4
+ data.tar.gz: aade0a19e965836bd7dc56b65f379c847ad584570d09f0ad81c1e5cbc3746ad8
5
5
  SHA512:
6
- metadata.gz: d5e193fdc0c040a628c4cce3d63a64c6980a450380c40a5c2a6e5baf6d5a23c6c8107d11623f8eb64269d5dd28eb536d6854271a768fae773cbee4497b78cc3e
7
- data.tar.gz: 9b6e2efd1dd81a7d815b7d31a371688358c46eca53db08ab7258aa22465836316f7e3c8e6cebb8dbe77528ea43ace605b46fabb2b466fecca35fd70d98063f99
6
+ metadata.gz: 5436f66c8ae138f8aaec5525c04c1df3a40d6d67bad923dd55fa88314a73df2d8c6326907e6b39ba587352a90bc9c454580ef76c4878d0e95071757082d0273e
7
+ data.tar.gz: 8ba9bb3f1bfe1e8222aebc5c37650896a470f8ecce0db47b46a75c9f353d154b72855923a78371211455244d75ebb5efdd63ed646d7c1e9aad54968d83c55cb3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mshard (0.7.1)
4
+ mshard (0.8.0)
5
5
  hiredis
6
6
  httparty
7
7
  no_proxy_fix
@@ -20,8 +20,8 @@ GEM
20
20
  url
21
21
  coderay (1.1.2)
22
22
  diff-lcs (1.3)
23
- docile (1.1.5)
24
- ffi (1.9.23)
23
+ docile (1.3.1)
24
+ ffi (1.9.25)
25
25
  formatador (0.2.5)
26
26
  guard (2.14.2)
27
27
  formatador (>= 0.2.4)
@@ -41,15 +41,16 @@ GEM
41
41
  guard (~> 2.0)
42
42
  rubocop (~> 0.20)
43
43
  hiredis (0.6.1)
44
- httparty (0.16.1)
44
+ httparty (0.16.2)
45
45
  multi_xml (>= 0.5.2)
46
+ jaro_winkler (1.5.1)
46
47
  json (2.1.0)
47
48
  listen (3.1.5)
48
49
  rb-fsevent (~> 0.9, >= 0.9.4)
49
50
  rb-inotify (~> 0.9, >= 0.9.7)
50
51
  ruby_dep (~> 1.2)
51
- lumberjack (1.0.12)
52
- mbs (0.0.2)
52
+ lumberjack (1.0.13)
53
+ mbs (0.0.3)
53
54
  thor
54
55
  method_source (0.9.0)
55
56
  multi_xml (0.6.0)
@@ -59,9 +60,9 @@ GEM
59
60
  nenv (~> 0.1)
60
61
  shellany (~> 0.0)
61
62
  parallel (1.12.1)
62
- parser (2.5.0.3)
63
+ parser (2.5.1.2)
63
64
  ast (~> 2.4.0)
64
- powerpack (0.1.1)
65
+ powerpack (0.1.2)
65
66
  pry (0.11.3)
66
67
  coderay (~> 1.1.0)
67
68
  method_source (~> 0.9.0)
@@ -73,22 +74,23 @@ GEM
73
74
  redis (4.0.1)
74
75
  redis-namespace (1.6.0)
75
76
  redis (>= 3.0.4)
76
- rspec (3.7.0)
77
- rspec-core (~> 3.7.0)
78
- rspec-expectations (~> 3.7.0)
79
- rspec-mocks (~> 3.7.0)
80
- rspec-core (3.7.1)
81
- rspec-support (~> 3.7.0)
82
- rspec-expectations (3.7.0)
77
+ rspec (3.8.0)
78
+ rspec-core (~> 3.8.0)
79
+ rspec-expectations (~> 3.8.0)
80
+ rspec-mocks (~> 3.8.0)
81
+ rspec-core (3.8.0)
82
+ rspec-support (~> 3.8.0)
83
+ rspec-expectations (3.8.0)
83
84
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.7.0)
85
- rspec-mocks (3.7.0)
85
+ rspec-support (~> 3.8.0)
86
+ rspec-mocks (3.8.0)
86
87
  diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.7.0)
88
- rspec-support (3.7.1)
89
- rubocop (0.53.0)
88
+ rspec-support (~> 3.8.0)
89
+ rspec-support (3.8.0)
90
+ rubocop (0.58.2)
91
+ jaro_winkler (~> 1.5.1)
90
92
  parallel (~> 1.10)
91
- parser (>= 2.5)
93
+ parser (>= 2.5, != 2.5.1.1)
92
94
  powerpack (~> 0.1)
93
95
  rainbow (>= 2.2.2, < 4.0)
94
96
  ruby-progressbar (~> 1.7)
@@ -96,14 +98,14 @@ GEM
96
98
  ruby-progressbar (1.9.0)
97
99
  ruby_dep (1.5.0)
98
100
  shellany (0.0.1)
99
- simplecov (0.15.1)
100
- docile (~> 1.1.0)
101
+ simplecov (0.16.1)
102
+ docile (~> 1.1)
101
103
  json (>= 1.8, < 3)
102
104
  simplecov-html (~> 0.10.0)
103
105
  simplecov-html (0.10.2)
104
106
  slack-notifier (2.3.2)
105
107
  thor (0.20.0)
106
- unicode-display_width (1.3.0)
108
+ unicode-display_width (1.4.0)
107
109
  url (0.3.2)
108
110
 
109
111
  PLATFORMS
@@ -20,15 +20,17 @@ module MShard
20
20
  self.class.post('/v2/shards', body: params)['id']
21
21
  end
22
22
 
23
- def try(times: 3, delay: 2)
23
+ def try(times: 5, delay: 2)
24
+ error = nil
24
25
  times.times do
25
26
  begin
26
27
  return yield
27
- rescue StandardError
28
+ rescue StandardError => e
29
+ error = e
28
30
  sleep delay
29
31
  end
30
32
  end
31
- nil
33
+ raise error
32
34
  end
33
35
 
34
36
  def get_safe(*args)
@@ -51,6 +53,10 @@ module MShard
51
53
  Slack::Notifier.new(args[:webhook_url], **args).ping(args[:text])
52
54
  end
53
55
 
56
+ def notify_safe(**args)
57
+ try { notify(**args) }
58
+ end
59
+
54
60
  def self.redis_cache(uri)
55
61
  @cache ||= Hash.new do |hash, uri_|
56
62
  hash[uri_] = Redis::Namespace.new(:shard, redis: Redis.new(url: uri_))
@@ -63,6 +69,10 @@ module MShard
63
69
  self.class.redis_cache(redis_uri).get(id)
64
70
  end
65
71
 
72
+ def load_safe(*args)
73
+ try { load(*args) }
74
+ end
75
+
66
76
  def save(redis_uri: ENV['MSHARD_REDIS_URI'], **args)
67
77
  return set(**args) if detour? || redis_uri.nil?
68
78
  response =
@@ -70,5 +80,9 @@ module MShard
70
80
  raise response unless response == 'OK'
71
81
  args[:id]
72
82
  end
83
+
84
+ def save_safe(*args)
85
+ try { save(*args) }
86
+ end
73
87
  end
74
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MShard
4
- VERSION = '0.7.1'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  lib = File.expand_path('lib', __dir__)
@@ -5,7 +5,9 @@ require 'mshard'
5
5
  describe MShard::MShard do
6
6
  it '#try works' do
7
7
  expect(subject.try { :result }).to be(:result)
8
- expect(subject.try(delay: 0.01) { raise }).to be(nil)
8
+ end
9
+ it '#try works with an error' do
10
+ expect { subject.try(delay: 0.01) { raise } }.to raise_error(StandardError)
9
11
  end
10
12
 
11
13
  describe '#get' do
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.7.1
4
+ version: 0.8.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: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hiredis