qm 1.1.13 → 1.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -10
- data/lib/defs-mongo.rb +9 -5
- data/lib/qm.rb +3 -14
- data/lib/service.rb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08ab22eda9dec9701dbc4c3cb219dd9e2dfc58a0
|
4
|
+
data.tar.gz: 846e5cb34d8302e4b06cc5ab6641861332fe60fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 026fdf8527b0ffbcad0f0b75c9f2091ba7771e93d8b90a769c1d65c4f73778202b0744cbeac67025428f12c8c3fb873ef906a0bdba63a44354aa6c8c0c4b7a9b
|
7
|
+
data.tar.gz: b012f21b8b4f514ff7963fc4a22c128cdfede019384edec03e51ce04c6eb0ed3636c7b8fc0a600e3e6e2db7586d587b17cdbea3f0eaef91fccec508a5174c6e6
|
data/README.md
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
# qm
|
2
2
|
|
3
|
-
The `qm` gem for [Ruby](http://www.ruby-lang.org/)
|
4
|
-
|
5
|
-
|
3
|
+
The `qm` gem for [Ruby](http://www.ruby-lang.org/) includes a
|
4
|
+
[QMachine](https://www.qmachine.org) API server and a web server. It uses
|
5
|
+
[MongoDB](http://www.mongodb.org/) for persistent storage, and it can
|
6
6
|
optionally log traffic data into a different MongoDB collection instead of
|
7
|
-
logging to stdout.
|
8
|
-
[SQLite](https://www.sqlite.org/) as persistent storage, however.
|
7
|
+
logging to stdout. A client is planned.
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
The repository contains vestigial definitions for using
|
10
|
+
[SQLite](https://www.sqlite.org/), but these may "evolve away" in the future,
|
11
|
+
primarily due to the
|
12
|
+
[obstacle it poses](https://devcenter.heroku.com/articles/sqlite3)
|
13
|
+
to deploying on [Heroku](https://www.heroku.com). If you are absolutely in love
|
14
|
+
with SQLite (or just hate MongoDB), consider trying the
|
15
|
+
[Node.js version](https://github.com/qmachine/qm-nodejs) instead.
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
$ gem install qm
|
17
|
+
For more information, please see the
|
18
|
+
[manual](https://docs.qmachine.org/en/latest/ruby.html).
|
16
19
|
|
17
20
|
===
|
18
21
|
|
data/lib/defs-mongo.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#- defs-mongo.rb ~~
|
4
4
|
# ~~ (c) SRW, 16 Jul 2014
|
5
|
-
# ~~ last updated
|
5
|
+
# ~~ last updated 02 Aug 2014
|
6
6
|
|
7
7
|
require 'json'
|
8
8
|
require 'mongo'
|
@@ -27,7 +27,7 @@ module Sinatra
|
|
27
27
|
sparse: true
|
28
28
|
})
|
29
29
|
settings.api_db['avars'].ensure_index('exp_date', {
|
30
|
-
expireAfterSeconds:
|
30
|
+
expireAfterSeconds: 0
|
31
31
|
})
|
32
32
|
return
|
33
33
|
end
|
@@ -50,8 +50,12 @@ module Sinatra
|
|
50
50
|
|
51
51
|
def get_avar(params)
|
52
52
|
# This helper function needs documentation.
|
53
|
-
|
54
|
-
x = db['avars'].
|
53
|
+
db = settings.api_db
|
54
|
+
x = db['avars'].find_and_modify({
|
55
|
+
query: {_id: "#{params[0]}&#{params[1]}"},
|
56
|
+
update: {'$set' => {exp_date: Time.now + settings.avar_ttl}},
|
57
|
+
fields: {body: 1}
|
58
|
+
})
|
55
59
|
y = (x.nil?) ? '{}' : x['body']
|
56
60
|
return y
|
57
61
|
end
|
@@ -73,7 +77,7 @@ module Sinatra
|
|
73
77
|
doc = {
|
74
78
|
_id: "#{params[0]}&#{params[1]}",
|
75
79
|
body: params[2],
|
76
|
-
exp_date: Time.now,
|
80
|
+
exp_date: Time.now + settings.avar_ttl,
|
77
81
|
key: params[1]
|
78
82
|
}
|
79
83
|
options = {upsert: true}#, w: 1}
|
data/lib/qm.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#- qm.rb ~~
|
4
4
|
# ~~ (c) SRW, 12 Apr 2013
|
5
|
-
# ~~ last updated
|
5
|
+
# ~~ last updated 04 Aug 2014
|
6
6
|
|
7
7
|
module QM
|
8
8
|
|
@@ -15,12 +15,10 @@ module QM
|
|
15
15
|
def self::launch_service(options = {})
|
16
16
|
# This function creates, configures, and launches a fresh Sinatra app
|
17
17
|
# that inherits from the original "teaching version".
|
18
|
-
require 'service'
|
19
18
|
require 'defs-mongo'
|
20
|
-
|
19
|
+
require 'service'
|
21
20
|
app = Sinatra.new(QMachineService) do
|
22
21
|
register Sinatra::MongoConnect
|
23
|
-
#register Sinatra::SQLiteConnect
|
24
22
|
configure do
|
25
23
|
convert = lambda do |x|
|
26
24
|
# This converts all keys in a hash to symbols recursively.
|
@@ -34,24 +32,15 @@ module QM
|
|
34
32
|
end
|
35
33
|
options = convert.call(options)
|
36
34
|
set options
|
37
|
-
|
38
|
-
# I'm not sure if the next three lines are necessary or not ...
|
39
|
-
set bind: settings.hostname,
|
40
|
-
run: false,
|
41
|
-
static: settings.enable_web_server
|
42
|
-
|
43
35
|
if (settings.persistent_storage.has_key?(:mongo)) then
|
44
36
|
helpers Sinatra::MongoAPIDefs
|
45
37
|
mongo_api_connect
|
46
|
-
#elsif (settings.persistent_storage.has_key?(:sqlite)) then
|
47
|
-
# helpers Sinatra::SQLiteDefs
|
48
|
-
# sqlite_connect
|
49
38
|
end
|
50
39
|
if (settings.trafficlog_storage.has_key?(:mongo)) then
|
51
40
|
helpers Sinatra::MongoLogDefs
|
52
41
|
mongo_log_connect
|
53
42
|
after do
|
54
|
-
log_to_db
|
43
|
+
log_to_db unless response.status == 444
|
55
44
|
end
|
56
45
|
end
|
57
46
|
end
|
data/lib/service.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
# of a 'box', 'key', or 'status' value.
|
17
17
|
#
|
18
18
|
# ~~ (c) SRW, 24 Apr 2013
|
19
|
-
# ~~ last updated
|
19
|
+
# ~~ last updated 03 Aug 2014
|
20
20
|
|
21
21
|
require 'sinatra'
|
22
22
|
require 'sinatra/cross_origin'
|
@@ -34,7 +34,6 @@ class QMachineService < Sinatra::Base
|
|
34
34
|
enable_CORS: false,
|
35
35
|
enable_web_server: false,
|
36
36
|
hostname: '0.0.0.0',
|
37
|
-
logging: true,
|
38
37
|
persistent_storage: {},
|
39
38
|
port: 8177,
|
40
39
|
public_folder: 'public',
|
@@ -44,9 +43,10 @@ class QMachineService < Sinatra::Base
|
|
44
43
|
|
45
44
|
mime_type webapp: 'application/x-web-app-manifest+json'
|
46
45
|
|
47
|
-
set bind: settings.hostname
|
48
|
-
|
49
|
-
|
46
|
+
set bind: lambda { settings.hostname },
|
47
|
+
logging: true,
|
48
|
+
run: false,
|
49
|
+
static: lambda { settings.enable_web_server }
|
50
50
|
|
51
51
|
# See also: http://www.sinatrarb.com/configuration.html
|
52
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Wilkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson_ext
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.4.1
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: A platform for World Wide Computing
|