redis-set 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/redis/set.rb +67 -0
- data/redis-set.gemspec +25 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f92eb97fa5e6b6a92a3fd2626601b71fa3fd672c
|
4
|
+
data.tar.gz: e4a4ef26258223dbf23648ad9451808ef531e7ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44445bd85204bacb5d94c8916d3ef040f32ec61ae87ea917f7071856d456cb145c9e5c41cd57d4cacf8b5c39edc69e1e8dddfbbfc8fc66658a10b6a32858c0d1
|
7
|
+
data.tar.gz: cdf1eb9a32bf14bad861a68425411bf1696aace19872c7ca3276c02928545cca5dfee99d046da4c91db34776dfe5a7422b14e438a95892a2682ed04e040aa7c4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Redis::Set
|
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/redis/set`. 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
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'redis-set'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install redis-set
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/redis-set.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "redis/set"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/redis/set.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require "redis"
|
2
|
+
|
3
|
+
class Redis
|
4
|
+
class Set
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
VERSION = "0.0.1"
|
8
|
+
|
9
|
+
class InvalidNameException < StandardError; end;
|
10
|
+
class InvalidRedisConfigException < StandardError; end;
|
11
|
+
|
12
|
+
def initialize(name, redis_or_options = {})
|
13
|
+
raise InvalidNameException.new unless name.kind_of?(String) && name.size > 0
|
14
|
+
@name = name
|
15
|
+
@redis = if redis_or_options.kind_of? Redis
|
16
|
+
redis_or_options
|
17
|
+
elsif redis_or_options.kind_of? Hash
|
18
|
+
Redis.new redis_or_options
|
19
|
+
else
|
20
|
+
raise InvalidRedisConfigException.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add value
|
25
|
+
@redis.sadd name, value
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_multi *values
|
29
|
+
if values.size > 0
|
30
|
+
values = values.first if 1 == values.size && values.first.kind_of?(Array)
|
31
|
+
@redis.sadd name, values
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def remove value
|
36
|
+
@redis.srem name, value
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_multi *values
|
40
|
+
if values.size > 0
|
41
|
+
values = values.first if 1 == values.size && values.first.kind_of?(Array)
|
42
|
+
@redis.srem name, values
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def include? value
|
47
|
+
@redis.sismember(name, value)
|
48
|
+
end
|
49
|
+
|
50
|
+
def size
|
51
|
+
@redis.scard name
|
52
|
+
end
|
53
|
+
|
54
|
+
def all
|
55
|
+
@redis.smembers name
|
56
|
+
end
|
57
|
+
|
58
|
+
def clear
|
59
|
+
@redis.del name
|
60
|
+
[]
|
61
|
+
end
|
62
|
+
|
63
|
+
def expire seconds
|
64
|
+
@redis.expire name, seconds
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/redis-set.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'redis/set'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "redis-set"
|
8
|
+
spec.version = Redis::Set::VERSION
|
9
|
+
spec.authors = ["Misha Conway"]
|
10
|
+
spec.email = ["mishaAconway@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Lightweight wrapper over redis sets.}
|
13
|
+
spec.description = %q{Lightweight wrapper over redis sets.}
|
14
|
+
spec.homepage = "https://github.com/MishaConway/ruby-redis-set"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_runtime_dependency 'redis'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redis-set
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Misha Conway
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redis
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Lightweight wrapper over redis sets.
|
56
|
+
email:
|
57
|
+
- mishaAconway@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- bin/console
|
67
|
+
- bin/setup
|
68
|
+
- lib/redis/set.rb
|
69
|
+
- redis-set.gemspec
|
70
|
+
homepage: https://github.com/MishaConway/ruby-redis-set
|
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.6.7
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Lightweight wrapper over redis sets.
|
94
|
+
test_files: []
|