gry 0.5.0 → 0.5.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: 61403908364d6b8a076ca3b158db740638fd99e6
4
- data.tar.gz: 9f8a3b348cb9990fd1cf20994f4aa115a78ebbd2
3
+ metadata.gz: 4d98ff82687336eb4415781113ec6e57f4dbd0f0
4
+ data.tar.gz: c60d4f8ba0b5e842f702195a345de65be1bc51ee
5
5
  SHA512:
6
- metadata.gz: 67ae839eb8b9fdf577a41e7ee82060c4b87c251bb95e9ff939ee270179ecd5ee262a06624299fc36d549e625deabf0dd4846668a25fcfe48fae43eb6e44c81fc
7
- data.tar.gz: 0b898367f552894f237520ad88432628f77ada36703024b19073f45e12df553fed9dadd7d502aa2ed240347d62e3aeb4ec7cff736530895234b101c8e6fdbea7
6
+ metadata.gz: fd0c95889ea318ea84506a05b184214bd2f38b9f0c29b604bcaf2aa8990537701338fed1d9b92b607c33636847046a0c2b3c0ff35275e07ffd3ca5fbc25d0dba
7
+ data.tar.gz: 972475b1098b2ddc90736dbb9e996f5af913ef7d20adb60744ef840752f5e15fbfb86d0155bcf8fa0d0e699829af28c41b93187f5a2ce4469c1ee419191a72fb
data/lib/gry.rb CHANGED
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'optparse'
6
6
  require 'open3'
7
7
  require 'pathname'
8
+ require 'digest/sha1'
8
9
 
9
10
  require 'rubocop'
10
11
  require 'parallel'
@@ -1,6 +1,6 @@
1
1
  module Gry
2
2
  class CLI
3
- CACHE_PATH = Pathname(ENV['XDG_CACHE_HOME'] || '~/.cache').expand_path / 'gry/cache'
3
+ CACHE_DIR = Pathname(ENV['XDG_CACHE_HOME'] || '~/.cache').expand_path / 'gry'
4
4
 
5
5
  def initialize(argv)
6
6
  @argv = argv
@@ -40,19 +40,18 @@ module Gry
40
40
  end
41
41
 
42
42
  def save_cache(bills, cops)
43
- cache_dir = CACHE_PATH.dirname
44
- Dir.mkdir(cache_dir) unless cache_dir.exist?
43
+ Dir.mkdir(cache_dir) unless CACHE_DIR.exist?
45
44
  cache = {
46
45
  bills: bills,
47
46
  cops: cops,
48
47
  created_at: Time.now,
49
48
  }
50
- File.write(CACHE_PATH, Marshal.dump(cache))
49
+ File.write(cache_path, Marshal.dump(cache))
51
50
  end
52
51
 
53
52
  def restore_cache(cops)
54
- return unless CACHE_PATH.exist?
55
- cache = Marshal.load(File.read(CACHE_PATH))
53
+ return unless cache_path.exist?
54
+ cache = Marshal.load(File.read(cache_path))
56
55
 
57
56
  return unless cops == cache[:cops]
58
57
 
@@ -62,5 +61,9 @@ module Gry
62
61
 
63
62
  return cache[:bills]
64
63
  end
64
+
65
+ def cache_path
66
+ CACHE_DIR / Digest::SHA1.hexdigest(Dir.pwd)
67
+ end
65
68
  end
66
69
  end
@@ -1,3 +1,3 @@
1
1
  module Gry
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-07 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler