qui 0.8.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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/lib/qui/queuemetrics.rb +18 -0
- data/lib/qui/queuemetrics_agent.rb +23 -0
- data/lib/qui/queuemetrics_queue.rb +32 -0
- data/lib/qui/queuemetrics_record.rb +27 -0
- data/lib/qui/queuemetrics_user.rb +19 -0
- data/lib/qui/version.rb +3 -0
- data/lib/qui.rb +11 -0
- data/qui.gemspec +25 -0
- data/spec/lib/config.yml +3 -0
- data/spec/lib/queuemetrics_agent_spec.rb +13 -0
- data/spec/lib/queuemetrics_queue_spec.rb +57 -0
- data/spec/lib/queuemetrics_spec.rb +29 -0
- data/spec/lib/queuemetrics_user_spec.rb +13 -0
- data/spec/spec_helper.rb +10 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a31a68713e3b77287d850b0cb22a3fae08a07a72
|
4
|
+
data.tar.gz: b83edfb11a6001aedaf612c50ec9e9621a442ec8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ffc90abfa22dc1eeb39d584ed412f80b4f75fd966acd44c041afb6e1d603a77f5e154acc5b684c9a613776e40ce8c95fd75dd7c3c2260284f044cc96b146474
|
7
|
+
data.tar.gz: 7d8fb3e1676df272704caaaa2665c96bef622e01aae395c804f3dff35df0f64b37550ccbba89aac9e6a5e5298e750f617045bbec0d9158c407bd3878c2b8602e
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format documentation
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kevin Collette
|
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,33 @@
|
|
1
|
+
# Qui
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'qui'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install qui
|
18
|
+
|
19
|
+
## Description
|
20
|
+
|
21
|
+
Qui, or Queuemetrics User Integration, is a gem that creates an ActiveRecord wrapper for manipulating users, agents, and queues within the Queuemetrics calling platform.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Queuemetrics
|
2
|
+
|
3
|
+
def self.establish_connection(host, username, password)
|
4
|
+
connection = {
|
5
|
+
:adapter => "mysql2",
|
6
|
+
:host => host,
|
7
|
+
:database => "queuemetrics",
|
8
|
+
:username => username,
|
9
|
+
:password => password,
|
10
|
+
}
|
11
|
+
ActiveRecord::Base.establish_connection connection
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.close_connection
|
15
|
+
ActiveRecord::Base.connection.close
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class QueuemetricsAgent < ActiveRecord::Base
|
2
|
+
self.table_name = 'agenti_noti'
|
3
|
+
|
4
|
+
def initialize(options={})
|
5
|
+
if options then
|
6
|
+
if options[:agent_name] then options[:nome_agente] = options.delete(:agent_name) end
|
7
|
+
if options[:agent_description] then options[:descr_agente] = options.delete(:agent_description) end
|
8
|
+
options[:location] = 3
|
9
|
+
options[:aliases] = ""
|
10
|
+
options[:group_by] = 1
|
11
|
+
options[:sys_dt_creazione] = Time.now.to_s(:db)
|
12
|
+
options[:current_terminal] = " "
|
13
|
+
options[:xmpp_address] = " "
|
14
|
+
options[:payroll_code] = " "
|
15
|
+
options[:chiave_agente] = " "
|
16
|
+
options[:sys_dt_modifica] = Time.now.to_s(:db)
|
17
|
+
super(options)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class QueuemetricsQueue < ActiveRecord::Base
|
2
|
+
self.table_name = 'code_possibili'
|
3
|
+
|
4
|
+
def initialize(options={}) super(options) end
|
5
|
+
|
6
|
+
def add_agent!(userid)
|
7
|
+
if exists_in_queue?(userid) then
|
8
|
+
false
|
9
|
+
else
|
10
|
+
self.agenti_membri += "|#{userid}"
|
11
|
+
self.save
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def remove_agent!(userid)
|
16
|
+
if exists_in_queue?(userid) then
|
17
|
+
members = self.agenti_membri.split("|")
|
18
|
+
members.delete userid
|
19
|
+
self.agenti_membri = members.join("|")
|
20
|
+
self.save
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def exists_in_queue?(userid)
|
29
|
+
if self.agenti_membri.include?(userid) then true else false end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module QueuemetricsRecord
|
2
|
+
include ActiveRecord::Base
|
3
|
+
|
4
|
+
def save
|
5
|
+
if self.exists? then
|
6
|
+
message = false
|
7
|
+
else
|
8
|
+
message = true
|
9
|
+
begin
|
10
|
+
self.class.create(self.db_attributes)
|
11
|
+
rescue Exception => e
|
12
|
+
message = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return message
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete
|
19
|
+
if self.exists? then
|
20
|
+
u = self.class.where(:nome_agente => "Agent/#{@userid}", :descr_agente => @username).first
|
21
|
+
u.destroy
|
22
|
+
else
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class QueuemetricsUser < ActiveRecord::Base
|
2
|
+
self.table_name = 'arch_users'
|
3
|
+
|
4
|
+
def initialize(options={})
|
5
|
+
if options then
|
6
|
+
options[:abilitato] = "1"
|
7
|
+
options[:masterkey] = "0"
|
8
|
+
options[:n_logon] = "0"
|
9
|
+
options[:chiavi_utente] = " "
|
10
|
+
options[:ultimo_logon] = Time.now.to_s(:db)
|
11
|
+
options[:sys_dt_creazione] = Time.now.to_s(:db)
|
12
|
+
options[:sys_dt_modifica] = Time.now.to_s(:db)
|
13
|
+
super(options)
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/qui/version.rb
ADDED
data/lib/qui.rb
ADDED
data/qui.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 'qui/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "qui"
|
8
|
+
spec.version = Qui::VERSION
|
9
|
+
spec.authors = ["Kevin Collette"]
|
10
|
+
spec.email = ["kevcollette@gmail.com"]
|
11
|
+
spec.description = %q{Qui, or Queuemetrics User Integration, is a gem that creates an ActiveRecord wrapper for manipulating users, agents, and queues within the Queuemetrics calling platform.}
|
12
|
+
spec.summary = %q{Qui creates and manages Queuemetrics users.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "mysql2"
|
24
|
+
spec.add_development_dependency "activerecord"
|
25
|
+
end
|
data/spec/lib/config.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'qui/queuemetrics'
|
3
|
+
require 'qui/queuemetrics_agent'
|
4
|
+
|
5
|
+
describe QueuemetricsAgent do
|
6
|
+
|
7
|
+
it "should wrap ActiveRecord" do
|
8
|
+
@q = YAML::load_file(File.join(__dir__, 'config.yml'))
|
9
|
+
Queuemetrics.establish_connection(@q["host"], @q["username"], @q["password"])
|
10
|
+
QueuemetricsAgent.superclass.should == ActiveRecord::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'qui/queuemetrics'
|
3
|
+
require 'qui/queuemetrics_queue'
|
4
|
+
|
5
|
+
describe QueuemetricsQueue do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@queue = QueuemetricsQueue.first
|
9
|
+
@userid = 'agent/128461849'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should wrap ActiveRecord" do
|
13
|
+
@q = YAML::load_file(File.join(__dir__, 'config.yml'))
|
14
|
+
Queuemetrics.establish_connection(@q["host"], @q["username"], @q["password"])
|
15
|
+
QueuemetricsQueue.superclass.should == ActiveRecord::Base
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".add_agent!" do
|
19
|
+
before do
|
20
|
+
@members = @queue.agenti_membri
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should add an agent to a queue object." do
|
24
|
+
@members.should_not include(@userid)
|
25
|
+
@queue.add_agent!(@userid)
|
26
|
+
@queue.agenti_membri.should include(@userid)
|
27
|
+
end
|
28
|
+
|
29
|
+
after do #return queue to prior state
|
30
|
+
@queue.agenti_membri = @members
|
31
|
+
@queue.save
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".remove_agent!" do
|
36
|
+
before do
|
37
|
+
@members = @queue.agenti_membri
|
38
|
+
@queue.agenti_membri = @members += "|#{@userid}"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should remove an agent from a queue object." do
|
42
|
+
@queue.agenti_membri.should include(@userid)
|
43
|
+
@queue.remove_agent!(@userid)
|
44
|
+
@queue.agenti_membri.should_not include(@userid)
|
45
|
+
end
|
46
|
+
|
47
|
+
after do
|
48
|
+
if @queue.agenti_membri.include?(@userid)
|
49
|
+
members = @queue.agenti_membri.split("|")
|
50
|
+
members.delete @userid
|
51
|
+
@queue.agenti_membri = members.join("|")
|
52
|
+
@queue.save
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
require 'qui/queuemetrics'
|
4
|
+
require 'qui/queuemetrics_agent'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
describe Queuemetrics do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@q = YAML::load_file(File.join(__dir__, 'config.yml'))
|
11
|
+
end
|
12
|
+
|
13
|
+
#connected? returns opposite bool
|
14
|
+
describe ".establish_connection" do
|
15
|
+
it "establishes a connection to a Queuemetrics database." do
|
16
|
+
Queuemetrics.establish_connection(@q["host"], @q["username"], @q["password"])
|
17
|
+
ActiveRecord::Base.connected?.should be_false
|
18
|
+
ActiveRecord::Base.connection.current_database.should eq("queuemetrics")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".close_connection" do
|
23
|
+
it "closes a connection to the Queuemetrics database." do
|
24
|
+
Queuemetrics.close_connection
|
25
|
+
ActiveRecord::Base.connected?.should be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'qui/queuemetrics'
|
3
|
+
require 'qui/queuemetrics_user'
|
4
|
+
|
5
|
+
describe QueuemetricsUser do
|
6
|
+
|
7
|
+
it "should wrap ActiveRecord" do
|
8
|
+
@q = YAML::load_file(File.join(__dir__, 'config.yml'))
|
9
|
+
Queuemetrics.establish_connection(@q["host"], @q["username"], @q["password"])
|
10
|
+
QueuemetricsAgent.superclass.should == ActiveRecord::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Collette
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-15 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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: mysql2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activerecord
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Qui, or Queuemetrics User Integration, is a gem that creates an ActiveRecord
|
70
|
+
wrapper for manipulating users, agents, and queues within the Queuemetrics calling
|
71
|
+
platform.
|
72
|
+
email:
|
73
|
+
- kevcollette@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .DS_Store
|
79
|
+
- .gitignore
|
80
|
+
- .rspec
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- lib/qui.rb
|
86
|
+
- lib/qui/queuemetrics.rb
|
87
|
+
- lib/qui/queuemetrics_agent.rb
|
88
|
+
- lib/qui/queuemetrics_queue.rb
|
89
|
+
- lib/qui/queuemetrics_record.rb
|
90
|
+
- lib/qui/queuemetrics_user.rb
|
91
|
+
- lib/qui/version.rb
|
92
|
+
- qui.gemspec
|
93
|
+
- spec/lib/config.yml
|
94
|
+
- spec/lib/queuemetrics_agent_spec.rb
|
95
|
+
- spec/lib/queuemetrics_queue_spec.rb
|
96
|
+
- spec/lib/queuemetrics_spec.rb
|
97
|
+
- spec/lib/queuemetrics_user_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
homepage: ''
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.0.2
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Qui creates and manages Queuemetrics users.
|
123
|
+
test_files:
|
124
|
+
- spec/lib/config.yml
|
125
|
+
- spec/lib/queuemetrics_agent_spec.rb
|
126
|
+
- spec/lib/queuemetrics_queue_spec.rb
|
127
|
+
- spec/lib/queuemetrics_spec.rb
|
128
|
+
- spec/lib/queuemetrics_user_spec.rb
|
129
|
+
- spec/spec_helper.rb
|