blsk_ruby_core_api 0.1.0 → 0.1.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 +4 -4
- data/lib/app_service.rb +2 -2
- data/lib/cassandra/abstracted_cassandra_repository.rb +6 -6
- data/lib/cassandra/cassandra_service.rb +4 -4
- data/lib/consul/consul_service.rb +3 -3
- data/lib/decoractors/authenticate.rb +2 -2
- data/lib/decoractors/valid.rb +1 -1
- data/lib/rest/rest_service.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77c293e83b94b669afaface9f0dfc796c0f06140598373f62ea8f1aa65b0c223
|
4
|
+
data.tar.gz: ea07f92cbe43425039d57e0b8bf69b7b7be909ceae978a269298a99a6dbb3fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686e5967bca53980bb1cfde3efcae0e2129d4c936df8a29842c269a9131b4da55e75d50c12d7ed8852db3f7572cf3ddf0c1b01afc30464aee7aab77a7ca9c5a6
|
7
|
+
data.tar.gz: 33c3c8904fbed09f245d5d34551c81fce6208d248150621383d46647b97e908dcd18d9484286253a2cd77ee5285c06792282314996ae02823dbc5aed7c1603b3
|
data/lib/app_service.rb
CHANGED
@@ -7,13 +7,13 @@ class AppService
|
|
7
7
|
injector
|
8
8
|
|
9
9
|
def start
|
10
|
-
puts 'start app_service'
|
10
|
+
# puts 'start app_service'
|
11
11
|
consul_service.start
|
12
12
|
cassandra_service.start
|
13
13
|
end
|
14
14
|
|
15
15
|
def stop
|
16
|
-
puts 'stop app_service'
|
16
|
+
# puts 'stop app_service'
|
17
17
|
consul_service.stop
|
18
18
|
cassandra_service.stop
|
19
19
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module AbstractedCassandraRepository
|
2
2
|
def find_by_id(id=nil, keyspace_name=nil, table_name=nil)
|
3
|
-
puts 'find_by_id'
|
3
|
+
# puts 'find_by_id'
|
4
4
|
if keyspace_name && table_name
|
5
5
|
session = cassandra_cluster.connect(keyspace_name)
|
6
6
|
result = session.execute("SELECT * FROM #{table_name} WHERE id = ?", arguments: [id])
|
@@ -8,7 +8,7 @@ module AbstractedCassandraRepository
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def find_all(keyspace_name=nil, table_name=nil)
|
11
|
-
puts 'find_all'
|
11
|
+
# puts 'find_all'
|
12
12
|
if keyspace_name && table_name
|
13
13
|
session = cassandra_cluster.connect(keyspace_name)
|
14
14
|
result = session.execute("SELECT * FROM #{table_name}")
|
@@ -16,7 +16,7 @@ module AbstractedCassandraRepository
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def create(value_hashes={}, keyspace_name=nil, table_name=nil)
|
19
|
-
puts 'create'
|
19
|
+
# puts 'create'
|
20
20
|
if keyspace_name && table_name
|
21
21
|
session = cassandra_cluster.connect(keyspace_name)
|
22
22
|
cql = '' # Building the cql using 'INSERT INTO' with 'IF NOT EXISTS'
|
@@ -25,7 +25,7 @@ module AbstractedCassandraRepository
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def update(id=nil, value_hashes={}, keyspace_name=nil, table_name=nil)
|
28
|
-
puts 'update'
|
28
|
+
# puts 'update'
|
29
29
|
if keyspace_name && table_name
|
30
30
|
session = cassandra_cluster.connect(keyspace_name)
|
31
31
|
cql = '' # Building the cql using UPDATE
|
@@ -34,7 +34,7 @@ module AbstractedCassandraRepository
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def save(value_hashes={}, keyspace_name=nil, table_name=nil)
|
37
|
-
puts 'save'
|
37
|
+
# puts 'save'
|
38
38
|
if keyspace_name && table_name
|
39
39
|
session = cassandra_cluster.connect(keyspace_name)
|
40
40
|
cql = '' # Building the cql using 'INSERT INTO' without 'IF NOT EXISTS'
|
@@ -43,7 +43,7 @@ module AbstractedCassandraRepository
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def delete(id=nil, keyspace_name=nil, table_name=nil)
|
46
|
-
puts 'delete'
|
46
|
+
# puts 'delete'
|
47
47
|
if keyspace_name && table_name
|
48
48
|
session = cassandra_cluster.connect(keyspace_name)
|
49
49
|
result = session.execute("DELETE FROM #{table_name} WHERE id = ?", arguments: [id])
|
@@ -10,12 +10,12 @@ class CassandraService
|
|
10
10
|
attr_accessor :cassandra_cluster
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
puts 'init cassandra'
|
13
|
+
# puts 'init cassandra'
|
14
14
|
self.cassandra_cluster = Cassandra.cluster
|
15
15
|
end
|
16
16
|
|
17
17
|
def start
|
18
|
-
puts 'start cassandra, create cluster'
|
18
|
+
# puts 'start cassandra, create cluster'
|
19
19
|
if !cassandra_cluster
|
20
20
|
cassandra_cluster = Cassandra.cluster
|
21
21
|
end
|
@@ -23,9 +23,9 @@ class CassandraService
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def stop
|
26
|
-
puts 'stop cassandra'
|
26
|
+
# puts 'stop cassandra'
|
27
27
|
if cassandra_cluster
|
28
|
-
puts 'closing'
|
28
|
+
# puts 'closing'
|
29
29
|
cassandra_cluster.close
|
30
30
|
end
|
31
31
|
end
|
@@ -11,12 +11,12 @@ class ConsulService
|
|
11
11
|
attr_accessor :consul_service_data
|
12
12
|
|
13
13
|
def initialize(option=nil)
|
14
|
-
puts 'init consul'
|
14
|
+
# puts 'init consul'
|
15
15
|
self.consul_service_data = ConsulService.configure
|
16
16
|
end
|
17
17
|
|
18
18
|
def start
|
19
|
-
puts 'start consul'
|
19
|
+
# puts 'start consul'
|
20
20
|
consul_service_data = ConsulConfiguration::CONFIG[:consul_service_data] if consul_service_data.nil?
|
21
21
|
Diplomat::Service.register(consul_service_data)
|
22
22
|
|
@@ -26,7 +26,7 @@ class ConsulService
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def stop
|
29
|
-
puts 'stop consul'
|
29
|
+
# puts 'stop consul'
|
30
30
|
consul_service_id = self.consul_service_data.try(:id) || ConsulConfiguration::CONFIG[:consul_service_data][:id]
|
31
31
|
Diplomat::Service.deregister(consul_service_id)
|
32
32
|
end
|
@@ -4,7 +4,7 @@ require_relative '../security/security_context_holder'
|
|
4
4
|
module Authenticator
|
5
5
|
def has_roles roles
|
6
6
|
lambda {|*args, &blk|
|
7
|
-
puts 'has_roles'
|
7
|
+
# puts 'has_roles'
|
8
8
|
check_role = true # check role here and return true/false
|
9
9
|
if check_role
|
10
10
|
true
|
@@ -16,7 +16,7 @@ module Authenticator
|
|
16
16
|
|
17
17
|
def authenticate isAuthorized
|
18
18
|
lambda {|self_model, *args, &blk|
|
19
|
-
puts "isAuthorized"
|
19
|
+
# puts "isAuthorized"
|
20
20
|
# check authentication and authorization here, then return true/false
|
21
21
|
if isAuthorized.call(*args, &blk)
|
22
22
|
true
|
data/lib/decoractors/valid.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative '../rest/rest_service'
|
|
3
3
|
module Validator
|
4
4
|
def validate params={}
|
5
5
|
lambda {|self_model, *args, &blk|
|
6
|
-
puts "Validate"
|
6
|
+
# puts "Validate"
|
7
7
|
check_validate = self_model.check_validate(*args, &blk) # check validation and return [true]/[false, errors]
|
8
8
|
if check_validate[0]
|
9
9
|
true
|
data/lib/rest/rest_service.rb
CHANGED
@@ -30,8 +30,8 @@ class RestService < RestApplication
|
|
30
30
|
extend ::RestResponseModel
|
31
31
|
|
32
32
|
before '/*' do
|
33
|
-
puts 'before any route ...'
|
34
|
-
RequestStore.store[:user] = "Nhuan Lai"
|
33
|
+
# puts 'before any route ...'
|
34
|
+
RequestStore.store[:user] = "Nhuan Lai" #get the user by access_token
|
35
35
|
end
|
36
36
|
|
37
37
|
# Health Check for Consul, run when start Consul
|