adhoq 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +28 -0
- data/app/assets/javascripts/adhoq/application.js +19 -0
- data/app/assets/javascripts/adhoq/bootstrap-sprockets.js +12 -0
- data/app/assets/javascripts/adhoq/bootstrap.js +2107 -0
- data/app/assets/javascripts/adhoq/bootstrap/affix.js +142 -0
- data/app/assets/javascripts/adhoq/bootstrap/alert.js +92 -0
- data/app/assets/javascripts/adhoq/bootstrap/button.js +110 -0
- data/app/assets/javascripts/adhoq/bootstrap/carousel.js +223 -0
- data/app/assets/javascripts/adhoq/bootstrap/collapse.js +170 -0
- data/app/assets/javascripts/adhoq/bootstrap/dropdown.js +151 -0
- data/app/assets/javascripts/adhoq/bootstrap/modal.js +280 -0
- data/app/assets/javascripts/adhoq/bootstrap/popover.js +113 -0
- data/app/assets/javascripts/adhoq/bootstrap/scrollspy.js +170 -0
- data/app/assets/javascripts/adhoq/bootstrap/tab.js +128 -0
- data/app/assets/javascripts/adhoq/bootstrap/tooltip.js +457 -0
- data/app/assets/javascripts/adhoq/bootstrap/transition.js +59 -0
- data/app/assets/javascripts/adhoq/previewer.js.coffee +25 -0
- data/app/assets/stylesheets/adhoq/_bootstrap-compass.scss +7 -0
- data/app/assets/stylesheets/adhoq/_bootstrap-mincer.scss +17 -0
- data/app/assets/stylesheets/adhoq/_bootstrap-sprockets.scss +7 -0
- data/app/assets/stylesheets/adhoq/adhoq.css.sass +57 -0
- data/app/assets/stylesheets/adhoq/application.css +16 -0
- data/app/assets/stylesheets/adhoq/bootstrap.scss +50 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_alerts.scss +68 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_badges.scss +57 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_breadcrumbs.scss +26 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_button-groups.scss +240 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_buttons.scss +157 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_carousel.scss +243 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_close.scss +35 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_code.scss +68 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_component-animations.scss +35 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_dropdowns.scss +215 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_forms.scss +538 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_glyphicons.scss +237 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_grid.scss +84 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_input-groups.scss +166 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_jumbotron.scss +48 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_labels.scss +66 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_list-group.scss +131 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_media.scss +56 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_mixins.scss +39 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_modals.scss +150 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_navbar.scss +659 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_navs.scss +242 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_normalize.scss +425 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_pager.scss +55 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_pagination.scss +88 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_panels.scss +243 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_popovers.scss +133 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_print.scss +101 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_progress-bars.scss +105 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_responsive-embed.scss +34 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_responsive-utilities.scss +174 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_scaffolding.scss +150 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_tables.scss +233 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_theme.scss +258 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_thumbnails.scss +38 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_tooltip.scss +95 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_type.scss +304 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_utilities.scss +57 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_variables.scss +850 -0
- data/app/assets/stylesheets/adhoq/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/adhoq/bootstrap/bootstrap.scss +50 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_alerts.scss +14 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_background-variant.scss +11 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_border-radius.scss +18 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_buttons.scss +50 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_center-block.scss +7 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_clearfix.scss +22 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_forms.scss +84 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_gradients.scss +58 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_grid-framework.scss +81 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_grid.scss +122 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_hide-text.scss +21 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_image.scss +34 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_labels.scss +12 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_list-group.scss +31 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_nav-divider.scss +10 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_opacity.scss +8 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_pagination.scss +23 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_panels.scss +24 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_progress-bar.scss +10 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_reset-filter.scss +8 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_responsive-visibility.scss +21 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_size.scss +10 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_tab-focus.scss +9 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_table-row.scss +28 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_text-emphasis.scss +11 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_text-overflow.scss +8 -0
- data/app/assets/stylesheets/adhoq/bootstrap/mixins/_vendor-prefixes.scss +219 -0
- data/app/controllers/adhoq/application_controller.rb +5 -0
- data/app/controllers/adhoq/authorization_methods.rb +36 -0
- data/app/controllers/adhoq/executions_controller.rb +25 -0
- data/app/controllers/adhoq/previews_controller.rb +13 -0
- data/app/controllers/adhoq/queries_controller.rb +38 -0
- data/app/helpers/adhoq/application_helper.rb +11 -0
- data/app/models/adhoq/execution.rb +29 -0
- data/app/models/adhoq/query.rb +14 -0
- data/app/models/adhoq/report.rb +42 -0
- data/app/models/adhoq/time_based_orders.rb +9 -0
- data/app/views/adhoq/application/_global_nav.html.slim +11 -0
- data/app/views/adhoq/application/_sidebar_queries_index.html.slim +10 -0
- data/app/views/adhoq/previews/create.html.slim +12 -0
- data/app/views/adhoq/previews/statement_invalid.html.slim +5 -0
- data/app/views/adhoq/queries/_form.html.slim +38 -0
- data/app/views/adhoq/queries/_query.html.slim +43 -0
- data/app/views/adhoq/queries/edit.html.slim +2 -0
- data/app/views/adhoq/queries/index.html.slim +1 -0
- data/app/views/adhoq/queries/new.html.slim +2 -0
- data/app/views/adhoq/queries/show.html.slim +1 -0
- data/app/views/layouts/adhoq/application.html.slim +18 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20141003095645_create_adhoq_queries.rb +11 -0
- data/db/migrate/20141006014750_create_adhoq_executions.rb +13 -0
- data/db/migrate/20141007052308_create_adhoq_reports.rb +12 -0
- data/lib/adhoq.rb +13 -0
- data/lib/adhoq/configuration.rb +21 -0
- data/lib/adhoq/engine.rb +15 -0
- data/lib/adhoq/error.rb +4 -0
- data/lib/adhoq/executor.rb +27 -0
- data/lib/adhoq/global_variable.rb +34 -0
- data/lib/adhoq/reporter.rb +5 -0
- data/lib/adhoq/reporter/xlsx.rb +32 -0
- data/lib/adhoq/result.rb +18 -0
- data/lib/adhoq/storage.rb +5 -0
- data/lib/adhoq/storage/local_file.rb +45 -0
- data/lib/adhoq/version.rb +3 -0
- data/lib/tasks/adhoq_tasks.rake +4 -0
- data/spec/adhoq/executor_spec.rb +11 -0
- data/spec/adhoq/storage_spec.rb +19 -0
- data/spec/factories/adhoq_queries.rb +29 -0
- data/spec/models/adhoq/execution_spec.rb +4 -0
- data/spec/models/adhoq/query_spec.rb +4 -0
- data/spec/models/adhoq/report_spec.rb +25 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/support/have_values_in_xlsx_sheet_matcher.rb +20 -0
- metadata +375 -0
data/lib/adhoq.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'adhoq/engine'
|
2
|
+
require 'adhoq/global_variable'
|
3
|
+
|
4
|
+
module Adhoq
|
5
|
+
autoload 'Configuration', 'adhoq/configuration'
|
6
|
+
autoload 'Error', 'adhoq/error'
|
7
|
+
autoload 'Executor', 'adhoq/executor'
|
8
|
+
autoload 'Reporter', 'adhoq/reporter'
|
9
|
+
autoload 'Result', 'adhoq/result'
|
10
|
+
autoload 'Storage', 'adhoq/storage'
|
11
|
+
|
12
|
+
extend Adhoq::GlobalVariable
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# see https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/config.rb
|
2
|
+
module Adhoq
|
3
|
+
class Configuration
|
4
|
+
include ActiveSupport::Configurable
|
5
|
+
|
6
|
+
config_accessor :storage
|
7
|
+
|
8
|
+
config_accessor :authorization
|
9
|
+
config_accessor :authorization_failure_action
|
10
|
+
|
11
|
+
config_accessor :current_user
|
12
|
+
|
13
|
+
def callablize(name)
|
14
|
+
if (c = config[name]).respond_to?(:call)
|
15
|
+
c
|
16
|
+
else
|
17
|
+
c.to_proc
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/adhoq/engine.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# TODO where to write?
|
2
|
+
require 'font-awesome-sass'
|
3
|
+
require 'jquery-rails'
|
4
|
+
require 'slim-rails'
|
5
|
+
|
6
|
+
module Adhoq
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace Adhoq
|
9
|
+
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec, fixture: false
|
12
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/adhoq/error.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Adhoq
|
2
|
+
class Executor
|
3
|
+
class << self
|
4
|
+
def select(query)
|
5
|
+
current_connection.send(:select, query)
|
6
|
+
end
|
7
|
+
|
8
|
+
def current_connection
|
9
|
+
ActiveRecord::Base.connection
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(query)
|
14
|
+
@query = query
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute
|
18
|
+
wrap_result(self.class.select(@query))
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def wrap_result(ar_result)
|
24
|
+
Adhoq::Result.new(ar_result.columns, ar_result.rows)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'monitor'
|
2
|
+
|
3
|
+
module Adhoq
|
4
|
+
module GlobalVariable
|
5
|
+
def self.extended(base)
|
6
|
+
base.extend MonitorMixin
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_storage
|
10
|
+
synchronize {
|
11
|
+
@current_storage ||= setup_storage(*Adhoq.config.storage)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure(&block)
|
16
|
+
yield config
|
17
|
+
end
|
18
|
+
|
19
|
+
def config
|
20
|
+
@config ||= Adhoq::Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# TODO Implement S3
|
26
|
+
def setup_storage(type, *args)
|
27
|
+
unless type == :local_file
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
Adhoq::Storage::LocalFile.new(*args)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'axlsx'
|
2
|
+
|
3
|
+
module Adhoq
|
4
|
+
module Reporter
|
5
|
+
class Xlsx
|
6
|
+
|
7
|
+
def self.mime_type
|
8
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(result)
|
12
|
+
@result = result
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_report
|
16
|
+
xlsx = Axlsx::Package.new
|
17
|
+
write_result!(xlsx)
|
18
|
+
|
19
|
+
xlsx.to_stream
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def write_result!(xlsx)
|
25
|
+
xlsx.workbook.add_worksheet do |sheet|
|
26
|
+
sheet.add_row @result.header
|
27
|
+
@result.rows.each {|row| sheet.add_row row }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/adhoq/result.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Adhoq
|
2
|
+
class Result
|
3
|
+
attr_reader :header, :rows
|
4
|
+
|
5
|
+
def initialize(header, rows = [])
|
6
|
+
@header = header
|
7
|
+
@rows = rows
|
8
|
+
end
|
9
|
+
|
10
|
+
def <<(row)
|
11
|
+
rows << row
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(obj)
|
15
|
+
header == obj.header && rows == obj.rows
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Adhoq
|
2
|
+
module Storage
|
3
|
+
class LocalFile
|
4
|
+
attr_reader :root
|
5
|
+
|
6
|
+
def initialize(root_path)
|
7
|
+
@root = Pathname.new(root_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def identifier
|
11
|
+
"file://#{@root.realpath}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def store(suffix = nil, seed = Time.now, &block)
|
15
|
+
calculate_identifier(suffix, seed).tap do |identifier|
|
16
|
+
mkpath!(identifier)
|
17
|
+
|
18
|
+
(@root + identifier).open('w:BINARY') do |file|
|
19
|
+
yield file, identifier
|
20
|
+
file.flush
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(identifier)
|
26
|
+
(@root + identifier).open('r:BINARY')
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def calculate_identifier(suffix, seed)
|
32
|
+
dirname, fname_seed = ['%Y-%m-%d', '%H%M%S.%L'].map {|f| seed.strftime(f) }
|
33
|
+
|
34
|
+
basename = "%s_%05d%s" % [fname_seed, Process.pid, suffix]
|
35
|
+
|
36
|
+
identifier = [dirname, basename].join('/')
|
37
|
+
end
|
38
|
+
|
39
|
+
def mkpath!(identifier)
|
40
|
+
dir = identifier.split('/').first
|
41
|
+
(@root + dir).mkpath
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Adhoq
|
2
|
+
RSpec.describe Storage, type: :model do
|
3
|
+
describe Storage::LocalFile do
|
4
|
+
tempdir = __dir__ + '/../../tmp/adhoq_storage.test'
|
5
|
+
|
6
|
+
after(:all) do
|
7
|
+
FileUtils.rm_rf(tempdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:storage) { Storage::LocalFile.new(tempdir) }
|
11
|
+
|
12
|
+
let(:identifier) do
|
13
|
+
storage.store('.txt') {|file, ident| file.puts 'Hello adhoq!' }
|
14
|
+
end
|
15
|
+
|
16
|
+
specify { expect(storage.get(identifier).read).to eq "Hello adhoq!\n" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :adhoq_query, class: 'Adhoq::Query' do
|
5
|
+
name 'A query'
|
6
|
+
description 'Simple simple SELECT'
|
7
|
+
query 'SELECT 1'
|
8
|
+
|
9
|
+
trait :complex do
|
10
|
+
name 'adhoq current use'
|
11
|
+
description 'Simple analysys: count execution per query'
|
12
|
+
query <<-SQL.strip_heredoc
|
13
|
+
SELECT
|
14
|
+
q.id
|
15
|
+
,q.name
|
16
|
+
,(
|
17
|
+
SELECT COUNT(*)
|
18
|
+
FROM adhoq_executions exec
|
19
|
+
INNER JOIN adhoq_reports r ON r.execution_id = exec.id
|
20
|
+
WHERE exec.query_id = q.id
|
21
|
+
) AS use_count
|
22
|
+
FROM
|
23
|
+
adhoq_queries q
|
24
|
+
ORDER BY
|
25
|
+
use_count DESC, id ASC
|
26
|
+
SQL
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Adhoq
|
2
|
+
RSpec.describe Report, type: :model do
|
3
|
+
context 'create xlsx report' do
|
4
|
+
let(:query) do
|
5
|
+
create(:adhoq_query, query: 'SELECT name, description FROM adhoq_queries')
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:report) do
|
9
|
+
execution = query.execute!('xlsx')
|
10
|
+
execution.report
|
11
|
+
end
|
12
|
+
|
13
|
+
specify do
|
14
|
+
expect(report.data).to have_values_in_xlsx_sheet([
|
15
|
+
%w[name description],
|
16
|
+
[query.name, query.description]
|
17
|
+
])
|
18
|
+
end
|
19
|
+
|
20
|
+
specify do
|
21
|
+
expect(report.name).to match /#{query.name}\.[\d\-]+\.xlsx/
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require_relative 'dummy/config/environment'
|
3
|
+
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'factory_girl_rails'
|
6
|
+
|
7
|
+
require 'pry-byebug'
|
8
|
+
|
9
|
+
Rails.backtrace_cleaner.remove_silencers!
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.expect_with :rspec do |expectations|
|
14
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.mock_with :rspec do |mocks|
|
18
|
+
mocks.verify_partial_doubles = true
|
19
|
+
end
|
20
|
+
|
21
|
+
config.use_transactional_fixtures = true
|
22
|
+
config.filter_run :focus
|
23
|
+
config.run_all_when_everything_filtered = true
|
24
|
+
|
25
|
+
config.warnings = ENV['SHOW_WARNING']
|
26
|
+
|
27
|
+
if config.files_to_run.one?
|
28
|
+
config.default_formatter = 'doc'
|
29
|
+
end
|
30
|
+
|
31
|
+
config.profile_examples = 10
|
32
|
+
config.order = :random
|
33
|
+
|
34
|
+
config.include FactoryGirl::Syntax::Methods
|
35
|
+
Kernel.srand config.seed
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rspec/matchers'
|
2
|
+
require 'simple_xlsx_reader'
|
3
|
+
|
4
|
+
RSpec::Matchers.define :have_values_in_xlsx_sheet do |values|
|
5
|
+
match do |data|
|
6
|
+
expect(extract_values(data)).to eq values
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def extract_values(data)
|
12
|
+
Tempfile.open(%w[actual .xlsx], Dir.tmpdir, encoding: 'BINARY') do |f|
|
13
|
+
f.write data.read
|
14
|
+
f.flush
|
15
|
+
|
16
|
+
sheet = SimpleXlsxReader::Document.new(f.path).sheets.first
|
17
|
+
[sheet.headers, *sheet.data]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adhoq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyosuke MOROHASHI
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: axlsx
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coffee-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: font-awesome-sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jquery-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sass-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: slim-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: factory_girl_rails
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-rails
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simple_xlsx_reader
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sqlite3
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: tapp
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description: Rails engine to generate instant reports from adhoc SQL query.
|
196
|
+
email:
|
197
|
+
- moronatural@gmail.com
|
198
|
+
executables: []
|
199
|
+
extensions: []
|
200
|
+
extra_rdoc_files: []
|
201
|
+
files:
|
202
|
+
- LICENSE.txt
|
203
|
+
- README.md
|
204
|
+
- Rakefile
|
205
|
+
- app/assets/javascripts/adhoq/application.js
|
206
|
+
- app/assets/javascripts/adhoq/bootstrap-sprockets.js
|
207
|
+
- app/assets/javascripts/adhoq/bootstrap.js
|
208
|
+
- app/assets/javascripts/adhoq/bootstrap/affix.js
|
209
|
+
- app/assets/javascripts/adhoq/bootstrap/alert.js
|
210
|
+
- app/assets/javascripts/adhoq/bootstrap/button.js
|
211
|
+
- app/assets/javascripts/adhoq/bootstrap/carousel.js
|
212
|
+
- app/assets/javascripts/adhoq/bootstrap/collapse.js
|
213
|
+
- app/assets/javascripts/adhoq/bootstrap/dropdown.js
|
214
|
+
- app/assets/javascripts/adhoq/bootstrap/modal.js
|
215
|
+
- app/assets/javascripts/adhoq/bootstrap/popover.js
|
216
|
+
- app/assets/javascripts/adhoq/bootstrap/scrollspy.js
|
217
|
+
- app/assets/javascripts/adhoq/bootstrap/tab.js
|
218
|
+
- app/assets/javascripts/adhoq/bootstrap/tooltip.js
|
219
|
+
- app/assets/javascripts/adhoq/bootstrap/transition.js
|
220
|
+
- app/assets/javascripts/adhoq/previewer.js.coffee
|
221
|
+
- app/assets/stylesheets/adhoq/_bootstrap-compass.scss
|
222
|
+
- app/assets/stylesheets/adhoq/_bootstrap-mincer.scss
|
223
|
+
- app/assets/stylesheets/adhoq/_bootstrap-sprockets.scss
|
224
|
+
- app/assets/stylesheets/adhoq/adhoq.css.sass
|
225
|
+
- app/assets/stylesheets/adhoq/application.css
|
226
|
+
- app/assets/stylesheets/adhoq/bootstrap.scss
|
227
|
+
- app/assets/stylesheets/adhoq/bootstrap/_alerts.scss
|
228
|
+
- app/assets/stylesheets/adhoq/bootstrap/_badges.scss
|
229
|
+
- app/assets/stylesheets/adhoq/bootstrap/_breadcrumbs.scss
|
230
|
+
- app/assets/stylesheets/adhoq/bootstrap/_button-groups.scss
|
231
|
+
- app/assets/stylesheets/adhoq/bootstrap/_buttons.scss
|
232
|
+
- app/assets/stylesheets/adhoq/bootstrap/_carousel.scss
|
233
|
+
- app/assets/stylesheets/adhoq/bootstrap/_close.scss
|
234
|
+
- app/assets/stylesheets/adhoq/bootstrap/_code.scss
|
235
|
+
- app/assets/stylesheets/adhoq/bootstrap/_component-animations.scss
|
236
|
+
- app/assets/stylesheets/adhoq/bootstrap/_dropdowns.scss
|
237
|
+
- app/assets/stylesheets/adhoq/bootstrap/_forms.scss
|
238
|
+
- app/assets/stylesheets/adhoq/bootstrap/_glyphicons.scss
|
239
|
+
- app/assets/stylesheets/adhoq/bootstrap/_grid.scss
|
240
|
+
- app/assets/stylesheets/adhoq/bootstrap/_input-groups.scss
|
241
|
+
- app/assets/stylesheets/adhoq/bootstrap/_jumbotron.scss
|
242
|
+
- app/assets/stylesheets/adhoq/bootstrap/_labels.scss
|
243
|
+
- app/assets/stylesheets/adhoq/bootstrap/_list-group.scss
|
244
|
+
- app/assets/stylesheets/adhoq/bootstrap/_media.scss
|
245
|
+
- app/assets/stylesheets/adhoq/bootstrap/_mixins.scss
|
246
|
+
- app/assets/stylesheets/adhoq/bootstrap/_modals.scss
|
247
|
+
- app/assets/stylesheets/adhoq/bootstrap/_navbar.scss
|
248
|
+
- app/assets/stylesheets/adhoq/bootstrap/_navs.scss
|
249
|
+
- app/assets/stylesheets/adhoq/bootstrap/_normalize.scss
|
250
|
+
- app/assets/stylesheets/adhoq/bootstrap/_pager.scss
|
251
|
+
- app/assets/stylesheets/adhoq/bootstrap/_pagination.scss
|
252
|
+
- app/assets/stylesheets/adhoq/bootstrap/_panels.scss
|
253
|
+
- app/assets/stylesheets/adhoq/bootstrap/_popovers.scss
|
254
|
+
- app/assets/stylesheets/adhoq/bootstrap/_print.scss
|
255
|
+
- app/assets/stylesheets/adhoq/bootstrap/_progress-bars.scss
|
256
|
+
- app/assets/stylesheets/adhoq/bootstrap/_responsive-embed.scss
|
257
|
+
- app/assets/stylesheets/adhoq/bootstrap/_responsive-utilities.scss
|
258
|
+
- app/assets/stylesheets/adhoq/bootstrap/_scaffolding.scss
|
259
|
+
- app/assets/stylesheets/adhoq/bootstrap/_tables.scss
|
260
|
+
- app/assets/stylesheets/adhoq/bootstrap/_theme.scss
|
261
|
+
- app/assets/stylesheets/adhoq/bootstrap/_thumbnails.scss
|
262
|
+
- app/assets/stylesheets/adhoq/bootstrap/_tooltip.scss
|
263
|
+
- app/assets/stylesheets/adhoq/bootstrap/_type.scss
|
264
|
+
- app/assets/stylesheets/adhoq/bootstrap/_utilities.scss
|
265
|
+
- app/assets/stylesheets/adhoq/bootstrap/_variables.scss
|
266
|
+
- app/assets/stylesheets/adhoq/bootstrap/_wells.scss
|
267
|
+
- app/assets/stylesheets/adhoq/bootstrap/bootstrap.scss
|
268
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_alerts.scss
|
269
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_background-variant.scss
|
270
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_border-radius.scss
|
271
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_buttons.scss
|
272
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_center-block.scss
|
273
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_clearfix.scss
|
274
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_forms.scss
|
275
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_gradients.scss
|
276
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_grid-framework.scss
|
277
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_grid.scss
|
278
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_hide-text.scss
|
279
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_image.scss
|
280
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_labels.scss
|
281
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_list-group.scss
|
282
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_nav-divider.scss
|
283
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_nav-vertical-align.scss
|
284
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_opacity.scss
|
285
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_pagination.scss
|
286
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_panels.scss
|
287
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_progress-bar.scss
|
288
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_reset-filter.scss
|
289
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_resize.scss
|
290
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_responsive-visibility.scss
|
291
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_size.scss
|
292
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_tab-focus.scss
|
293
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_table-row.scss
|
294
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_text-emphasis.scss
|
295
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_text-overflow.scss
|
296
|
+
- app/assets/stylesheets/adhoq/bootstrap/mixins/_vendor-prefixes.scss
|
297
|
+
- app/controllers/adhoq/application_controller.rb
|
298
|
+
- app/controllers/adhoq/authorization_methods.rb
|
299
|
+
- app/controllers/adhoq/executions_controller.rb
|
300
|
+
- app/controllers/adhoq/previews_controller.rb
|
301
|
+
- app/controllers/adhoq/queries_controller.rb
|
302
|
+
- app/helpers/adhoq/application_helper.rb
|
303
|
+
- app/models/adhoq/execution.rb
|
304
|
+
- app/models/adhoq/query.rb
|
305
|
+
- app/models/adhoq/report.rb
|
306
|
+
- app/models/adhoq/time_based_orders.rb
|
307
|
+
- app/views/adhoq/application/_global_nav.html.slim
|
308
|
+
- app/views/adhoq/application/_sidebar_queries_index.html.slim
|
309
|
+
- app/views/adhoq/previews/create.html.slim
|
310
|
+
- app/views/adhoq/previews/statement_invalid.html.slim
|
311
|
+
- app/views/adhoq/queries/_form.html.slim
|
312
|
+
- app/views/adhoq/queries/_query.html.slim
|
313
|
+
- app/views/adhoq/queries/edit.html.slim
|
314
|
+
- app/views/adhoq/queries/index.html.slim
|
315
|
+
- app/views/adhoq/queries/new.html.slim
|
316
|
+
- app/views/adhoq/queries/show.html.slim
|
317
|
+
- app/views/layouts/adhoq/application.html.slim
|
318
|
+
- config/routes.rb
|
319
|
+
- db/migrate/20141003095645_create_adhoq_queries.rb
|
320
|
+
- db/migrate/20141006014750_create_adhoq_executions.rb
|
321
|
+
- db/migrate/20141007052308_create_adhoq_reports.rb
|
322
|
+
- lib/adhoq.rb
|
323
|
+
- lib/adhoq/configuration.rb
|
324
|
+
- lib/adhoq/engine.rb
|
325
|
+
- lib/adhoq/error.rb
|
326
|
+
- lib/adhoq/executor.rb
|
327
|
+
- lib/adhoq/global_variable.rb
|
328
|
+
- lib/adhoq/reporter.rb
|
329
|
+
- lib/adhoq/reporter/xlsx.rb
|
330
|
+
- lib/adhoq/result.rb
|
331
|
+
- lib/adhoq/storage.rb
|
332
|
+
- lib/adhoq/storage/local_file.rb
|
333
|
+
- lib/adhoq/version.rb
|
334
|
+
- lib/tasks/adhoq_tasks.rake
|
335
|
+
- spec/adhoq/executor_spec.rb
|
336
|
+
- spec/adhoq/storage_spec.rb
|
337
|
+
- spec/factories/adhoq_queries.rb
|
338
|
+
- spec/models/adhoq/execution_spec.rb
|
339
|
+
- spec/models/adhoq/query_spec.rb
|
340
|
+
- spec/models/adhoq/report_spec.rb
|
341
|
+
- spec/spec_helper.rb
|
342
|
+
- spec/support/have_values_in_xlsx_sheet_matcher.rb
|
343
|
+
homepage: https://github.com/esminc/adhoq
|
344
|
+
licenses:
|
345
|
+
- MIT
|
346
|
+
metadata: {}
|
347
|
+
post_install_message:
|
348
|
+
rdoc_options: []
|
349
|
+
require_paths:
|
350
|
+
- lib
|
351
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
352
|
+
requirements:
|
353
|
+
- - ">="
|
354
|
+
- !ruby/object:Gem::Version
|
355
|
+
version: '0'
|
356
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
357
|
+
requirements:
|
358
|
+
- - ">="
|
359
|
+
- !ruby/object:Gem::Version
|
360
|
+
version: '0'
|
361
|
+
requirements: []
|
362
|
+
rubyforge_project:
|
363
|
+
rubygems_version: 2.2.2
|
364
|
+
signing_key:
|
365
|
+
specification_version: 4
|
366
|
+
summary: DB management console in the wild.
|
367
|
+
test_files:
|
368
|
+
- spec/adhoq/executor_spec.rb
|
369
|
+
- spec/adhoq/storage_spec.rb
|
370
|
+
- spec/factories/adhoq_queries.rb
|
371
|
+
- spec/models/adhoq/execution_spec.rb
|
372
|
+
- spec/models/adhoq/query_spec.rb
|
373
|
+
- spec/models/adhoq/report_spec.rb
|
374
|
+
- spec/support/have_values_in_xlsx_sheet_matcher.rb
|
375
|
+
- spec/spec_helper.rb
|