jungle_path 0.0.0
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/.gitignore +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +22 -0
- data/README.md +5 -0
- data/jungle_path.gemspec +43 -0
- data/lib/jungle_path/api/helpers/auth.rb +45 -0
- data/lib/jungle_path/api/helpers/auth_local_user.rb +284 -0
- data/lib/jungle_path/api/helpers/auth_old.rb +232 -0
- data/lib/jungle_path/api/helpers/data_cache.rb +20 -0
- data/lib/jungle_path/api/helpers/defaults.rb +83 -0
- data/lib/jungle_path/api/helpers/logging.rb +36 -0
- data/lib/jungle_path/api/helpers/query_filters.rb +15 -0
- data/lib/jungle_path/api/helpers/rescues.rb +15 -0
- data/lib/jungle_path/api/helpers/result.rb +16 -0
- data/lib/jungle_path/api/helpers/standard_apis.rb +280 -0
- data/lib/jungle_path/api/helpers.rb +16 -0
- data/lib/jungle_path/api/template.erb +35 -0
- data/lib/jungle_path/api.rb +5 -0
- data/lib/jungle_path/app/a.gitignore +1 -0
- data/lib/jungle_path/app/api/server_base.rb +95 -0
- data/lib/jungle_path/app/api/server_custom.rb +121 -0
- data/lib/jungle_path/app/api/server_gen.rb +11 -0
- data/lib/jungle_path/app/auth/authorization.rb +96 -0
- data/lib/jungle_path/app/config/a.gitignore +1 -0
- data/lib/jungle_path/app/config/config.rb +240 -0
- data/lib/jungle_path/app/config/override.rb +3 -0
- data/lib/jungle_path/app/config.ru +28 -0
- data/lib/jungle_path/app/logs/log_files_go_here +0 -0
- data/lib/jungle_path/app/run.sh +4 -0
- data/lib/jungle_path/app/schemas/schema.rb +21 -0
- data/lib/jungle_path/app/schemas/schema_all_in_one.rb +181 -0
- data/lib/jungle_path/app.rb +8 -0
- data/lib/jungle_path/authentication/auth_provider/default.rb +83 -0
- data/lib/jungle_path/authentication/auth_provider.rb +7 -0
- data/lib/jungle_path/authentication/data_provider/default.rb +144 -0
- data/lib/jungle_path/authentication/data_provider.rb +7 -0
- data/lib/jungle_path/authentication/helpers.rb +19 -0
- data/lib/jungle_path/authentication/identity.rb +30 -0
- data/lib/jungle_path/authentication/password_hash.rb +124 -0
- data/lib/jungle_path/authentication.rb +9 -0
- data/lib/jungle_path/authorization/filter.rb +106 -0
- data/lib/jungle_path/authorization/paths.rb +71 -0
- data/lib/jungle_path/authorization.rb +5 -0
- data/lib/jungle_path/cache.rb +36 -0
- data/lib/jungle_path/config.rb +65 -0
- data/lib/jungle_path/controller/authentication.rb +129 -0
- data/lib/jungle_path/controller/base.rb +193 -0
- data/lib/jungle_path/controller/helpers.rb +47 -0
- data/lib/jungle_path/controller/template.erb +14 -0
- data/lib/jungle_path/controller.rb +7 -0
- data/lib/jungle_path/db_access/import/db_dir.rb +74 -0
- data/lib/jungle_path/db_access/import/delete.rb +30 -0
- data/lib/jungle_path/db_access/import/insert.rb +168 -0
- data/lib/jungle_path/db_access/import/schema.rb +34 -0
- data/lib/jungle_path/db_access/import/select.rb +68 -0
- data/lib/jungle_path/db_access/import.rb +15 -0
- data/lib/jungle_path/db_access/io/chunked_file_reader.rb +62 -0
- data/lib/jungle_path/db_access/io/config.rb +19 -0
- data/lib/jungle_path/db_access/io/copy.rb +73 -0
- data/lib/jungle_path/db_access/io/db.rb +82 -0
- data/lib/jungle_path/db_access/io/delete.rb +23 -0
- data/lib/jungle_path/db_access/io/init_db.rb +39 -0
- data/lib/jungle_path/db_access/io/insert.rb +24 -0
- data/lib/jungle_path/db_access/io/schema.rb +21 -0
- data/lib/jungle_path/db_access/io/select.rb +44 -0
- data/lib/jungle_path/db_access/io/update.rb +36 -0
- data/lib/jungle_path/db_access/io.rb +104 -0
- data/lib/jungle_path/db_model/column.rb +186 -0
- data/lib/jungle_path/db_model/params.rb +60 -0
- data/lib/jungle_path/db_model/schema.rb +100 -0
- data/lib/jungle_path/db_model/string.rb +9 -0
- data/lib/jungle_path/db_model/table.rb +307 -0
- data/lib/jungle_path/db_model.rb +34 -0
- data/lib/jungle_path/exceptions.rb +10 -0
- data/lib/jungle_path/gen/api.rb +52 -0
- data/lib/jungle_path/gen/controller.rb +0 -0
- data/lib/jungle_path/gen/db.rb +0 -0
- data/lib/jungle_path/gen/schema.rb +47 -0
- data/lib/jungle_path/gen/schema_tree/filter.rb +33 -0
- data/lib/jungle_path/gen/schema_tree/match_columns.rb +54 -0
- data/lib/jungle_path/gen/schema_tree/match_table_data.rb +22 -0
- data/lib/jungle_path/gen/schema_tree/match_tables.rb +70 -0
- data/lib/jungle_path/gen/schema_tree/node.rb +39 -0
- data/lib/jungle_path/gen/schema_tree.rb +105 -0
- data/lib/jungle_path/gen.rb +9 -0
- data/lib/jungle_path/json/base.rb +29 -0
- data/lib/jungle_path/json/time.rb +8 -0
- data/lib/jungle_path/json.rb +6 -0
- data/lib/jungle_path/logging.rb +23 -0
- data/lib/jungle_path/query/alias_info.rb +16 -0
- data/lib/jungle_path/query/engine.rb +878 -0
- data/lib/jungle_path/query/entity.rb +141 -0
- data/lib/jungle_path/query/field.rb +28 -0
- data/lib/jungle_path/query/field_primary_key.rb +27 -0
- data/lib/jungle_path/query/filter.rb +34 -0
- data/lib/jungle_path/query/float_value.rb +16 -0
- data/lib/jungle_path/query/from.rb +33 -0
- data/lib/jungle_path/query/int_value.rb +16 -0
- data/lib/jungle_path/query/limit.rb +19 -0
- data/lib/jungle_path/query/nested_hash_sorter.rb +94 -0
- data/lib/jungle_path/query/operator.rb +17 -0
- data/lib/jungle_path/query/query.rb +23 -0
- data/lib/jungle_path/query/sort_field.rb +34 -0
- data/lib/jungle_path/query/sql_string.rb +145 -0
- data/lib/jungle_path/query/string_value.rb +16 -0
- data/lib/jungle_path/query.rb +19 -0
- data/lib/jungle_path/rack/basic_credentials.rb +70 -0
- data/lib/jungle_path/rack/json_body_parser.rb +41 -0
- data/lib/jungle_path/rack.rb +6 -0
- data/lib/jungle_path/schema/auth.rb +83 -0
- data/lib/jungle_path/schema/base.rb +6 -0
- data/lib/jungle_path/schema/db.rb +10 -0
- data/lib/jungle_path/schema/version.rb +19 -0
- data/lib/jungle_path/schema.rb +8 -0
- data/lib/jungle_path/sql/auth_local_user.rb +5 -0
- data/lib/jungle_path/sql/general.rb +10 -0
- data/lib/jungle_path/sql/helpers.rb +11 -0
- data/lib/jungle_path/sql/key.rb +107 -0
- data/lib/jungle_path/sql/query_filter.rb +5 -0
- data/lib/jungle_path/sql/role.rb +5 -0
- data/lib/jungle_path/sql/user.rb +35 -0
- data/lib/jungle_path/sql/user_role.rb +5 -0
- data/lib/jungle_path/sql.rb +12 -0
- data/lib/jungle_path.rb +13 -0
- data/test.rb +33 -0
- data/test2.rb +15 -0
- metadata +200 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
# basic_credentials.rb
|
2
|
+
# Add basic auth credentials into Rack env.
|
3
|
+
# Return 401 Unauthorized if no credentials are passed.
|
4
|
+
require 'rack'
|
5
|
+
require 'rack/auth/abstract/handler'
|
6
|
+
require 'rack/auth/abstract/request'
|
7
|
+
|
8
|
+
module JunglePath
|
9
|
+
module Rack
|
10
|
+
module BasicCredentials
|
11
|
+
# Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617.
|
12
|
+
#
|
13
|
+
# Initialize with the Rack application that you want protecting,
|
14
|
+
# and a block that checks if a username and password pair are valid.
|
15
|
+
#
|
16
|
+
# See also: <tt>example/protectedlobster.rb</tt>
|
17
|
+
class Basic < ::Rack::Auth::AbstractHandler
|
18
|
+
def initialize(app, realm=nil, issue_challenge=true, &authenticator)
|
19
|
+
@issue_challenge = issue_challenge
|
20
|
+
super(app, realm, &authenticator)
|
21
|
+
end
|
22
|
+
|
23
|
+
def call(env)
|
24
|
+
#puts "realm: #{realm}."
|
25
|
+
|
26
|
+
auth = Basic::Request.new(env)
|
27
|
+
|
28
|
+
if @issue_challenge
|
29
|
+
return unauthorized unless auth.provided?
|
30
|
+
return bad_request unless auth.basic?
|
31
|
+
end
|
32
|
+
|
33
|
+
if auth.provided? and auth.basic?
|
34
|
+
env['REMOTE_USER'] = auth.username
|
35
|
+
env['REMOTE_PASSWORD'] = auth.password
|
36
|
+
else
|
37
|
+
env['REMOTE_USER'] = nil
|
38
|
+
env['REMOTE_PASSWORD'] = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
@app.call(env)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def challenge
|
47
|
+
'Basic realm="%s"' % realm
|
48
|
+
end
|
49
|
+
|
50
|
+
class Request < ::Rack::Auth::AbstractRequest
|
51
|
+
def basic?
|
52
|
+
"basic" == scheme
|
53
|
+
end
|
54
|
+
|
55
|
+
def credentials
|
56
|
+
@credentials ||= params.unpack("m*").first.split(/:/, 2)
|
57
|
+
end
|
58
|
+
|
59
|
+
def username
|
60
|
+
credentials.first
|
61
|
+
end
|
62
|
+
|
63
|
+
def password
|
64
|
+
credentials.last
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# rack_json_body_parser.rb -- mod of code from rack-contrib. This mod allows sybolizing the hash key names by passing in a second parameter to initialize.
|
2
|
+
#begin
|
3
|
+
# require 'json'
|
4
|
+
#rescue LoadError => e
|
5
|
+
# require 'json/pure'
|
6
|
+
#end
|
7
|
+
#require 'rack'
|
8
|
+
|
9
|
+
module JunglePath
|
10
|
+
require 'jungle_path/json'
|
11
|
+
|
12
|
+
module Rack
|
13
|
+
# A Rack middleware for parsing POST/PUT body data when Content-Type is
|
14
|
+
# not one of the standard supported types, like <tt>application/json</tt>.
|
15
|
+
class JsonBodyParser
|
16
|
+
# Constants
|
17
|
+
CONTENT_TYPE = 'CONTENT_TYPE'.freeze
|
18
|
+
POST_BODY = 'rack.input'.freeze
|
19
|
+
FORM_INPUT = 'rack.request.form_input'.freeze
|
20
|
+
FORM_HASH = 'rack.request.form_hash'.freeze
|
21
|
+
|
22
|
+
# Supported Content-Types
|
23
|
+
APPLICATION_JSON = 'application/json'.freeze
|
24
|
+
|
25
|
+
def initialize(app, symbolize_names=false)
|
26
|
+
@app = app
|
27
|
+
@symbolize_names = symbolize_names
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
if Rack::Request.new(env).media_type == APPLICATION_JSON && (body = env[POST_BODY].read).length != 0
|
32
|
+
puts "rack body: #{body}."
|
33
|
+
env[POST_BODY].rewind # somebody might try to read this stream
|
34
|
+
#env.update(FORM_HASH => JSON.parse(body, :symbolize_names=>@symbolize_names), FORM_INPUT => env[POST_BODY])
|
35
|
+
env.update(FORM_HASH => JunglePath::Json.parse(body, :symbolize_names=>@symbolize_names), FORM_INPUT => env[POST_BODY])
|
36
|
+
end
|
37
|
+
@app.call(env)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'jungle_path/schema'
|
2
|
+
|
3
|
+
module Schema
|
4
|
+
class Key < Schema::Base
|
5
|
+
define(
|
6
|
+
[:id, :primary_key],
|
7
|
+
[:key, :string, :unique, :secure, :not_null],
|
8
|
+
[:name, :string, :not_null],
|
9
|
+
[:user_id, :foreign_key, :user, :not_null, :unique_index, [:user_id, :name]],
|
10
|
+
[:expires_at, :timestamp, :not_null],
|
11
|
+
[:is_default, :boolean, :default, false],
|
12
|
+
[:audit_key]
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
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."
|
18
|
+
define(
|
19
|
+
[:user_id, :foreign_key, :user, :primary_key],
|
20
|
+
[:query_filter_id, :foreign_key, :query_filter, :primary_key],
|
21
|
+
[:audit_key]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
class KeyRole < Schema::Base
|
26
|
+
define(
|
27
|
+
[:user_id, :foreign_key, :user, :primary_key],
|
28
|
+
[:role_id, :foreign_key, :role, :primary_key],
|
29
|
+
[:audit_key]
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
class QueryFilter < Schema::Base
|
34
|
+
self.description = "misc. filters to apply against product/or other entities of the form: select product.id from product join table_x on table_x.product_id = product.id where table_x.some_column = 'abc'"
|
35
|
+
define(
|
36
|
+
[:id, :primary_key],
|
37
|
+
[:name, :string, :desc, "Give this filter a name so you know who it should apply to."],
|
38
|
+
[:base_table_name, :string, :desc, "Should be the name of the base table you are filtering on such as 'product'. Your filter will be applied to any queries containing tables which relate to the base table."],
|
39
|
+
[:sub_select, :string, :desc, "Your sub_select query should select a set of ids from your base table. You can join to any other related tables and add where clause conditions. Do not use table aliases, instead use the full table names to avoid naming collisions as your sub_select will be hooked into queries generated by API users."],
|
40
|
+
[:use_not_in, :boolean, :desc, "use a query like 'id not in (list....)' instead of 'id in (list...)'."],
|
41
|
+
[:audit_key]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
class Role < Schema::Base # use roles to group privileges and restrictions
|
46
|
+
define(
|
47
|
+
[:id, :primary_key],
|
48
|
+
[:name, :string, :unique_index, [:name], :not_null],
|
49
|
+
[:description, :string],
|
50
|
+
[:audit_key]
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
class User < Schema::Base
|
55
|
+
self.description = "User of system."
|
56
|
+
define(
|
57
|
+
[:id, :primary_key],
|
58
|
+
[:user_name, :string, :unique, :not_null, :alternate_key, :secure],
|
59
|
+
[:hash, :string, :not_null, :secure, :calculated, :desc, "See password_hash.rb for details."],
|
60
|
+
[:name, :string, :secure, :desc, "Your human name! :)"],
|
61
|
+
[:email, :string, :secure],
|
62
|
+
[:organization, :string, :secure],
|
63
|
+
[:notes, :string, :desc, "For any misc. notes about this user including addition email addresses, phone numbers, etc."],
|
64
|
+
[:active, :boolean, :default, true],
|
65
|
+
[:is_valid, :boolean, :calculated],
|
66
|
+
[:audit_user]
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
class User
|
71
|
+
@auth
|
72
|
+
@query_filters
|
73
|
+
attr_accessor :auth, :query_filters
|
74
|
+
end
|
75
|
+
|
76
|
+
class Key
|
77
|
+
def valid?
|
78
|
+
#puts "expires_at: #{expires_at}."
|
79
|
+
#puts "expires_at.class: #{expires_at.class}."
|
80
|
+
expires_at > Time.now
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Schema
|
2
|
+
# schema meta data:
|
3
|
+
|
4
|
+
def self.version
|
5
|
+
# Specify database version number.
|
6
|
+
# This version number will be used to apply database
|
7
|
+
# migrations.
|
8
|
+
# If the configatron.db.name does not exist, then
|
9
|
+
# this schema is applied directly and the appropriate
|
10
|
+
# version number is recorded in the database.
|
11
|
+
# Version of nil will run all available migrations
|
12
|
+
#1
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.migrations_path
|
17
|
+
::File.expand_path('../ztools/db/migrations',::File.dirname(__FILE__))
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module JunglePath
|
2
|
+
module Sql
|
3
|
+
module Key
|
4
|
+
def self.by_key(db, key)
|
5
|
+
sql = SQLHelpers.sql("
|
6
|
+
#{base_sql}
|
7
|
+
where a.key = ?
|
8
|
+
order by a.id
|
9
|
+
")
|
10
|
+
#puts "sql:\n#{sql}"
|
11
|
+
#puts "key: #{key}"
|
12
|
+
ds = db.base[sql, key]
|
13
|
+
all = ds.all
|
14
|
+
#puts "count: #{all.length}"
|
15
|
+
all
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.by_user_id(db, user_id)
|
19
|
+
sql = SQLHelpers.sql("
|
20
|
+
#{base_sql}
|
21
|
+
where a.user_id = ?
|
22
|
+
order by a.id
|
23
|
+
")
|
24
|
+
ds = db.base[sql, user_id]
|
25
|
+
ds.all
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.by_user_id_key_name(db, user_id, key_name)
|
29
|
+
sql = SQLHelpers.sql("
|
30
|
+
select
|
31
|
+
a.id,
|
32
|
+
a.key,
|
33
|
+
a.name,
|
34
|
+
a.user_id,
|
35
|
+
a.expires_at,
|
36
|
+
a.is_default,
|
37
|
+
a.created_at,
|
38
|
+
a.created_by_key_id,
|
39
|
+
a.updated_at,
|
40
|
+
a.updated_by_key_id
|
41
|
+
from key a
|
42
|
+
where a.user_id = ?
|
43
|
+
and a.name = ?
|
44
|
+
")
|
45
|
+
puts "db.class: #{db.class}."
|
46
|
+
ds = db.base[sql, user_id, key_name]
|
47
|
+
#puts "sql: #{ds.sql}."
|
48
|
+
ds.all
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.default_by_user_id(db, user_id)
|
52
|
+
sql = SQLHelpers.sql("
|
53
|
+
#{base_sql}
|
54
|
+
where a.user_id = ?
|
55
|
+
and a.is_default = true
|
56
|
+
order by a.id
|
57
|
+
")
|
58
|
+
ds = db.base[sql, user_id]
|
59
|
+
ds.all
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.by_user_id(db, user_id)
|
63
|
+
sql = SQLHelpers.sql("
|
64
|
+
#{base_sql}
|
65
|
+
where a.user_id = ?
|
66
|
+
order by a.id
|
67
|
+
")
|
68
|
+
ds = db.base[sql, user_id]
|
69
|
+
ds.all
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.default_by_user_id(db, user_id)
|
73
|
+
sql = SQLHelpers.sql("
|
74
|
+
#{base_sql}
|
75
|
+
where a.user_id = ?
|
76
|
+
and a.is_default = true
|
77
|
+
order by a.id
|
78
|
+
")
|
79
|
+
#puts "sql:\n#{sql}."
|
80
|
+
ds = db.base[sql, user_id]
|
81
|
+
ds.all
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def self.base_sql
|
87
|
+
SQLHelpers.sql("
|
88
|
+
select
|
89
|
+
a.id,
|
90
|
+
a.key,
|
91
|
+
a.name,
|
92
|
+
a.user_id,
|
93
|
+
a.expires_at,
|
94
|
+
a.is_default
|
95
|
+
from key a
|
96
|
+
join (
|
97
|
+
select
|
98
|
+
b.key_id
|
99
|
+
from role a
|
100
|
+
join key_role b on b.role_id = a.id
|
101
|
+
group by b.key_id
|
102
|
+
) b on b.key_id = a.id
|
103
|
+
")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JunglePath
|
2
|
+
module Sql
|
3
|
+
module User
|
4
|
+
def self.by_user_name(db, user_name)
|
5
|
+
sql = SQLHelpers.sql("
|
6
|
+
#{base_sql}
|
7
|
+
where a.user_name = ?
|
8
|
+
")
|
9
|
+
puts "sql:\n#{sql}."
|
10
|
+
puts "user_name: #{user_name}."
|
11
|
+
ds = db.base[sql, user_name]
|
12
|
+
row = ds.first
|
13
|
+
puts "row: #{row}."
|
14
|
+
row
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.base_sql
|
20
|
+
SQLHelpers.sql("
|
21
|
+
select
|
22
|
+
a.id,
|
23
|
+
a.user_name,
|
24
|
+
a.hash,
|
25
|
+
a.name,
|
26
|
+
a.email,
|
27
|
+
a.organization,
|
28
|
+
a.notes,
|
29
|
+
a.active
|
30
|
+
from \"user\" a
|
31
|
+
")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JunglePath
|
2
|
+
module Sql
|
3
|
+
require 'jungle_path/sql/helpers'
|
4
|
+
require 'jungle_path/sql/general'
|
5
|
+
require 'jungle_path/sql/user'
|
6
|
+
require 'jungle_path/sql/key'
|
7
|
+
require 'jungle_path/sql/role'
|
8
|
+
require 'jungle_path/sql/user_role'
|
9
|
+
require 'jungle_path/sql/auth_local_user'
|
10
|
+
require 'jungle_path/sql/query_filter'
|
11
|
+
end
|
12
|
+
end
|
data/lib/jungle_path.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module JunglePath
|
2
|
+
require 'jungle_path/api'
|
3
|
+
require 'jungle_path/authentication'
|
4
|
+
require 'jungle_path/cache'
|
5
|
+
require 'jungle_path/config'
|
6
|
+
require 'jungle_path/controller'
|
7
|
+
require 'jungle_path/db_model'
|
8
|
+
require 'jungle_path/exceptions'
|
9
|
+
require 'jungle_path/json'
|
10
|
+
require 'jungle_path/query'
|
11
|
+
#require 'jungle_path/schema' #should be required by app when needed...
|
12
|
+
require 'jungle_path/sql'
|
13
|
+
end
|
data/test.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Model
|
5
|
+
class Table
|
6
|
+
def self.models
|
7
|
+
@models
|
8
|
+
end
|
9
|
+
def self.inherited(sub_class)
|
10
|
+
puts "#{sub_class} is a child of #{self}."
|
11
|
+
@models = [] unless models
|
12
|
+
@models << sub_class
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module MySchema
|
18
|
+
class Base < Model::Table
|
19
|
+
#extend Tables
|
20
|
+
end
|
21
|
+
class MyTableA < MySchema::Base
|
22
|
+
end
|
23
|
+
class MyTableB < MySchema::Base
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module MyOtherSchema
|
28
|
+
class Base < Model::Table
|
29
|
+
#extend Tables
|
30
|
+
end
|
31
|
+
class MyOtherTable < MyOtherSchema::Base
|
32
|
+
end
|
33
|
+
end
|