lemondrop 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.
@@ -0,0 +1,3 @@
1
+ .*.sw*
2
+ .DS_Store
3
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in plugin-template.gemspec
4
+ gemspec
@@ -0,0 +1,9 @@
1
+ Lemondrop
2
+ =========
3
+
4
+ An Adhearsion plugin providing integration with Redis
5
+
6
+ Configuration
7
+ -------------
8
+
9
+ As with all Adhearsion plugins, type `rake config:show` to see the list of configuration options.
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+
4
+ require "rspec/core"
5
+ require "rspec/core/rake_task"
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ spec.rspec_opts = '--color'
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "lemondrop/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "lemondrop"
7
+ s.version = Lemondrop::VERSION
8
+ s.authors = ["Ben Klang"]
9
+ s.email = ["bklang@mojolingo.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Redis plugin for Adhearsion}
12
+ s.description = %q{This gem provides a plugin for Adhearsion, allowing you to create and use Redis as a queue or data source in your Adhearsion application.}
13
+
14
+ s.rubyforge_project = "lemondrop"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency %q<adhearsion>, ["~> 2.1"]
21
+ s.add_runtime_dependency %q<redis>, [">= 3.0.0"]
22
+
23
+ s.add_development_dependency %q<bundler>, ["~> 1.0"]
24
+ s.add_development_dependency %q<rspec>, ["~> 2.5"]
25
+ s.add_development_dependency %q<rake>, [">= 0"]
26
+ s.add_development_dependency %q<mocha>, [">= 0"]
27
+ s.add_development_dependency %q<guard-rspec>
28
+ end
@@ -0,0 +1,4 @@
1
+ module Lemondrop
2
+ end
3
+ require "lemondrop/version"
4
+ require "lemondrop/plugin"
@@ -0,0 +1,22 @@
1
+ require 'redis'
2
+
3
+ class Lemondrop::Plugin < Adhearsion::Plugin
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Service, 'lemondrop/plugin/service'
7
+
8
+ # Configure the connection information to your Redis instance.
9
+ config :lemondrop do
10
+ uri '' , :desc => 'URI to the Redis instance. Use this or specify each piece of connection information separately below.'
11
+ username '' , :desc => 'valid database username'
12
+ password '' , :desc => 'valid database password'
13
+ host 'localhost', :desc => 'host where the database is running'
14
+ port 6379 , :desc => 'port where the database is listening'
15
+ socket '' , :desc => 'path to Unix socket where Redis is listening (Optional; to use, set host and port to nil)'
16
+ end
17
+
18
+ init :lemondrop do
19
+ Service.start Adhearsion.config[:lemondrop]
20
+ end
21
+
22
+ end
@@ -0,0 +1,40 @@
1
+ require 'uri'
2
+
3
+ class Lemondrop::Plugin::Service
4
+ cattr_accessor :connection
5
+
6
+ class << self
7
+
8
+ ##
9
+ # Start the Sequel connection with the configured database
10
+ def start(config)
11
+ params = config.to_hash.select { |k,v| !v.nil? }
12
+ unless params[:uri].nil? || params[:uri].empty?
13
+ redis_uri = URI.parse params[:uri]
14
+ params[:user] = redis_uri.user
15
+ params[:password] = redis_uri.password
16
+ params[:host] = redis_uri.host
17
+ params[:port] = redis_uri.port || params[:port]
18
+ params.delete :uri
19
+ end
20
+
21
+ @@connection = establish_connection params
22
+ end
23
+
24
+ ##
25
+ # Stop the database connection
26
+ def stop
27
+ logger.warn "Todo: Close down Redis connections"
28
+ end
29
+
30
+ ##
31
+ # Start the Sequel connection with the configured database
32
+ #
33
+ # @param params [Hash] Options to establish the database connection
34
+ def establish_connection(params)
35
+ ::Redis.new params
36
+ end
37
+
38
+ end # class << self
39
+ end # Service
40
+
@@ -0,0 +1,3 @@
1
+ module Lemondrop
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lemondrop::Plugin::Service do
4
+ subject { Lemondrop::Plugin::Service }
5
+
6
+ describe '#start' do
7
+ it 'should allow specifying a URI for the connection information' do
8
+ config = {uri: 'redis://redisuser:redispass@foo.bar.com:9530/'}
9
+ expected_params = {
10
+ user: 'redisuser',
11
+ password: 'redispass',
12
+ host: 'foo.bar.com',
13
+ port: 9530
14
+ }
15
+ subject.should_receive(:establish_connection).once.with(expected_params)
16
+ subject.start config
17
+ end
18
+
19
+ it 'should default to the correct port if the URI does not specify one' do
20
+ config = {uri: 'redis://redisuser:redispass@foo.bar.com/', port: 6379}
21
+ expected_params = {
22
+ user: 'redisuser',
23
+ password: 'redispass',
24
+ host: 'foo.bar.com',
25
+ port: 6379
26
+ }
27
+ subject.should_receive(:establish_connection).once.with(expected_params)
28
+ subject.start config
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ require 'adhearsion'
2
+ require 'lemondrop'
3
+
4
+ RSpec.configure do |config|
5
+ config.color_enabled = true
6
+ config.tty = true
7
+
8
+ config.filter_run :focus => true
9
+ config.run_all_when_everything_filtered = true
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lemondrop
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Ben Klang
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-04-26 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: adhearsion
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 1
30
+ version: "2.1"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: redis
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 3
42
+ - 0
43
+ - 0
44
+ version: 3.0.0
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 0
57
+ version: "1.0"
58
+ type: :development
59
+ version_requirements: *id003
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ prerelease: false
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 2
69
+ - 5
70
+ version: "2.5"
71
+ type: :development
72
+ version_requirements: *id004
73
+ - !ruby/object:Gem::Dependency
74
+ name: rake
75
+ prerelease: false
76
+ requirement: &id005 !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ type: :development
84
+ version_requirements: *id005
85
+ - !ruby/object:Gem::Dependency
86
+ name: mocha
87
+ prerelease: false
88
+ requirement: &id006 !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id006
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ prerelease: false
100
+ requirement: &id007 !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ type: :development
108
+ version_requirements: *id007
109
+ description: This gem provides a plugin for Adhearsion, allowing you to create and use Redis as a queue or data source in your Adhearsion application.
110
+ email:
111
+ - bklang@mojolingo.com
112
+ executables: []
113
+
114
+ extensions: []
115
+
116
+ extra_rdoc_files: []
117
+
118
+ files:
119
+ - .gitignore
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lemondrop.gemspec
124
+ - lib/lemondrop.rb
125
+ - lib/lemondrop/plugin.rb
126
+ - lib/lemondrop/plugin/service.rb
127
+ - lib/lemondrop/version.rb
128
+ - spec/lemondrop/plugin/service_spec.rb
129
+ - spec/spec_helper.rb
130
+ has_rdoc: true
131
+ homepage: ""
132
+ licenses: []
133
+
134
+ post_install_message:
135
+ rdoc_options: []
136
+
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ requirements: []
154
+
155
+ rubyforge_project: lemondrop
156
+ rubygems_version: 1.3.6
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: Redis plugin for Adhearsion
160
+ test_files:
161
+ - spec/lemondrop/plugin/service_spec.rb
162
+ - spec/spec_helper.rb