yaml_cache 0.1.0 → 0.2.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: cc6419739cdc3626128aa721dc4e9553ed43446ae3d065c696537da98ae3a509
4
- data.tar.gz: e563f88ad73a3a6f1764a5a1f02faca49e375612d0a2f4b01d992a393bc407c3
3
+ metadata.gz: 54b25d047ecaa020d7407977c6b4b0a5c4b05cb56fd65c1d134f9f501c760151
4
+ data.tar.gz: 0c42a0c84a153bcfcfa4f6c50148882053d726678ccd93c6934e5f29073cc172
5
5
  SHA512:
6
- metadata.gz: 11aaa878fbd409d3fb8758ee6de6b3b561bf08e1a36526e99dc209e8fcdb0b658f56cf858adbddabff310add6aa014cf922534f443666abbbc232e4348049797
7
- data.tar.gz: b724d7102382e6e71a38bfe71558052ca86005f28368ee23c570e84d225aac5eb9bc947a559bcfd1f8ca96248afcd2cee60d2b2c94ad0103074678d32d7e84cf
6
+ metadata.gz: 76250821c9eda52063a789012ee52123e1a15d51dfffa19b7b7dac9537e3d5afea8a9df5a0f8d5fe76785dac507f8eaee1576ee08bacf2ea4b792ad0728082cc
7
+ data.tar.gz: cb3b347381cdc24d592c72853cb23cb5d332c1eab735beb0e6c7eaaabaa7115dcca365ca16d834a620ad863672ae3fe39593b86dc2c51c10c63205912f7398f2
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ Gemfile.lock
@@ -1,5 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.0
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
7
+ - 2.6
8
+ - 2.7
9
+ - ruby-head
10
+ before_install: gem install bundler
data/README.md CHANGED
@@ -1,16 +1,13 @@
1
- # YamlStore
1
+ # YAML Cache ![TravisCI](https://travis-ci.org/HellRok/YAMLCache.svg?branch=master)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yaml_store`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is a simple gem written in plain ruby just to store and cache data in a
4
+ yaml file.
6
5
 
7
6
  ## Installation
8
7
 
9
8
  Add this line to your application's Gemfile:
10
9
 
11
- ```ruby
12
- gem 'yaml_store'
13
- ```
10
+ ```ruby gem 'yaml_cache' ```
14
11
 
15
12
  And then execute:
16
13
 
@@ -18,22 +15,64 @@ And then execute:
18
15
 
19
16
  Or install it yourself as:
20
17
 
21
- $ gem install yaml_store
18
+ $ gem install yaml_cache
22
19
 
23
20
  ## Usage
24
21
 
25
- TODO: Write usage instructions here
22
+ To save and retrieve simple data all you need to do is:
23
+
24
+ ```
25
+ require 'yaml_cache'
26
+
27
+ store = YAMLCache.new('store.yml')
28
+ store.write('example', 'Here is some example text')
29
+ store.read('example')
30
+ ```
31
+
32
+ `#write` will return the amount of bytes written to the file, this may change
33
+ in the past.
34
+
35
+ To cache a block you'll need to do something more like:
36
+
37
+ ```
38
+ require 'yaml_cache'
39
+
40
+ store = YAMLCache.new('store.yml')
41
+
42
+ store.cache('key_1', 3600) {
43
+ 'Some data'
44
+ }
45
+
46
+ # or
47
+
48
+ store.cache('key_2', 60) do
49
+ 'Some other data'
50
+ end
51
+ ```
52
+
53
+ The first argument is the key to store the data under while the second argument
54
+ is how many seconds to cache this for. If you call `#cache` with the same key
55
+ again before it expires it will just return the value intsead of running the
56
+ block.
26
57
 
27
58
  ## Development
28
59
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
61
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
62
+ prompt that will allow you to experiment.
30
63
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To
65
+ release a new version, update the version number in `version.rb`, and then run
66
+ `bundle exec rake release`, which will create a git tag for the version, push
67
+ git commits and tags, and push the `.gem` file to
68
+ [rubygems.org](https://rubygems.org).
32
69
 
33
70
  ## Contributing
34
71
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yaml_store.
72
+ Bug reports and pull requests are welcome on GitHub at
73
+ https://github.com/HellRok/YAMLCache
36
74
 
37
75
  ## License
38
76
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
77
+ The gem is available as open source under the terms of the [MIT
78
+ License](https://opensource.org/licenses/MIT).
@@ -37,7 +37,7 @@ class YAMLCache
37
37
 
38
38
  private
39
39
  def load_store
40
- if File.exists?(@path)
40
+ if File.exist?(@path)
41
41
  YAML.load(File.read(@path))
42
42
  else
43
43
  {}
@@ -1,3 +1,3 @@
1
1
  module YamlCache
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.16"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "minitest", "~> 5.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
26
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Ross Earle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2019-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '0'
55
55
  description: A simple gem for storing and caching data in a YAML file
56
56
  email:
57
57
  - sean.earle@oeQuacki.com
@@ -62,7 +62,6 @@ files:
62
62
  - ".gitignore"
63
63
  - ".travis.yml"
64
64
  - Gemfile
65
- - Gemfile.lock
66
65
  - LICENSE.txt
67
66
  - README.md
68
67
  - Rakefile
@@ -70,7 +69,6 @@ files:
70
69
  - bin/setup
71
70
  - lib/yaml_cache.rb
72
71
  - lib/yaml_cache/version.rb
73
- - test.yml
74
72
  - title.md
75
73
  - tmp/.keep
76
74
  - yaml_cache.gemspec
@@ -93,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
91
  - !ruby/object:Gem::Version
94
92
  version: '0'
95
93
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.7.3
94
+ rubygems_version: 3.1.2
98
95
  signing_key:
99
96
  specification_version: 4
100
97
  summary: Store and cache data in a YAML file
@@ -1,22 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- yaml_cache (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- minitest (5.11.3)
10
- rake (10.5.0)
11
-
12
- PLATFORMS
13
- ruby
14
-
15
- DEPENDENCIES
16
- bundler (~> 1.16)
17
- minitest (~> 5.0)
18
- rake (~> 10.0)
19
- yaml_cache!
20
-
21
- BUNDLED WITH
22
- 1.16.1
data/test.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- hello:
3
- :value: there
4
- :expiration:
5
- cache:
6
- :value: snth
7
- :expiration: 1523344130