jungle_path 0.0.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7c640c8f8482983063d216433074adca552b14c
4
- data.tar.gz: 26812a3c5aa1cfacf98b9fd787fd56b6620a3df1
3
+ metadata.gz: 61179dfea18fd9bfef83ac47f07a8ec178752c66
4
+ data.tar.gz: cf9b2c08672ea2d236956bcc6d34f0147f7039aa
5
5
  SHA512:
6
- metadata.gz: 2250667bf6a1780bd176fff62161379246a7eb358ae8fe0f497db34d2540087756ee291221f32f73628fc085b516aad4c2eeb492c379da123d51b5567a3009f2
7
- data.tar.gz: 597fbde8599a34552c5e7db85cf9a0efdf03b6a9463ccf51c1f6840d5c6f5cc6c94971952aa66dc5147121112491e9e77a7103fcc9fc2672cc49c42839e686f1
6
+ metadata.gz: 916535ebfdd122a1107fa132fa8663490167b7422af9b45652bd2d38fa944730f787896488e28f193c6725b3d775f7445cae8625aa3c28d756f0e6f4104bdd3b
7
+ data.tar.gz: 2b4c38646c95ae2e2881f1e01bf208c23399633b2d1ced1dd8c7636b14e4e60834cbe3207b6619b690386a3ea039fafef0fbc4e8c89b56a40d380db17238118c
data/jungle_path.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'jungle_path'
7
- spec.version = '0.0.0'
7
+ spec.version = '0.0.1'
8
8
  spec.authors = ['Michael VanZant']
9
9
  spec.email = ['mxvanzant@yahoo.com']
10
10
  spec.summary = 'Full-stack web application framework for creating API services.'
@@ -14,7 +14,7 @@ module Schema
14
14
  end
15
15
 
16
16
  class UserQueryFilter < Schema::Base
