dakwak 1.0.3 → 1.6.5
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/lib/dakwak/admin/bot.rb +0 -0
- data/lib/dakwak/admin/console.rb +0 -0
- data/lib/dakwak/admin/message.rb +0 -0
- data/lib/dakwak/analytics/sheet.rb +77 -0
- data/lib/dakwak/configurable.rb +22 -0
- data/lib/dakwak/configurator.rb +61 -0
- data/lib/dakwak/log_manager.rb +52 -0
- data/lib/dakwak/logger.rb +127 -0
- data/lib/dakwak/messaging/channel.rb +215 -0
- data/lib/dakwak/messaging/communicator.rb +101 -0
- data/lib/dakwak/messaging/message.rb +68 -0
- data/lib/dakwak/messaging/private_channel.rb +143 -0
- data/lib/dakwak/messaging/station.rb +140 -0
- data/lib/dakwak/mongo_adapter.rb +141 -0
- data/lib/dakwak/utility.rb +8 -0
- data/lib/dakwak.rb +239 -8
- metadata +76 -41
- data/.gitignore +0 -18
- data/Gemfile +0 -4
- data/LICENSE +0 -22
- data/README.md +0 -28
- data/Rakefile +0 -2
- data/bin/dakwak +0 -5
- data/dakwak.gemspec +0 -22
- data/lib/dakwak/version.rb +0 -3
data/lib/dakwak.rb
CHANGED
@@ -1,15 +1,246 @@
|
|
1
|
-
require
|
1
|
+
require 'amqp'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
require 'dakwak/log_manager'
|
5
|
+
require 'dakwak/logger'
|
6
|
+
require 'dakwak/analytics/sheet'
|
7
|
+
require 'dakwak/messaging/station'
|
8
|
+
require 'dakwak/messaging/channel'
|
9
|
+
require 'dakwak/messaging/private_channel'
|
10
|
+
require 'dakwak/messaging/communicator'
|
11
|
+
require 'dakwak/messaging/message'
|
12
|
+
require 'dakwak/configurator'
|
13
|
+
require 'dakwak/configurable'
|
2
14
|
|
3
15
|
module Dakwak
|
4
|
-
|
5
|
-
|
6
|
-
|
16
|
+
attr_reader :logger, :log_manager, :station # :nodoc:
|
17
|
+
|
18
|
+
class << self
|
19
|
+
|
20
|
+
# :main: README.rdoc
|
21
|
+
# :title: dakwak Gem API Reference
|
22
|
+
|
23
|
+
# ----------------------------------------
|
24
|
+
# :section: !Public
|
25
|
+
# ----------------------------------------
|
26
|
+
|
27
|
+
# Initializes the logging system and other sub-systems.
|
28
|
+
# This must be called before attempting to use anything!
|
29
|
+
#
|
30
|
+
# Params:
|
31
|
+
# +info+::
|
32
|
+
# { name: String, version: [ MAJOR, MINOR, PATCH, BUILD ] }
|
33
|
+
#
|
34
|
+
# +foreground+::
|
35
|
+
# Whether dakwak should be run in the foreground or in a detached
|
36
|
+
# thread. If passing false, the init and teardown routines will
|
37
|
+
# force a sleep of 250 milliseconds.
|
38
|
+
#
|
39
|
+
# +install_trap+::
|
40
|
+
# When true, SIGINT will be trapped to call ::cleanup and
|
41
|
+
# stop the EventMachine, terminating gracefully. If you need
|
42
|
+
# to trap SIGINT and define custom behaviour, make sure to call
|
43
|
+
# ::cleanup in your signal handler.
|
44
|
+
#
|
45
|
+
# *Note*: this parameter is ignored when foreground = false
|
46
|
+
def init(info, foreground = true, install_trap = true, &callback)
|
47
|
+
|
48
|
+
@@sleep_ms = 100 / 1000.0
|
49
|
+
|
50
|
+
booter = lambda {
|
51
|
+
@@worker = nil
|
52
|
+
@@cleanup_handlers = []
|
53
|
+
@@app_name = info[:name]
|
54
|
+
@@app_fqn = format_name(info)
|
55
|
+
|
56
|
+
@@log_manager = LogManager.new
|
57
|
+
@@logger = Object.new
|
58
|
+
@@logger.extend(Logger)
|
59
|
+
@@logger.logging_context("")
|
60
|
+
|
61
|
+
@@station = Station.new
|
62
|
+
|
63
|
+
callback.call if callback
|
64
|
+
|
65
|
+
logger.log_info "dakwak: running in debug mode" if Dakwak.debugging?
|
66
|
+
logger.log_info "dakwak: dakwak initialized"
|
67
|
+
|
68
|
+
if install_trap
|
69
|
+
__die_gracefully
|
70
|
+
end
|
71
|
+
}
|
72
|
+
|
73
|
+
if foreground then
|
74
|
+
__start do booter.call end
|
75
|
+
else
|
76
|
+
@@worker = Thread.new {
|
77
|
+
__start do booter.call end
|
78
|
+
}
|
79
|
+
sleep(@@sleep_ms)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def __start
|
85
|
+
if defined?(PhusionPassenger)
|
86
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
87
|
+
@@my_own_reactor = true
|
88
|
+
# for passenger, we need to avoid orphaned threads
|
89
|
+
if forked && EM.reactor_running?
|
90
|
+
Dakwak.cleanup
|
91
|
+
end
|
92
|
+
Thread.new { EM.run do yield end }
|
93
|
+
# __die_gracefully
|
94
|
+
sleep(@@sleep_ms * 2)
|
95
|
+
end
|
96
|
+
else
|
97
|
+
if EventMachine.reactor_running?
|
98
|
+
puts "EM reactor seems to be running, will hook into it"
|
99
|
+
@@my_own_reactor = false
|
100
|
+
yield
|
101
|
+
else
|
102
|
+
@@my_own_reactor = true
|
103
|
+
puts "EM reactor doesn't seem to be running, will fire it up"
|
104
|
+
if defined?(Thin)
|
105
|
+
return yield
|
106
|
+
end
|
107
|
+
|
108
|
+
EventMachine.run do
|
109
|
+
yield
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end # no phusion passenger
|
114
|
+
end
|
115
|
+
|
116
|
+
def __die_gracefully
|
117
|
+
logger.log_notice "dakwak: installing traps for SIGINT and SIGTERM"
|
118
|
+
Signal.trap("INT") { Dakwak.cleanup }
|
119
|
+
Signal.trap("TERM") { Dakwak.cleanup }
|
120
|
+
end
|
121
|
+
|
122
|
+
def init?
|
123
|
+
!@@log_manager.nil?
|
124
|
+
end
|
125
|
+
|
126
|
+
def light_init(info)
|
127
|
+
@@app_name = info[:name]
|
128
|
+
@@app_fqn = format_name(info)
|
129
|
+
|
130
|
+
@@log_manager = LogManager.new
|
131
|
+
@@logger = Object.new
|
132
|
+
@@logger.extend(Logger)
|
133
|
+
@@logger.logging_context("")
|
134
|
+
|
135
|
+
@@cleanup_handlers = []
|
136
|
+
end
|
137
|
+
|
138
|
+
def light_init?
|
139
|
+
!EventMachine.reactor_running?
|
140
|
+
end
|
141
|
+
|
142
|
+
# Call this when you're done using dakwak.
|
143
|
+
def cleanup(&callback)
|
144
|
+
logger.log_info "dakwak: dakwak cleaning up..."
|
7
145
|
|
8
|
-
|
146
|
+
cleaner = Proc.new {
|
147
|
+
@@cleanup_handlers.each { |handler| handler.call }
|
9
148
|
|
10
|
-
|
149
|
+
callback.call if callback
|
11
150
|
|
12
|
-
|
13
|
-
|
151
|
+
logger.log_info "dakwak: dakwak cleaned up"
|
152
|
+
|
153
|
+
@@logger = nil
|
154
|
+
@@log_manager = nil
|
155
|
+
}
|
156
|
+
|
157
|
+
if light_init? then
|
158
|
+
cleaner.call
|
159
|
+
else
|
160
|
+
EventMachine.next_tick do
|
161
|
+
@@station.shutdown {
|
162
|
+
EventMachine.stop if @@my_own_reactor
|
163
|
+
|
164
|
+
cleaner.call
|
165
|
+
|
166
|
+
@@worker.join if @@worker
|
167
|
+
}
|
168
|
+
# sleep(@@sleep_ms)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def add_cleanup_handler(handler)
|
174
|
+
raise RuntimeError "cleanup handler must be a Proc or a lambda" unless handler.respond_to?(:call)
|
175
|
+
|
176
|
+
@@cleanup_handlers << handler
|
177
|
+
end
|
178
|
+
|
179
|
+
# An anonymous Logger that objects can use when they won't/can't
|
180
|
+
# include an instance of Dakwak::Logger themseles
|
181
|
+
def logger()
|
182
|
+
@@logger
|
183
|
+
end
|
184
|
+
|
185
|
+
# ----------------------------------------
|
186
|
+
# :section: Utility
|
187
|
+
# ----------------------------------------
|
188
|
+
|
189
|
+
# The fully-qualified application name that is unique across the network.
|
190
|
+
# Format:
|
191
|
+
# name-version@hostname
|
192
|
+
# # an example
|
193
|
+
# ruby_test-0.1.0-a1@localhost.com
|
194
|
+
def app_fqn()
|
195
|
+
@@app_fqn
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
# The registered application name
|
200
|
+
def app_name
|
201
|
+
@@app_name
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# The runtime environment, if the environment variable DAKWAK_DEBUG
|
206
|
+
# is defined, then the environment is set to :development, otherwise
|
207
|
+
# it is :production.
|
208
|
+
def environment
|
209
|
+
Dakwak.debugging? ? :development : :production
|
210
|
+
end
|
211
|
+
|
212
|
+
# :category: Utility
|
213
|
+
#
|
214
|
+
def debugging?
|
215
|
+
ENV["DAKWAK_DEBUG"] or app_fqn.include?("cornholio")
|
216
|
+
end
|
217
|
+
|
218
|
+
alias :development? :debugging?
|
219
|
+
|
220
|
+
|
221
|
+
def production?
|
222
|
+
!debugging?
|
223
|
+
end
|
224
|
+
|
225
|
+
# ----------------------------------------
|
226
|
+
# :section: Internal
|
227
|
+
# ----------------------------------------
|
228
|
+
|
229
|
+
# Used by Logger instances
|
230
|
+
def log_manager()
|
231
|
+
@@log_manager
|
232
|
+
end
|
233
|
+
|
234
|
+
# Use Dakwak::Station.instance instead
|
235
|
+
def station
|
236
|
+
@@station
|
237
|
+
end
|
238
|
+
|
239
|
+
private
|
240
|
+
|
241
|
+
def format_name(info)
|
242
|
+
"#{info[:name]}-#{info[:version][0]}.#{info[:version][1]}.#{info[:version][2]}-#{info[:version][3]}@#{Socket.gethostbyname(Socket.gethostname).first}"
|
243
|
+
end
|
14
244
|
end
|
245
|
+
|
15
246
|
end
|
metadata
CHANGED
@@ -1,81 +1,116 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dakwak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.6.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
7
|
+
- Ahmad Amireh
|
8
8
|
- dakwak
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: mongo
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.4'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.4'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bson
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 4.15.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 4.15.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: amqp
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
20
47
|
- !ruby/object:Gem::Version
|
21
48
|
version: '0'
|
22
|
-
type: :
|
49
|
+
type: :runtime
|
23
50
|
prerelease: false
|
24
51
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
52
|
requirements:
|
27
|
-
- -
|
53
|
+
- - ">="
|
28
54
|
- !ruby/object:Gem::Version
|
29
55
|
version: '0'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: json
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: A collection of interfaces and helpers for integrating an application
|
71
|
+
with the dakwak platform. This gem strives to be the counterpart to libdakwak, the
|
72
|
+
C++ library.
|
73
|
+
email: info@dakwak.com
|
74
|
+
executables: []
|
38
75
|
extensions: []
|
39
76
|
extra_rdoc_files: []
|
40
77
|
files:
|
41
|
-
- .gitignore
|
42
|
-
- Gemfile
|
43
|
-
- LICENSE
|
44
|
-
- README.md
|
45
|
-
- Rakefile
|
46
|
-
- bin/dakwak
|
47
|
-
- dakwak.gemspec
|
48
78
|
- lib/dakwak.rb
|
49
|
-
- lib/dakwak/
|
50
|
-
|
79
|
+
- lib/dakwak/admin/bot.rb
|
80
|
+
- lib/dakwak/admin/console.rb
|
81
|
+
- lib/dakwak/admin/message.rb
|
82
|
+
- lib/dakwak/analytics/sheet.rb
|
83
|
+
- lib/dakwak/configurable.rb
|
84
|
+
- lib/dakwak/configurator.rb
|
85
|
+
- lib/dakwak/log_manager.rb
|
86
|
+
- lib/dakwak/logger.rb
|
87
|
+
- lib/dakwak/messaging/channel.rb
|
88
|
+
- lib/dakwak/messaging/communicator.rb
|
89
|
+
- lib/dakwak/messaging/message.rb
|
90
|
+
- lib/dakwak/messaging/private_channel.rb
|
91
|
+
- lib/dakwak/messaging/station.rb
|
92
|
+
- lib/dakwak/mongo_adapter.rb
|
93
|
+
- lib/dakwak/utility.rb
|
94
|
+
homepage: http://github.com/dakwak/rb_dakwak
|
51
95
|
licenses: []
|
96
|
+
metadata: {}
|
52
97
|
post_install_message:
|
53
98
|
rdoc_options: []
|
54
99
|
require_paths:
|
55
100
|
- lib
|
56
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
102
|
requirements:
|
59
|
-
- -
|
103
|
+
- - ">="
|
60
104
|
- !ruby/object:Gem::Version
|
61
105
|
version: '0'
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
hash: 142627955
|
65
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
107
|
requirements:
|
68
|
-
- -
|
108
|
+
- - ">="
|
69
109
|
- !ruby/object:Gem::Version
|
70
110
|
version: '0'
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
hash: 142627955
|
74
111
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 1.8.25
|
112
|
+
rubygems_version: 3.1.2
|
77
113
|
signing_key:
|
78
|
-
specification_version:
|
79
|
-
summary: dakwak
|
80
|
-
translation in 54 different languages.
|
114
|
+
specification_version: 4
|
115
|
+
summary: The dakwak platform Ruby bindings.
|
81
116
|
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 nour
|
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
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# Dakwak
|
2
|
-
|
3
|
-
dakwak is a website localization service that offers both machine and professional translation in 54 different languages.
|
4
|
-
|
5
|
-
You can quickly and easily translate your websites to your languages of choice, and have your translated websites up and running in no time.
|
6
|
-
|
7
|
-
Start your 14 day trial at dakwak now: https://dakwak.com
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
gem 'dakwak'
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install dakwak
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
For more information about dakwak, type into terminal:
|
26
|
-
|
27
|
-
$ dakwak
|
28
|
-
|
data/Rakefile
DELETED
data/bin/dakwak
DELETED
data/dakwak.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/dakwak/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["dakwak"]
|
6
|
-
gem.email = ["nour.h@dakwak.com"]
|
7
|
-
gem.description = %q{dakwak is a website localization service that offers both machine and professional translation
|
8
|
-
in 54 different languages.You can quickly and easily translate your websites to your languages of choice,
|
9
|
-
and have your translated websites up and running in no time.}
|
10
|
-
gem.summary = %q{dakwak is a website localization service that offers both machine and professional translation
|
11
|
-
in 54 different languages.}
|
12
|
-
gem.homepage = "https://dakwak.com"
|
13
|
-
|
14
|
-
gem.files = `git ls-files`.split($\)
|
15
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
-
gem.name = "dakwak"
|
18
|
-
gem.require_paths = ["lib"]
|
19
|
-
gem.version = Dakwak::VERSION
|
20
|
-
|
21
|
-
gem.add_development_dependency 'rake'
|
22
|
-
end
|
data/lib/dakwak/version.rb
DELETED