redis_tools 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 ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redis_tools.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michael Gorsuch
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,35 @@
1
+ # RedisTools
2
+
3
+ A few command line derivations from the Redis command set.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'redis_tools'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install redis_tools
18
+
19
+ ## Usage
20
+
21
+ From the command line:
22
+
23
+ ```bash
24
+ $ rpush -l urls "http://www.heroku.com"
25
+ $ blpop -l urls
26
+ http://www.heroku.com
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/blpop ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ require 'redis_tools'
6
+
7
+ opts = {}
8
+ ARGV.options do |o|
9
+ o.banner = 'Usage: blpop -l <list> -u [redis url]'
10
+ o.on("-l", "--list LIST", "list to lpop from") { |l| opts[:list] = l }
11
+ o.on("-u", "--url REDIS_URL", "url for redis connection") { |u| opts[:url] = u }
12
+ o.parse!
13
+
14
+ opts[:url] ||= ENV['REDIS_URL'] || 'redis://localhost:6379'
15
+
16
+ abort("Missing -l\n\n#{o}") unless opts[:list]
17
+
18
+ redis = Redis.connect(url: opts[:url])
19
+
20
+ loop do
21
+ puts redis.blpop(opts[:list], 0).last
22
+ end
23
+ end
data/bin/rpush ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ require 'redis_tools'
6
+
7
+ opts = {}
8
+ ARGV.options do |o|
9
+ o.banner = 'Usage: rpush -l <list> -u [redis url] [input]'
10
+ o.on("-l", "--list LIST", "list to push input onto") { |l| opts[:list] = l }
11
+ o.on("-u", "--url REDIS_URL", "url for redis connection") { |u| opts[:url] = u }
12
+ o.parse!
13
+
14
+ opts[:url] ||= ENV['REDIS_URL'] || 'redis://localhost:6379'
15
+
16
+ abort("Missing -l\n\n#{o}") unless opts[:list]
17
+
18
+ redis = Redis.connect(url: opts[:url])
19
+ input = ARGV.shift
20
+
21
+ if input
22
+ redis.rpush(opts[:list], input)
23
+ else
24
+ ARGF.each_line do |input|
25
+ redis.rpush(opts[:list], input)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ require 'redis'
2
+
3
+ require 'redis_tools/version'
4
+
5
+ module RedisTools
6
+ extend self
7
+
8
+ def redis
9
+ @redis ||= Redis.new
10
+ end
11
+
12
+ def rpush(l, s)
13
+ redis.rpush(l, s)
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module RedisTools
2
+ VERSION = "0.0.1"
3
+ end
@@ -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 'redis_tools/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "redis_tools"
8
+ gem.version = RedisTools::VERSION
9
+ gem.authors = ["Michael Gorsuch"]
10
+ gem.email = ["michael.gorsuch@gmail.com"]
11
+ gem.description = %q{Command line tools derived from the Redis command set}
12
+ gem.summary = gem.description
13
+ gem.homepage = 'https://github.com/gorsuch/redis_tools'
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
+ gem.add_dependency('redis')
20
+ gem.add_development_dependency('rspec')
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedisTools do
4
+ context 'rpush' do
5
+ it 'should call rpush properly' do
6
+ Redis.any_instance.should_receive(:rpush).with('foo', 'bar')
7
+ RedisTools.rpush('foo', 'bar')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ require 'redis_tools'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+ config.order = 'random'
8
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Gorsuch
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redis
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Command line tools derived from the Redis command set
47
+ email:
48
+ - michael.gorsuch@gmail.com
49
+ executables:
50
+ - blpop
51
+ - rpush
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - Gemfile
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - bin/blpop
62
+ - bin/rpush
63
+ - lib/redis_tools.rb
64
+ - lib/redis_tools/version.rb
65
+ - redis_tools.gemspec
66
+ - spec/redis_tools_spec.rb
67
+ - spec/spec_helper.rb
68
+ homepage: https://github.com/gorsuch/redis_tools
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.23
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Command line tools derived from the Redis command set
92
+ test_files:
93
+ - spec/redis_tools_spec.rb
94
+ - spec/spec_helper.rb