aqueduct 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -1
- data/README.rdoc +16 -2
- data/Rakefile +4 -1
- data/aqueduct.gemspec +2 -2
- data/lib/aqueduct.rb +43 -0
- data/lib/aqueduct/repositories/developer.rb +42 -0
- data/lib/aqueduct/repository.rb +34 -0
- data/lib/aqueduct/version.rb +1 -1
- data/lib/aqueduct/wrapper.rb +80 -0
- data/lib/aqueduct/wrappers/developer.rb +77 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +6 -0
- data/test/dummy/log/test.log +14 -0
- metadata +22 -7
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
-
= Aqueduct
|
1
|
+
= Aqueduct {<img src="https://secure.travis-ci.org/remomueller/aqueduct.png"/>}[http://travis-ci.org/remomueller/aqueduct] {<img src="https://gemnasium.com/remomueller/aqueduct.png" alt="Dependency Status" />}[https://gemnasium.com/remomueller/aqueduct]
|
2
2
|
|
3
|
-
|
3
|
+
Data integration gem designed to increase data flow between applications.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Aqueduct can be installed from rubygems.org using:
|
8
|
+
|
9
|
+
gem install aqueduct
|
10
|
+
|
11
|
+
Or update your Gemfile to include:
|
12
|
+
|
13
|
+
gem 'aqueduct'
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Remo Mueller. See {LICENSE}[https://github.com/remomueller/aqueduct/blob/master/LICENSE] for further details.
|
data/Rakefile
CHANGED
@@ -16,10 +16,13 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
16
|
rdoc.rdoc_dir = 'rdoc'
|
17
17
|
rdoc.title = 'Aqueduct'
|
18
18
|
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('CHANGELOG.rdoc')
|
19
20
|
rdoc.rdoc_files.include('README.rdoc')
|
20
21
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
22
|
end
|
22
23
|
|
24
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
25
|
+
load 'rails/tasks/engine.rake'
|
23
26
|
|
24
27
|
|
25
28
|
|
@@ -35,4 +38,4 @@ Rake::TestTask.new(:test) do |t|
|
|
35
38
|
end
|
36
39
|
|
37
40
|
|
38
|
-
task :
|
41
|
+
task default: :test
|
data/aqueduct.gemspec
CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.email = ["remosm@gmail.com"]
|
20
20
|
s.homepage = "https://github.com/remomueller"
|
21
21
|
s.summary = "Data integration gem designed to increase data flow between applications"
|
22
|
-
s.description = "Data integration gem designed to increase data flow between applications"
|
22
|
+
s.description = "Data integration gem designed to increase data flow between applications using a common interface"
|
23
23
|
|
24
24
|
s.files = Dir["{app,config,db,lib}/**/*"] + ["aqueduct.gemspec", "CHANGELOG.rdoc", "LICENSE", "Rakefile", "README.rdoc"]
|
25
25
|
s.test_files = Dir["test/**/*"]
|
26
26
|
|
27
|
-
s.add_dependency "rails", "~> 3.2.
|
27
|
+
s.add_dependency "rails", "~> 3.2.1"
|
28
28
|
|
29
29
|
s.add_development_dependency "sqlite3"
|
30
30
|
end
|
data/lib/aqueduct.rb
CHANGED
@@ -1,4 +1,47 @@
|
|
1
|
+
require 'aqueduct/repository'
|
2
|
+
require 'aqueduct/wrapper'
|
1
3
|
require 'aqueduct/version'
|
2
4
|
|
3
5
|
module Aqueduct
|
6
|
+
module Repositories
|
7
|
+
autoload :Developer, 'aqueduct/repositories/developer'
|
8
|
+
end
|
9
|
+
|
10
|
+
module Wrappers
|
11
|
+
autoload :Developer, 'aqueduct/wrappers/developer'
|
12
|
+
end
|
13
|
+
|
14
|
+
autoload :Repository, 'aqueduct/repository'
|
15
|
+
autoload :Wrapper, 'aqueduct/wrapper'
|
16
|
+
|
17
|
+
def self.repositories
|
18
|
+
@@repositories ||= []
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.wrappers
|
22
|
+
@@wrappers ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
class Builder
|
26
|
+
def self.repository(source, user)
|
27
|
+
klass = source.repository[0].upcase + source.repository[1..-1]
|
28
|
+
|
29
|
+
begin
|
30
|
+
Aqueduct::Repositories.const_get(klass).new(source, user)
|
31
|
+
rescue NameError
|
32
|
+
raise LoadError, "Please add aqueduct-#{source.repository} to your Gemfile."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.wrapper(source, user)
|
37
|
+
klass = source.wrapper[0].upcase + source.wrapper[1..-1]
|
38
|
+
|
39
|
+
begin
|
40
|
+
Aqueduct::Wrappers.const_get(klass).new(source, user)
|
41
|
+
rescue NameError
|
42
|
+
raise LoadError, "Please add aqueduct-#{source.wrapper} to your Gemfile."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
4
47
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'aqueduct'
|
2
|
+
|
3
|
+
module Aqueduct
|
4
|
+
module Repositories
|
5
|
+
class Developer
|
6
|
+
include Aqueduct::Repository
|
7
|
+
|
8
|
+
# Returns a list of urls to download files
|
9
|
+
def count_files(file_locators, file_type)
|
10
|
+
error = ''
|
11
|
+
result = 0
|
12
|
+
file_paths = []
|
13
|
+
url_paths = []
|
14
|
+
file_locators.each do |file_locator|
|
15
|
+
file_locator = file_locator.to_s.gsub(/[\/*]/, '') # Don't allow wild cards or subfolders
|
16
|
+
file_type = file_type.to_s.gsub(/[\/*]/, '') # Don't allow wild cards or subfolders
|
17
|
+
matching_file_names = Dir.glob(File.join(Rails.root, 'test', 'support', 'repositories', "#{file_locator}#{file_type}"))
|
18
|
+
matching_file_names.each do |file_name|
|
19
|
+
file_paths << file_name unless file_name.blank?
|
20
|
+
url_paths << SITE_URL + "/sources/#{@source.id}/download_file?file_locator=#{file_locator}&file_type=#{file_type}&fn=#{file_name.split('/').last}" unless file_name.blank?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
{ result: url_paths.size, error: error, file_paths: file_paths, urls: url_paths }
|
25
|
+
end
|
26
|
+
|
27
|
+
# Only For Local repositories.
|
28
|
+
def get_file(file_locator, file_type)
|
29
|
+
result_hash = count_files([file_locator], file_type)
|
30
|
+
{ file_path: result_hash[:file_paths].first.to_s, error: result_hash[:error] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_repository?
|
34
|
+
{ result: true, error: "" }
|
35
|
+
end
|
36
|
+
|
37
|
+
def file_server_available?
|
38
|
+
{ result: true, error: "" }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'aqueduct'
|
2
|
+
|
3
|
+
module Aqueduct
|
4
|
+
module Repository
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
Aqueduct.repositories << base
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(source, current_user)
|
11
|
+
@source = source
|
12
|
+
@current_user = current_user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a list of urls to download files
|
16
|
+
def count_files(file_locators, file_type)
|
17
|
+
{ result: 0, error: "Unknown Repository: #{@source.repository}", file_paths: [], urls: [] }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Only For Local repositories.
|
21
|
+
def get_file(file_locator, file_type)
|
22
|
+
{ file_path: '', error: "Unknown Repository: #{@source.repository}" }
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_repository?
|
26
|
+
{ result: false, error: "Unknown Repository: #{@source.repository}" }
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_server_available?
|
30
|
+
{ result: false, error: "Unknown Repository: #{@source.repository}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/aqueduct/version.rb
CHANGED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'aqueduct'
|
2
|
+
|
3
|
+
module Aqueduct
|
4
|
+
module Wrapper
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
Aqueduct.wrappers << base
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(source, current_user)
|
11
|
+
@source = source
|
12
|
+
@current_user = current_user
|
13
|
+
@db_connection = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def connect
|
17
|
+
@db_connection
|
18
|
+
end
|
19
|
+
|
20
|
+
def disconnect
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def query(sql_statement)
|
25
|
+
[[],0]
|
26
|
+
end
|
27
|
+
|
28
|
+
def use_sql?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def sql_codes
|
33
|
+
{ text: '', numeric: '', open: '', close: '' }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the Connection Status of the underlying data source.
|
37
|
+
def connected?
|
38
|
+
{ result: false, error: "Unknown Wrapper: #{@source.wrapper}" }
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns an array of tables
|
42
|
+
def tables
|
43
|
+
{ result: [], error: "Unknown Wrapper: #{@source.wrapper}" }
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns an array of columns for a given table
|
47
|
+
def table_columns(table)
|
48
|
+
{ columns: [], error: "Unknown Wrapper: #{@source.wrapper}" }
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_all_values_for_column(table, column)
|
52
|
+
{ values: [], error: "<span style='vertical-align:middle'><img height='13' width='13' align='absmiddle' src='#{SITE_URL}/assets/contour/cross.png' alt='warning' /></span> Unknown Wrapper: #{@source.wrapper}" }
|
53
|
+
end
|
54
|
+
|
55
|
+
def column_values(table, column)
|
56
|
+
{ result: [], error: "Unknown Wrapper: #{@source.wrapper}" }
|
57
|
+
end
|
58
|
+
|
59
|
+
def count(query_concepts, conditions, tables, join_conditions, concept_to_count)
|
60
|
+
{ result: 0, error: "Unknown Wrapper: #{@source.wrapper}" }
|
61
|
+
end
|
62
|
+
|
63
|
+
def external_concepts(folder = '', search_term = '')
|
64
|
+
{ result: [], error: '' }#, error: "Unknown Wrapper: #{@source.wrapper}"}
|
65
|
+
end
|
66
|
+
|
67
|
+
def external_concept_information(external_key = '')
|
68
|
+
{ result: {}, error: "Unknown Wrapper: #{@source.wrapper}" }
|
69
|
+
end
|
70
|
+
|
71
|
+
def concept_tables(query_concept)
|
72
|
+
{ result: [], error: "Unknown Wrapper: #{@source.wrapper}" }
|
73
|
+
end
|
74
|
+
|
75
|
+
def conditions(query_concepts)
|
76
|
+
{ conditions: '', error: "Unknown Wrapper: #{@source.wrapper}" }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'aqueduct'
|
2
|
+
|
3
|
+
module Aqueduct
|
4
|
+
module Wrappers
|
5
|
+
class Developer
|
6
|
+
include Aqueduct::Wrapper
|
7
|
+
|
8
|
+
def initialize(source, current_user)
|
9
|
+
@source = source
|
10
|
+
@current_user = current_user
|
11
|
+
@db_connection = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def disconnect
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def query(sql_statement)
|
19
|
+
[[[1,2,3,4],[5,nil,7,8]],2]
|
20
|
+
end
|
21
|
+
|
22
|
+
def sql_codes
|
23
|
+
{ text: 'text', numeric: 'numeric', open: '[', close: ']' }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the Connection Status of the underlying data source.
|
27
|
+
def connected?
|
28
|
+
{ result: true, error: "" }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns an array of tables
|
32
|
+
def tables
|
33
|
+
{ result: ['table'], error: "" }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns an array of columns for a given table
|
37
|
+
def table_columns(table)
|
38
|
+
if table.blank?
|
39
|
+
{ columns: [], error: "No Table Name Provided" }
|
40
|
+
else
|
41
|
+
{ columns: (1..50).collect{|i| { column: "column#{i}" }} + [{ column: "gender" }], error: "" }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_all_values_for_column(table, column)
|
46
|
+
values = []
|
47
|
+
case column when 'gender'
|
48
|
+
values = ['m', 'f', nil, 'm', 'm', 'f']
|
49
|
+
when 'column4'
|
50
|
+
values = [20, 21, 22, 23, 27, 28]
|
51
|
+
end
|
52
|
+
{ values: values, error: "" }
|
53
|
+
end
|
54
|
+
|
55
|
+
def column_values(table, column)
|
56
|
+
values = []
|
57
|
+
values_hash = self.get_all_values_for_column(table, column)
|
58
|
+
values = values_hash[:values].uniq
|
59
|
+
{ result: values, error: values_hash[:error] }
|
60
|
+
end
|
61
|
+
|
62
|
+
def count(query_concepts, conditions, tables, join_conditions, concept_to_count)
|
63
|
+
result = (conditions == '1 = 1') ? 100 : 0
|
64
|
+
{ result: result, error: "" }
|
65
|
+
end
|
66
|
+
|
67
|
+
def concept_tables(query_concept)
|
68
|
+
{ result: ['table'], error: "" }
|
69
|
+
end
|
70
|
+
|
71
|
+
def conditions(query_concepts)
|
72
|
+
conditions = (query_concepts.size > 0) ? '1 = 1' : '1 = 0'
|
73
|
+
{ conditions: conditions, error: "" }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 0) do
|
15
|
+
|
16
|
+
end
|
Binary file
|
@@ -0,0 +1,6 @@
|
|
1
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
2
|
+
[1m[35m (1.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
3
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
4
|
+
[1m[35m (1.5ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
5
|
+
[1m[36m (0.3ms)[0m [1mselect sqlite_version(*)[0m
|
6
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
2
|
+
[1m[35m (3.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
3
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
4
|
+
[1m[35m (1.3ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
5
|
+
[1m[36m (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
6
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
7
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
8
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
9
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
10
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
12
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
13
|
+
[1m[36m (0.5ms)[0m [1mbegin transaction[0m
|
14
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aqueduct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70203822551000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.2.
|
21
|
+
version: 3.2.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70203822551000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &70203822550400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,15 +32,20 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70203822550400
|
36
36
|
description: Data integration gem designed to increase data flow between applications
|
37
|
+
using a common interface
|
37
38
|
email:
|
38
39
|
- remosm@gmail.com
|
39
40
|
executables: []
|
40
41
|
extensions: []
|
41
42
|
extra_rdoc_files: []
|
42
43
|
files:
|
44
|
+
- lib/aqueduct/repositories/developer.rb
|
45
|
+
- lib/aqueduct/repository.rb
|
43
46
|
- lib/aqueduct/version.rb
|
47
|
+
- lib/aqueduct/wrapper.rb
|
48
|
+
- lib/aqueduct/wrappers/developer.rb
|
44
49
|
- lib/aqueduct.rb
|
45
50
|
- lib/tasks/aqueduct_tasks.rake
|
46
51
|
- aqueduct.gemspec
|
@@ -70,6 +75,11 @@ files:
|
|
70
75
|
- test/dummy/config/locales/en.yml
|
71
76
|
- test/dummy/config/routes.rb
|
72
77
|
- test/dummy/config.ru
|
78
|
+
- test/dummy/db/development.sqlite3
|
79
|
+
- test/dummy/db/schema.rb
|
80
|
+
- test/dummy/db/test.sqlite3
|
81
|
+
- test/dummy/log/development.log
|
82
|
+
- test/dummy/log/test.log
|
73
83
|
- test/dummy/public/404.html
|
74
84
|
- test/dummy/public/422.html
|
75
85
|
- test/dummy/public/500.html
|
@@ -125,6 +135,11 @@ test_files:
|
|
125
135
|
- test/dummy/config/locales/en.yml
|
126
136
|
- test/dummy/config/routes.rb
|
127
137
|
- test/dummy/config.ru
|
138
|
+
- test/dummy/db/development.sqlite3
|
139
|
+
- test/dummy/db/schema.rb
|
140
|
+
- test/dummy/db/test.sqlite3
|
141
|
+
- test/dummy/log/development.log
|
142
|
+
- test/dummy/log/test.log
|
128
143
|
- test/dummy/public/404.html
|
129
144
|
- test/dummy/public/422.html
|
130
145
|
- test/dummy/public/500.html
|