cmis_rabbit_queue 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/cmis_rabbit_queue.gemspec +21 -0
- data/lib/cmis_rabbit_queue/document.rb +10 -0
- data/lib/cmis_rabbit_queue/folder.rb +9 -0
- data/lib/cmis_rabbit_queue/internal/connection.rb +37 -0
- data/lib/cmis_rabbit_queue/object.rb +13 -0
- data/lib/cmis_rabbit_queue/repository.rb +56 -0
- data/lib/cmis_rabbit_queue/server.rb +46 -0
- data/lib/cmis_rabbit_queue.rb +8 -0
- metadata +87 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cmis_rabbit_queue/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cmis_rabbit_queue"
|
8
|
+
spec.version = CmisRabbitQueue::VERSION
|
9
|
+
spec.authors = ["Nitesh"]
|
10
|
+
spec.email = ["neethiwin@gmail.com"]
|
11
|
+
spec.summary = ""
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = ["cmis_rabbit_queue.gemspec","lib/cmis_rabbit_queue.rb","lib/cmis_rabbit_queue/document.rb","lib/cmis_rabbit_queue/folder.rb","lib/cmis_rabbit_queue/object.rb","lib/cmis_rabbit_queue/repository.rb","lib/cmis_rabbit_queue/server.rb","lib/cmis_rabbit_queue/internal/connection.rb"]
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module CmisRabbitQueue
|
2
|
+
class Document < Object
|
3
|
+
attr_accessor :path, :created_date, :modified_by, :name, :type
|
4
|
+
attr_accessor :modified_date, :created_by, :url, :label
|
5
|
+
attr_accessor :mime_type, :data
|
6
|
+
def initialize
|
7
|
+
@type = 'document'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
require "bunny"
|
3
|
+
|
4
|
+
module CmisRabbitQueue
|
5
|
+
class Connection
|
6
|
+
|
7
|
+
# The connection object used connect Rabbit Queue
|
8
|
+
attr_reader :connection
|
9
|
+
# The channel used to retrive queue instance
|
10
|
+
attr_reader :channel
|
11
|
+
# The logical buffer
|
12
|
+
attr_reader :queue
|
13
|
+
# constructor
|
14
|
+
def initialize(url, port)
|
15
|
+
if @connection == nil
|
16
|
+
@connection = Bunny.new(:hostname => url, :port => port)
|
17
|
+
@connection.start
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# call this method to create a upload channel to process documents
|
22
|
+
def init_channel(name)
|
23
|
+
if @channel == nil
|
24
|
+
@channel = @connection.create_channel
|
25
|
+
@queue = @channel.queue(name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# This method should be automatically called during garbage collection
|
32
|
+
def self.finalize
|
33
|
+
@connection.close
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CmisRabbitQueue
|
2
|
+
class Object
|
3
|
+
class << self
|
4
|
+
attr_accessor :path, :created_date, :modified_by, :name, :type
|
5
|
+
attr_accessor :modified_date, :created_by, :url, :label
|
6
|
+
end
|
7
|
+
|
8
|
+
def store
|
9
|
+
self.class.instances ||= []
|
10
|
+
self.class.instances << self
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module CmisRabbitQueue
|
2
|
+
class Repository
|
3
|
+
# repository name
|
4
|
+
attr_reader :name
|
5
|
+
# queue
|
6
|
+
attr_reader :queue
|
7
|
+
#channel
|
8
|
+
attr_reader :channel
|
9
|
+
#connection
|
10
|
+
attr_reader :connection
|
11
|
+
|
12
|
+
def initialize(name, queue, channel, connection)
|
13
|
+
@name = name
|
14
|
+
@queue = queue
|
15
|
+
@channel = channel
|
16
|
+
@connection = connection
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_folder(folder)
|
20
|
+
@channel.default_exchange.publish(
|
21
|
+
folder.name, :routing_key => @queue.name,
|
22
|
+
:headers => {
|
23
|
+
:path => folder.path,
|
24
|
+
:document_type => folder.type,
|
25
|
+
:created_date => folder.created_date,
|
26
|
+
:modified_date => folder.modified_date,
|
27
|
+
:created_by => folder.created_by,
|
28
|
+
:modified_by => folder.modified_by
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def upload_document(document)
|
34
|
+
@channel.default_exchange.publish(
|
35
|
+
document.data, :routing_key => @queue.name,
|
36
|
+
:headers => {
|
37
|
+
:path => document.path,
|
38
|
+
:document_name => document.name,
|
39
|
+
:document_type => document.type,
|
40
|
+
:created_date => document.created_date,
|
41
|
+
:modified_date => document.modified_date,
|
42
|
+
:created_by => document.created_by,
|
43
|
+
:modified_by => document.modified_by,
|
44
|
+
:content_type => document.mime_type
|
45
|
+
}
|
46
|
+
)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_folders(folder)
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
module CmisRabbitQueue
|
3
|
+
class Server
|
4
|
+
|
5
|
+
# The connection
|
6
|
+
attr_reader :connection
|
7
|
+
#Repository
|
8
|
+
attr_reader :repository
|
9
|
+
attr_reader :repository_name
|
10
|
+
# constructor
|
11
|
+
def initialize(url, port, queue, repository)
|
12
|
+
@repository_name = repository
|
13
|
+
@connection = Connection.new(url, port)
|
14
|
+
init_message_queue(queue)
|
15
|
+
init_repository(repository)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# create folder object with path and other required data
|
20
|
+
def create_folder(folder)
|
21
|
+
@repository.create_folder(folder)
|
22
|
+
end
|
23
|
+
|
24
|
+
# create documentobject with path and other required data
|
25
|
+
def create_document(document)
|
26
|
+
@repository.upload_document(document)
|
27
|
+
end
|
28
|
+
#Initalize the channel and create queue
|
29
|
+
private
|
30
|
+
def init_message_queue(queue)
|
31
|
+
@connection.init_channel(queue)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
#Initalize repository
|
36
|
+
def init_repository(repository)
|
37
|
+
@repository = Repository.new(repository, @connection.queue, @connection.channel, @connection.connection)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require "bunny"
|
2
|
+
require 'require_relative'
|
3
|
+
require_relative 'cmis_rabbit_queue/internal/connection'
|
4
|
+
require_relative 'cmis_rabbit_queue/document'
|
5
|
+
require_relative 'cmis_rabbit_queue/folder'
|
6
|
+
require_relative 'cmis_rabbit_queue/repository'
|
7
|
+
require_relative 'cmis_rabbit_queue/server'
|
8
|
+
require_relative 'cmis_rabbit_queue/object'
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cmis_rabbit_queue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nitesh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.7'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '10.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: '10.0'
|
46
|
+
description: ''
|
47
|
+
email:
|
48
|
+
- neethiwin@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- cmis_rabbit_queue.gemspec
|
54
|
+
- lib/cmis_rabbit_queue.rb
|
55
|
+
- lib/cmis_rabbit_queue/document.rb
|
56
|
+
- lib/cmis_rabbit_queue/folder.rb
|
57
|
+
- lib/cmis_rabbit_queue/object.rb
|
58
|
+
- lib/cmis_rabbit_queue/repository.rb
|
59
|
+
- lib/cmis_rabbit_queue/server.rb
|
60
|
+
- lib/cmis_rabbit_queue/internal/connection.rb
|
61
|
+
homepage: ''
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: ''
|
86
|
+
test_files: []
|
87
|
+
has_rdoc:
|