aquel-sequel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e0bd3f4523911841ec7b3dba2c05bce7503757d9
4
+ data.tar.gz: 9bb7f05c2bcc2151ca89fe05bdfcc64eb76a7ac2
5
+ SHA512:
6
+ metadata.gz: 7c3bb082840437027b296d391407584177cada71cf776936bbe0d41bfc89bdfb7412e55756f83a5676e79b6b14a4eff4c38303ebdb1c0ca16b3bb51fb14a8660
7
+ data.tar.gz: 225326e53efea8ce27ba9ffc66cc6ae03f98494d7330ccdbd8160f2eabb897f1a8f5dcc861533fc406cefe6dfde9826afdd27c9f91019e2081d78287b8b57ff5
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aquel-sequel.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 youpy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # aquel-sequel [![Build Status](https://travis-ci.org/youpy/aquel-sequel.svg)](https://travis-ci.org/youpy/aquel-sequel)
2
+
3
+ A Sequel adapter for aquel
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'aquel-sequel'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install aquel-sequel
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'aquel/sequel'
25
+
26
+ aquel = Aquel.define 'tsv' do
27
+ has_header
28
+
29
+ document do |attributes|
30
+ open(attributes['path'])
31
+ end
32
+
33
+ item do |document|
34
+ document.gets
35
+ end
36
+
37
+ split do |item|
38
+ item.chomp.split(/\t/)
39
+ end
40
+ end
41
+
42
+ DB = Sequel.connect('aquel:///', :database => aquel)
43
+ ```
44
+
45
+ ```ruby
46
+ items = DB.select(:col1, :col3).from('tsv').where(path: tsv_path).exclude(col1: 'foo1').all
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/[my-github-username]/aquel-sequel/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec) do |spec|
5
+ spec.pattern = FileList['spec/**/*_spec.rb']
6
+ end
7
+
8
+ task :default => :spec
9
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aquel/sequel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aquel-sequel"
8
+ spec.version = Aquel::Sequel::VERSION
9
+ spec.authors = ["youpy"]
10
+ spec.email = ["youpy@buycheapviagraonlinenow.com"]
11
+ spec.summary = %q{Sequel adapter for aquel}
12
+ spec.homepage = "https://github.com/youpy/aquel-sequel"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "sequel"
21
+ spec.add_dependency "aquel"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
@@ -0,0 +1,44 @@
1
+ require 'sequel'
2
+ require 'aquel'
3
+
4
+ module Sequel
5
+ module Aquel
6
+ class Database < Sequel::Database
7
+ set_adapter_scheme :aquel
8
+
9
+ def connect(server)
10
+ opts = server_opts(server)
11
+ opts[:database]
12
+ end
13
+
14
+ def disconnect_connection(c)
15
+ end
16
+
17
+ def execute(sql, opts=OPTS)
18
+ synchronize(opts[:server]) do |conn|
19
+ r = log_yield(sql){conn.execute(sql)}
20
+ yield(r) if block_given?
21
+ r
22
+ end
23
+ end
24
+
25
+ def identifier_input_method_default; nil; end
26
+ def identifier_output_method_default; nil; end
27
+ end
28
+
29
+ class Dataset < Sequel::Dataset
30
+ def_sql_method(self, :select, %w'select columns from where')
31
+
32
+ Database::DatasetClass = self
33
+
34
+ def fetch_rows(sql)
35
+ execute(sql) do |result|
36
+ result.each do |row|
37
+ yield row
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Aquel
2
+ module Sequel
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Aquel::Sequel do
4
+ describe 'TSV parser' do
5
+ let(:tsv_path) {
6
+ File.dirname(__FILE__) + '/../test.tsv'
7
+ }
8
+
9
+ let(:aquel) {
10
+ Aquel.define 'tsv' do
11
+ has_header
12
+
13
+ document do |attributes|
14
+ open(attributes['path'])
15
+ end
16
+
17
+ item do |document|
18
+ document.gets
19
+ end
20
+
21
+ split do |item|
22
+ item.chomp.split(/\t/)
23
+ end
24
+ end
25
+ }
26
+
27
+ let(:db) {
28
+ Sequel.connect('aquel:///', :database => aquel)
29
+ }
30
+
31
+ context 'simple query' do
32
+ it 'finds matching line' do
33
+ items = db.from('tsv').where(path: tsv_path).all
34
+
35
+ expect(items.size).to eql(2)
36
+ expect(items.first).to eql({"col1"=>"foo1", "col2"=>"bar1", "col3"=>"baz1"})
37
+
38
+ items = db.select(:col1, :col3).from('tsv').where(path: tsv_path).all
39
+
40
+ expect(items.size).to eql(2)
41
+ expect(items.first).to eql({"col1"=>"foo1", "col3"=>"baz1"})
42
+ end
43
+ end
44
+
45
+ context 'filter query' do
46
+ it 'finds matching line' do
47
+ items = db.from('tsv').where(path: tsv_path).where(col1: 'foo2').all
48
+
49
+ expect(items.size).to eql(1)
50
+ expect(items.first).to eql({"col1"=>"foo2", "col2"=>"bar2", "col3"=>"baz2"})
51
+
52
+ items = db.select(:col1, :col3).from('tsv').where(path: tsv_path).where(col1: 'foo1').all
53
+
54
+ expect(items.size).to eql(1)
55
+ expect(items.first).to eql({"col1"=>"foo1", "col3"=>"baz1"})
56
+
57
+ items = db.select(:col1, :col3).from('tsv').where(path: tsv_path).exclude(col1: 'foo1').all
58
+
59
+ expect(items.size).to eql(1)
60
+ expect(items.first).to eql({"col1"=>"foo2", "col3"=>"baz2"})
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,93 @@
1
+ require 'aquel/sequel'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is
56
+ # recommended. For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # This setting enables warnings. It's recommended, but in some cases may
63
+ # be too noisy due to issues in dependencies.
64
+ config.warnings = true
65
+
66
+ # Many RSpec users commonly either run the entire suite or an individual
67
+ # file, and it's useful to allow more verbose output when running an
68
+ # individual spec file.
69
+ if config.files_to_run.one?
70
+ # Use the documentation formatter for detailed output,
71
+ # unless a formatter has already been configured
72
+ # (e.g. via a command-line flag).
73
+ config.default_formatter = 'doc'
74
+ end
75
+
76
+ # Print the 10 slowest examples and example groups at the
77
+ # end of the spec run, to help surface which specs are running
78
+ # particularly slow.
79
+ config.profile_examples = 10
80
+
81
+ # Run specs in random order to surface order dependencies. If you find an
82
+ # order dependency and want to debug it, you can fix the order by providing
83
+ # the seed, which is printed after each run.
84
+ # --seed 1234
85
+ config.order = :random
86
+
87
+ # Seed global randomization in this process using the `--seed` CLI option.
88
+ # Setting this allows you to use `--seed` to deterministically reproduce
89
+ # test failures related to randomization by passing the same `--seed` value
90
+ # as the one that triggered the failure.
91
+ Kernel.srand config.seed
92
+ =end
93
+ end
@@ -0,0 +1,3 @@
1
+ COL1 COL2 COL3
2
+ foo1 bar1 baz1
3
+ foo2 bar2 baz2
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aquel-sequel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - youpy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sequel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aquel
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - youpy@buycheapviagraonlinenow.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - aquel-sequel.gemspec
97
+ - lib/aquel/sequel.rb
98
+ - lib/aquel/sequel/version.rb
99
+ - spec/aquel/sequel_spec.rb
100
+ - spec/spec_helper.rb
101
+ - spec/test.tsv
102
+ homepage: https://github.com/youpy/aquel-sequel
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.0.rc.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Sequel adapter for aquel
126
+ test_files:
127
+ - spec/aquel/sequel_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/test.tsv