ruboty-local_yaml 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +16 -0
- data/Rakefile +1 -0
- data/lib/ruboty/brains/local_yaml.rb +53 -0
- data/lib/ruboty/local_yaml.rb +3 -0
- data/lib/ruboty/local_yaml/version.rb +5 -0
- data/ruboty-local_yaml.gemspec +24 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45556d749eb5602fc0c9956ccbe92d491a858c3d
|
4
|
+
data.tar.gz: 86cfae1f5405097633bed0fc67974eefabb9e98f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64eea4da98c12f530d755bec615065e391ceff7bba3518793d00fb02de311669d9622aaf510fe1b1a17e153e07f89e45a9fe650fb96fe44fab4c03973fdef88d
|
7
|
+
data.tar.gz: 5730ca9b26f01fcbee8728815df374d77b0119826b81f15932b6c08fc150eba501fe9f5efdbf685cde695080bdf722eabeaf6542d5431a4d6dbf828ecbd18c79
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Ruboty::LocalYaml
|
2
|
+
|
3
|
+
Store [Ruboty](https://github.com/r7kamura/ruboty/)'s memory in local yaml file.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
```
|
7
|
+
# Gemfile
|
8
|
+
gem 'ruboty-local_yaml'
|
9
|
+
```
|
10
|
+
|
11
|
+
## ENV
|
12
|
+
```
|
13
|
+
LOCAL_YAML_FILE_PATH # Yaml path (default: ruboty.yml)
|
14
|
+
LOCAL_YAML_INTERVAL # Interval time to write (default: 5)
|
15
|
+
```
|
16
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Brains
|
5
|
+
class LocalYAML < Base
|
6
|
+
env :LOCAL_YAML_PATH, 'Yaml path', optional: true
|
7
|
+
env :LOCAL_YAML_SAVE_INTERVAL, 'Interval time to write', optional: true
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
@thread = Thread.new { sync }
|
12
|
+
@thread.abort_on_exception = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def data
|
16
|
+
@data ||= pull || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def push
|
22
|
+
yaml = data.to_yaml
|
23
|
+
return if yaml == @old_yaml
|
24
|
+
File.open(file_path, 'w') { |f| f.write yaml }
|
25
|
+
@old_yaml = yaml
|
26
|
+
end
|
27
|
+
|
28
|
+
def pull
|
29
|
+
return nil unless File.exist?(file_path)
|
30
|
+
YAML.load File.read(file_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def sync
|
34
|
+
loop do
|
35
|
+
wait
|
36
|
+
push
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def wait
|
41
|
+
sleep(interval)
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_path
|
45
|
+
(ENV['LOCAL_YAML_PATH'] || './ruboty.yml')
|
46
|
+
end
|
47
|
+
|
48
|
+
def interval
|
49
|
+
(ENV['LOCAL_YAML_SAVE_INTERVAL'] || 5).to_i
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/local_yaml/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ruboty-local_yaml'
|
8
|
+
spec.version = Ruboty::LocalYaml::VERSION
|
9
|
+
spec.authors = ['ru_shalm']
|
10
|
+
spec.email = ['ru_shalm@hazimu.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Store Ruboty's memory in local yaml file.}
|
13
|
+
spec.homepage = 'https://github.com/rutan/ruboty-local_yaml'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'ruboty'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-local_yaml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ru_shalm
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- ru_shalm@hazimu.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/ruboty/brains/local_yaml.rb
|
67
|
+
- lib/ruboty/local_yaml.rb
|
68
|
+
- lib/ruboty/local_yaml/version.rb
|
69
|
+
- ruboty-local_yaml.gemspec
|
70
|
+
homepage: https://github.com/rutan/ruboty-local_yaml
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.4.5.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Store Ruboty's memory in local yaml file.
|
94
|
+
test_files: []
|