cinch-storage 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/cinch-storage.gemspec +21 -0
- data/lib/cinch-storage.rb +2 -0
- data/lib/cinch-storage/storage.rb +18 -0
- data/lib/cinch-storage/version.rb +5 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brian Haberer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Cinch::Storage
|
2
|
+
|
3
|
+
Simple YAML backed Storage solution for Cinch plugins.
|
4
|
+
|
5
|
+
Warning: Once Cinch's author finishes Cinch::Storage I will deprecate this gem.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'cinch-storage'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cinch-storage
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In your plugin you will need to spin up a Storage object as part of your init.
|
24
|
+
|
25
|
+
def initialize(*args)
|
26
|
+
super
|
27
|
+
@storage = CinchStorage.new('yaml/plugin_name.yml')
|
28
|
+
@storage.data ||= {}
|
29
|
+
end
|
30
|
+
|
31
|
+
Then once you add or alter data and you want to write it out to the file you
|
32
|
+
can call `Storage#save`, but be sure to wrap it in a synchronize to avoid
|
33
|
+
data collision.
|
34
|
+
|
35
|
+
synchronize(:plugin_name_save) do
|
36
|
+
@storage.save
|
37
|
+
end
|
38
|
+
|
39
|
+
## This is Horrible Code!
|
40
|
+
|
41
|
+
The module is very fragile at the moment as a result of being written in like 20 minutes
|
42
|
+
or something as a stopgap.
|
43
|
+
|
44
|
+
However, since it doesn't look like Cinch::Storage will be happening very soon I will
|
45
|
+
be going back through and adding tests and error handling and proper debugging and a
|
46
|
+
little tighter integration with Cinch.
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cinch-storage/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "cinch-storage"
|
8
|
+
gem.version = Cinch::Storage::VERSION
|
9
|
+
gem.authors = ["Brian Haberer"]
|
10
|
+
gem.email = ["bhaberer@gmail.com"]
|
11
|
+
gem.description = %q{Simle YAML backed Storage solution for Cinch plugins.}
|
12
|
+
gem.summary = %q{Simle YAML backed Storage solution for Cinch plugins.}
|
13
|
+
gem.homepage = "https://github.com/bhaberer/cinch-storage"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('psych', '1.3.4')
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CinchStorage
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
attr_accessor :filename, :data
|
5
|
+
|
6
|
+
def initialize(file)
|
7
|
+
@filename = file
|
8
|
+
@data = YAML::load(File.open(@filename)) if File::exist?(@filename)
|
9
|
+
@data ||= Hash.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def save
|
13
|
+
File.open(@filename, 'w') do |file|
|
14
|
+
YAML::dump(@data, file)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-storage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Haberer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: psych
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.4
|
30
|
+
description: Simle YAML backed Storage solution for Cinch plugins.
|
31
|
+
email:
|
32
|
+
- bhaberer@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- cinch-storage.gemspec
|
43
|
+
- lib/cinch-storage.rb
|
44
|
+
- lib/cinch-storage/storage.rb
|
45
|
+
- lib/cinch-storage/version.rb
|
46
|
+
homepage: https://github.com/bhaberer/cinch-storage
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.24
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Simle YAML backed Storage solution for Cinch plugins.
|
70
|
+
test_files: []
|