17
- self.description = "Links users (actually their keys) to query_filters -- will be used to restrict certain users to only be able to query entities (such as products, etc.) as restricted by the related query_filter."
17
+ self.description = "Links users to query_filters -- will be used to restrict certain users to only be able to query entities (such as products, etc.) as restricted by the related query_filter."
18
18
  define(
19
19
  [:user_id, :foreign_key, :user, :primary_key],
20
20
  [:query_filter_id, :foreign_key, :query_filter, :primary_key],
@@ -1,6 +1,13 @@
1
1
  module JunglePath
2
- module Sql
2
+ module SQL
3
3
  module Helpers
4
+ def self.get_count(db, sql, arg)
5
+ ds = db.base[sql, arg]
6
+ result = ds.first
7
+ puts "result: #{result}."
8
+ count = result[:count].to_i
9
+ end
10
+
4
11
  def self.sql(input)
5
12
  a = input.split("\n")
6
13
  a = a.map {|s| s.strip}
@@ -1,8 +1,10 @@
1
+ require 'jungle_path/sql/helpers'
2
+
1
3
  module JunglePath
2
- module Sql
4
+ module SQL
3
5
  module Key
4
6
  def self.by_key(db, key)
5
- sql = SQLHelpers.sql("
7
+ sql = JunglePath::SQL::Helpers.sql("
6
8
  #{base_sql}
7
9
  where a.key = ?
8
10
  order by a.id
@@ -16,7 +18,7 @@ module JunglePath
16
18
  end
17
19
 
18
20
  def self.by_user_id(db, user_id)
19
- sql = SQLHelpers.sql("
21
+ sql = JunglePath::SQL::Helpers.sql("
20
22
  #{base_sql}
21
23
  where a.user_id = ?
22
24
  order by a.id
@@ -26,7 +28,7 @@ module JunglePath
26
28
  end
27
29
 
28
30
  def self.by_user_id_key_name(db, user_id, key_name)
29
- sql = SQLHelpers.sql("
31
+ sql = JunglePath::SQL::Helpers.sql("
30
32
  select
31
33
  a.id,
32
34
  a.key,
@@ -49,7 +51,7 @@ module JunglePath
49
51
  end
50
52
 
51
53
  def self.default_by_user_id(db, user_id)
52
- sql = SQLHelpers.sql("
54
+ sql = JunglePath::SQL::Helpers.sql("
53
55
  #{base_sql}
54
56
  where a.user_id = ?
55
57
  and a.is_default = true
@@ -60,7 +62,7 @@ module JunglePath
60
62
  end
61
63
 
62
64
  def self.by_user_id(db, user_id)
63
- sql = SQLHelpers.sql("
65
+ sql = JunglePath::SQL::Helpers.sql("
64
66
  #{base_sql}
65
67
  where a.user_id = ?
66
68
  order by a.id
@@ -70,7 +72,7 @@ module JunglePath
70
72
  end
71
73
 
72
74
  def self.default_by_user_id(db, user_id)
73
- sql = SQLHelpers.sql("
75
+ sql = JunglePath::SQL::Helpers.sql("
74
76
  #{base_sql}
75
77
  where a.user_id = ?
76
78
  and a.is_default = true
@@ -84,7 +86,7 @@ module JunglePath
84
86
  private
85
87
 
86
88
  def self.base_sql
87
- SQLHelpers.sql("
89
+ JunglePath::SQL::Helpers.sql("
88
90
  select
89
91
  a.id,
90
92
  a.key,
@@ -1,5 +1,28 @@
1
+ require 'jungle_path/sql/helpers'
2
+
1
3
  module JunglePath
2
- module Sql
3
-
4
+ module SQL
5
+ module QueryFilter
6
+ def self.by_user db, key
7
+ sql = JunglePath::SQL::Helpers.sql("
8
+ select
9
+ a.id,
10
+ a.name,
11
+ a.base_table_name,
12
+ a.sub_select
13
+ from query_filter a
14
+ join user_query_filter b on a.id = b.query_filter_id
15
+ where b.user_id = ?
16
+ ")
17
+
18
+ ds = db.base[sql, key.id]
19
+ result = ds.all
20
+ array = []
21
+ result.each do |row|
22
+ array << ({id: row[:id], name: row[:name], base_table_name: row[:base_table_name], sub_select: row[:sub_select]})
23
+ end
24
+ array
25
+ end
26
+ end
4
27
  end
5
28
  end
@@ -1,5 +1,27 @@
1
+ require 'jungle_path/sql/helpers'
2
+
1
3
  module JunglePath
2
- module Sql
3
-
4
+ module SQL
5
+ module Role
6
+ def self.by_user db, key
7
+ sql = JunglePath::SQL::Helpers.sql("
8
+ select
9
+ a.id,
10
+ a.name,
11
+ a.description
12
+ from role a
13
+ join user_role b on a.id = b.role_id
14
+ where b.user_id = ?
15
+ ")
16
+
17
+ ds = db.base[sql, key.id]
18
+ result = ds.all
19
+ array = []
20
+ result.each do |row|
21
+ array << ({id: row[:id], name: row[:name], description: row[:description]})
22
+ end
23
+ array
24
+ end
25
+ end
4
26
  end
5
27
  end
@@ -1,8 +1,10 @@
1
+ require 'jungle_path/sql/helpers'
2
+
1
3
  module JunglePath
2
4
  module Sql
3
5
  module User
4
6
  def self.by_user_name(db, user_name)
5
- sql = SQLHelpers.sql("
7
+ sql = JunglePath::SQL::Helpers.sql("
6
8
  #{base_sql}
7
9
  where a.user_name = ?
8
10
  ")
@@ -17,7 +19,7 @@ module JunglePath
17
19
  private
18
20
 
19
21
  def self.base_sql
20
- SQLHelpers.sql("
22
+ JunglePath::SQL::Helpers.sql("
21
23
  select
22
24
  a.id,
23
25
  a.user_name,
@@ -1,5 +1,39 @@
1
+ require 'jungle_path/sql/helpers'
2
+
1
3
  module JunglePath
2
- module Sql
3
-
4
+ module SQL
5
+ module UserRole
6
+ def self.has_root_role_by_user_id(db, user_id)
7
+ puts "has_root_role_by_user_id: #{user_id}."
8
+ sql = JunglePath::SQL::Helpers.sql("
9
+ select
10
+ count(*)
11
+ from \"user\" a
12
+ join user_role b on b.user_id = a.id
13
+ join role c on c.id = b.role_id
14
+ where c.name = 'root'
15
+ and a.id = ?
16
+ ")
17
+ count = JunglePath::SQL::Helpers.get_count(db, sql, user_id)
18
+ puts "count: #{count}."
19
+ puts "(count > 0): #{(count > 0)}."
20
+ (count > 0)
21
+ end
22
+
23
+ def self.is_root_role_by_role_id(db, role_id)
24
+ puts "has_root_role_by_role_id: #{role_id}."
25
+ sql = JunglePath::SQL::Helpers.sql("
26
+ select
27
+ count(*)
28
+ from role a
29
+ where a.name = 'root'
30
+ and a.id = ?
31
+ ")
32
+ count = JunglePath::SQL::Helpers.get_count(db, sql, role_id)
33
+ puts "count: #{count}."
34
+ puts "(count > 0): #{(count > 0)}."
35
+ (count > 0)
36
+ end
37
+ end
4
38
  end
5
39
  end
@@ -1,12 +1,10 @@
1
1
  module JunglePath
2
- module Sql
2
+ module SQL
3
3
  require 'jungle_path/sql/helpers'
4
- require 'jungle_path/sql/general'
5
4
  require 'jungle_path/sql/user'
6
5
  require 'jungle_path/sql/key'
7
6
  require 'jungle_path/sql/role'
8
7
  require 'jungle_path/sql/user_role'
9
- require 'jungle_path/sql/auth_local_user'
10
8
  require 'jungle_path/sql/query_filter'
11
9
  end
12
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jungle_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael VanZant
@@ -163,8 +163,6 @@ files:
163
163
  - lib/jungle_path/schema/db.rb
164
164
  - lib/jungle_path/schema/version.rb
165
165
  - lib/jungle_path/sql.rb
166
- - lib/jungle_path/sql/auth_local_user.rb
167
- - lib/jungle_path/sql/general.rb
168
166
  - lib/jungle_path/sql/helpers.rb
169
167
  - lib/jungle_path/sql/key.rb
170
168
  - lib/jungle_path/sql/query_filter.rb
@@ -1,5 +0,0 @@
1
- module JunglePath
2
- module Sql
3
-
4
- end
5
- end
@@ -1,10 +0,0 @@
1
- module JunglePath
2
- module Sql
3
- def self.get_count(db, sql, arg)
4
- ds = db.base[sql, arg]
5
- result = ds.first
6
- puts "result: #{result}."
7
- count = result[:count].to_i
8
- end
9
- end
10
- end