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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +7 -2
- data/README.md +52 -13
- data/lib/yaml_cache.rb +1 -1
- data/lib/yaml_cache/version.rb +1 -1
- data/yaml_cache.gemspec +3 -3
- metadata +15 -18
- data/Gemfile.lock +0 -22
- data/test.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54b25d047ecaa020d7407977c6b4b0a5c4b05cb56fd65c1d134f9f501c760151
|
4
|
+
data.tar.gz: 0c42a0c84a153bcfcfa4f6c50148882053d726678ccd93c6934e5f29073cc172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76250821c9eda52063a789012ee52123e1a15d51dfffa19b7b7dac9537e3d5afea8a9df5a0f8d5fe76785dac507f8eaee1576ee08bacf2ea4b792ad0728082cc
|
7
|
+
data.tar.gz: cb3b347381cdc24d592c72853cb23cb5d332c1eab735beb0e6c7eaaabaa7115dcca365ca16d834a620ad863672ae3fe39593b86dc2c51c10c63205912f7398f2
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# YAML Cache ![TravisCI](https://travis-ci.org/HellRok/YAMLCache.svg?branch=master)
|
2
2
|
|
3
|
-
|
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
|
18
|
+
$ gem install yaml_cache
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
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
|
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
|
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
|
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
|
77
|
+
The gem is available as open source under the terms of the [MIT
|
78
|
+
License](https://opensource.org/licenses/MIT).
|
data/lib/yaml_cache.rb
CHANGED
data/lib/yaml_cache/version.rb
CHANGED
data/yaml_cache.gemspec
CHANGED
@@ -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"
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "minitest"
|
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.
|
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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
|
-
|
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
|
data/Gemfile.lock
DELETED
@@ -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
|