axiom-do-adapter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +37 -0
  5. data/.rspec +4 -0
  6. data/.rvmrc +1 -0
  7. data/.travis.yml +35 -0
  8. data/CONTRIBUTING.md +11 -0
  9. data/Gemfile +10 -0
  10. data/Gemfile.devtools +57 -0
  11. data/Guardfile +23 -0
  12. data/LICENSE +20 -0
  13. data/README.md +26 -0
  14. data/Rakefile +5 -0
  15. data/TODO +0 -0
  16. data/axiom-do-adapter.gemspec +27 -0
  17. data/config/flay.yml +3 -0
  18. data/config/flog.yml +2 -0
  19. data/config/mutant.yml +3 -0
  20. data/config/reek.yml +115 -0
  21. data/config/yardstick.yml +2 -0
  22. data/lib/axiom-do-adapter.rb +4 -0
  23. data/lib/axiom/adapter/data_objects.rb +55 -0
  24. data/lib/axiom/adapter/data_objects/statement.rb +109 -0
  25. data/lib/axiom/adapter/data_objects/version.rb +12 -0
  26. data/lib/axiom/relation/gateway.rb +374 -0
  27. data/spec/rcov.opts +7 -0
  28. data/spec/shared/binary_relation_method_behaviour.rb +51 -0
  29. data/spec/shared/unary_relation_method_behaviour.rb +21 -0
  30. data/spec/spec_helper.rb +46 -0
  31. data/spec/support/config_alias.rb +3 -0
  32. data/spec/support/example_group_methods.rb +7 -0
  33. data/spec/support/ice_nine_config.rb +6 -0
  34. data/spec/unit/axiom/adapter/data_objects/class_methods/new_spec.rb +15 -0
  35. data/spec/unit/axiom/adapter/data_objects/read_spec.rb +66 -0
  36. data/spec/unit/axiom/adapter/data_objects/statement/class_methods/new_spec.rb +28 -0
  37. data/spec/unit/axiom/adapter/data_objects/statement/each_spec.rb +63 -0
  38. data/spec/unit/axiom/adapter/data_objects/statement/to_s_spec.rb +53 -0
  39. data/spec/unit/axiom/relation/gateway/class_methods/new_spec.rb +16 -0
  40. data/spec/unit/axiom/relation/gateway/difference_spec.rb +17 -0
  41. data/spec/unit/axiom/relation/gateway/drop_spec.rb +21 -0
  42. data/spec/unit/axiom/relation/gateway/each_spec.rb +86 -0
  43. data/spec/unit/axiom/relation/gateway/extend_spec.rb +29 -0
  44. data/spec/unit/axiom/relation/gateway/intersect_spec.rb +17 -0
  45. data/spec/unit/axiom/relation/gateway/join_spec.rb +44 -0
  46. data/spec/unit/axiom/relation/gateway/materialize_spec.rb +27 -0
  47. data/spec/unit/axiom/relation/gateway/optimize_spec.rb +23 -0
  48. data/spec/unit/axiom/relation/gateway/product_spec.rb +17 -0
  49. data/spec/unit/axiom/relation/gateway/project_spec.rb +21 -0
  50. data/spec/unit/axiom/relation/gateway/remove_spec.rb +21 -0
  51. data/spec/unit/axiom/relation/gateway/rename_spec.rb +21 -0
  52. data/spec/unit/axiom/relation/gateway/respond_to_spec.rb +29 -0
  53. data/spec/unit/axiom/relation/gateway/restrict_spec.rb +29 -0
  54. data/spec/unit/axiom/relation/gateway/reverse_spec.rb +21 -0
  55. data/spec/unit/axiom/relation/gateway/sort_by_spec.rb +29 -0
  56. data/spec/unit/axiom/relation/gateway/summarize_spec.rb +154 -0
  57. data/spec/unit/axiom/relation/gateway/take_spec.rb +21 -0
  58. data/spec/unit/axiom/relation/gateway/union_spec.rb +17 -0
  59. metadata +214 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed1710fbd739ac85f9d3b0df14915062a10b88ed
4
+ data.tar.gz: 228074550829123b935ab2daf643d0fc79896bd3
5
+ SHA512:
6
+ metadata.gz: ec7449b950c3f710b2718d3ead6275b86529fdc372e3db25ab02c89ef701cb07f050fa81a85f0342d7fe0610b31891612a5ad472baab9c3dfc2e6dea16802f09
7
+ data.tar.gz: ed431cca2abaa3126f61726686a788775c11c1752dc0c127332338da9b518b92487cc15c52a7fdbf7bb8a9a5c5e0623457cc13287cac3ef7038af33fbff6ab5d
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## Rubinius
17
+ *.rbc
18
+ .rbx
19
+
20
+ ## PROJECT::GENERAL
21
+ *.gem
22
+ coverage
23
+ profiling
24
+ turbulence
25
+ rdoc
26
+ pkg
27
+ tmp
28
+ doc
29
+ log
30
+ .yardoc
31
+ measurements
32
+
33
+ ## BUNDLER
34
+ .bundle
35
+ Gemfile.lock
36
+
37
+ ## PROJECT::SPECIFIC
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format progress
3
+ --profile
4
+ --order random
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @$(basename `pwd`) --create
data/.travis.yml ADDED
@@ -0,0 +1,35 @@
1
+ language: ruby
2
+ before_install: gem install bundler
3
+ bundler_args: --without yard guard benchmarks
4
+ script: "bundle exec rake ci"
5
+ rvm:
6
+ - ree
7
+ - 1.8.7
8
+ - 1.9.2
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - ruby-head
12
+ - rbx-18mode
13
+ - rbx-19mode
14
+ - jruby-18mode
15
+ notifications:
16
+ irc:
17
+ channels:
18
+ - irc.freenode.org#datamapper
19
+ on_success: never
20
+ on_failure: change
21
+ email:
22
+ recipients:
23
+ - dan.kubb@gmail.com
24
+ on_success: never
25
+ on_failure: change
26
+ matrix:
27
+ include:
28
+ - rvm: jruby-19mode
29
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
30
+ - rvm: jruby-head
31
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
32
+ allow_failures:
33
+ # mutant fails
34
+ - rvm: 1.9.3
35
+ - rvm: rbx-19mode
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,11 @@
1
+ Contributing
2
+ ------------
3
+
4
+ * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin.
5
+ * Fork the project.
6
+ * Make your feature addition or bug fix.
7
+ * Follow this [style guide](https://github.com/dkubb/styleguide).
8
+ * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
9
+ * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
10
+ * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
11
+ * Send me a pull request. Bonus points for topic branches.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'data_objects', '~> 0.10.12', :git => 'https://github.com/datamapper/do.git'
6
+ gem 'axiom', '~> 0.1.0', :git => 'https://github.com/dkubb/axiom.git'
7
+ gem 'axiom-sql-generator', '~> 0.1.0', :git => 'https://github.com/dkubb/axiom-sql-generator.git'
8
+
9
+ gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
10
+ eval File.read('Gemfile.devtools')
data/Gemfile.devtools ADDED
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ group :development do
4
+ gem 'rake', '~> 10.0.4'
5
+ gem 'rspec', '~> 2.13.0'
6
+ gem 'yard', '~> 0.8.5.2'
7
+ end
8
+
9
+ group :yard do
10
+ gem 'kramdown', '~> 1.0.1'
11
+ end
12
+
13
+ group :guard do
14
+ gem 'guard', '~> 1.7.0'
15
+ gem 'guard-bundler', '~> 1.0.0'
16
+ gem 'guard-rspec', '~> 2.5.2'
17
+
18
+ # file system change event handling
19
+ gem 'listen', '~> 0.7.3'
20
+ gem 'rb-fchange', '~> 0.0.6', :require => false
21
+ gem 'rb-fsevent', '~> 0.9.3', :require => false
22
+ gem 'rb-inotify', '~> 0.9.0', :require => false
23
+
24
+ # notification handling
25
+ gem 'libnotify', '~> 0.8.0', :require => false
26
+ gem 'rb-notifu', '~> 0.0.4', :require => false
27
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
28
+ end
29
+
30
+ group :metrics do
31
+ gem 'backports', '~> 3.3', '>= 3.3.0'
32
+ gem 'coveralls', '~> 0.6.4'
33
+ gem 'flay', '~> 2.1.0'
34
+ gem 'flog', '~> 3.2.3'
35
+ gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
36
+ gem 'simplecov', '~> 0.7.1'
37
+ gem 'yardstick', '~> 0.9.5'
38
+ gem 'yard-spellcheck', '~> 0.1.5'
39
+
40
+ platforms :mri_19, :rbx do
41
+ gem 'mutant', '~> 0.2.20'
42
+ end
43
+
44
+ platforms :rbx do
45
+ gem 'pelusa', '~> 0.2.2'
46
+ end
47
+ end
48
+
49
+ group :benchmarks do
50
+ gem 'rbench', '~> 0.2.3'
51
+ end
52
+
53
+ platform :jruby do
54
+ group :jruby do
55
+ gem 'jruby-openssl', '~> 0.8.5'
56
+ end
57
+ end
data/Guardfile ADDED
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ guard :bundler do
4
+ watch('Gemfile')
5
+ end
6
+
7
+ guard :rspec, :cli => File.read('.rspec').split.join(' '), :keep_failed => false do
8
+ # run all specs if configuration is modified
9
+ watch('Guardfile') { 'spec' }
10
+ watch('Gemfile.lock') { 'spec' }
11
+ watch('spec/spec_helper.rb') { 'spec' }
12
+
13
+ # run all specs if supporting files files are modified
14
+ watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
15
+
16
+ # run unit specs if associated lib code is modified
17
+ watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
18
+ watch(%r{\Alib/(.+)/support/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}/#{m[2]}"] }
19
+ watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
20
+
21
+ # run a spec if it is modified
22
+ watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
23
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2013 Dan Kubb
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ axiom-do-adapter
2
+ ================
3
+
4
+ Use Axiom relations with an SQL based RDBMS
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/axiom-do-adapter.png)][gem]
7
+ [![Build Status](https://secure.travis-ci.org/dkubb/axiom-do-adapter.png?branch=master)][travis]
8
+ [![Dependency Status](https://gemnasium.com/dkubb/axiom-do-adapter.png)][gemnasium]
9
+ [![Code Climate](https://codeclimate.com/github/dkubb/axiom-do-adapter.png)][codeclimate]
10
+ [![Coverage Status](https://coveralls.io/repos/dkubb/axiom-do-adapter/badge.png?branch=master)][coveralls]
11
+
12
+ [gem]: https://rubygems.org/gems/axiom-do-adapter
13
+ [travis]: https://travis-ci.org/dkubb/axiom-do-adapter
14
+ [gemnasium]: https://gemnasium.com/dkubb/axiom-do-adapter
15
+ [codeclimate]: https://codeclimate.com/github/dkubb/axiom-do-adapter
16
+ [coveralls]: https://coveralls.io/r/dkubb/axiom-do-adapter
17
+
18
+ Contributing
19
+ ------------
20
+
21
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
22
+
23
+ Copyright
24
+ ---------
25
+
26
+ Copyright © 2011-2013 Dan Kubb. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ require 'devtools'
4
+
5
+ Devtools.init_rake_tasks
data/TODO ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../lib/axiom/adapter/data_objects/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'axiom-do-adapter'
7
+ gem.version = Axiom::Adapter::DataObjects::VERSION.dup
8
+ gem.authors = ['Dan Kubb']
9
+ gem.email = 'dan.kubb@gmail.com'
10
+ gem.description = 'Use Axiom relations with an RDBMS'
11
+ gem.summary = 'Vertias DataObjects adapter'
12
+ gem.homepage = 'https://github.com/dkubb/axiom-do-adapter'
13
+ gem.licenses = %w[MIT]
14
+
15
+ gem.require_paths = %w[lib]
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
18
+ gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
19
+
20
+ gem.add_runtime_dependency('data_objects', '~> 0.10.12')
21
+ gem.add_runtime_dependency('axiom', '~> 0.1.0')
22
+ gem.add_runtime_dependency('axiom-sql-generator', '~> 0.1.0')
23
+
24
+ gem.add_development_dependency('rake', '~> 10.0.4')
25
+ gem.add_development_dependency('rspec', '~> 2.13.0')
26
+ gem.add_development_dependency('yard', '~> 0.8.5.2')
27
+ end
data/config/flay.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ threshold: 8
3
+ total_score: 55
data/config/flog.yml ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 10.9
data/config/mutant.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ name: axiom-do-adapter
3
+ namespace: Axiom::Adapter::DataObjects
data/config/reek.yml ADDED
@@ -0,0 +1,115 @@
1
+ ---
2
+ Attribute:
3
+ enabled: true
4
+ exclude:
5
+ - Axiom::Relation::Gateway
6
+ BooleanParameter:
7
+ enabled: true
8
+ exclude: []
9
+ ClassVariable:
10
+ enabled: true
11
+ exclude: []
12
+ ControlParameter:
13
+ enabled: true
14
+ exclude: []
15
+ DataClump:
16
+ enabled: true
17
+ exclude: []
18
+ max_copies: 2
19
+ min_clump_size: 2
20
+ DuplicateMethodCall:
21
+ enabled: true
22
+ exclude: []
23
+ max_calls: 1
24
+ allow_calls: []
25
+ FeatureEnvy:
26
+ enabled: true
27
+ exclude:
28
+ - Axiom::Adapter::DataObjects::Statement#each_row
29
+ - Axiom::Relation::Gateway#gateway?
30
+ - Axiom::Relation::Gateway#summarize_merge?
31
+ IrresponsibleModule:
32
+ enabled: true
33
+ exclude:
34
+ - Axiom::Relation
35
+ LongParameterList:
36
+ enabled: true
37
+ exclude:
38
+ - Axiom::Relation::Gateway#binary_operation
39
+ max_params: 2
40
+ overrides:
41
+ initialize:
42
+ max_params: 3
43
+ LongYieldList:
44
+ enabled: true
45
+ exclude: []
46
+ max_params: 2
47
+ NestedIterators:
48
+ enabled: true
49
+ exclude: []
50
+ max_allowed_nesting: 1
51
+ ignore_iterators: []
52
+ NilCheck:
53
+ enabled: true
54
+ exclude: []
55
+ RepeatedConditional:
56
+ enabled: true
57
+ exclude: []
58
+ max_ifs: 1
59
+ TooManyInstanceVariables:
60
+ enabled: true
61
+ exclude: []
62
+ max_instance_variables: 3
63
+ TooManyMethods:
64
+ enabled: true
65
+ exclude:
66
+ - Axiom::Relation::Gateway
67
+ max_methods: 10
68
+ TooManyStatements:
69
+ enabled: true
70
+ exclude:
71
+ - Axiom::Adapter::DataObjects#read
72
+ - Axiom::Adapter::DataObjects::Statement#command
73
+ - Axiom::Relation::Gateway#forward
74
+ - Axiom::Relation::Gateway#tuples
75
+ - each
76
+ max_statements: 2
77
+ UncommunicativeMethodName:
78
+ enabled: true
79
+ exclude: []
80
+ reject:
81
+ - !ruby/regexp /^[a-z]$/
82
+ - !ruby/regexp /[0-9]$/
83
+ - !ruby/regexp /[A-Z]/
84
+ accept: []
85
+ UncommunicativeModuleName:
86
+ enabled: true
87
+ exclude: []
88
+ reject:
89
+ - !ruby/regexp /^.$/
90
+ - !ruby/regexp /[0-9]$/
91
+ accept: []
92
+ UncommunicativeParameterName:
93
+ enabled: true
94
+ exclude: []
95
+ reject:
96
+ - !ruby/regexp /^.$/
97
+ - !ruby/regexp /[0-9]$/
98
+ - !ruby/regexp /[A-Z]/
99
+ accept: []
100
+ UncommunicativeVariableName:
101
+ enabled: true
102
+ exclude: []
103
+ reject:
104
+ - !ruby/regexp /^.$/
105
+ - !ruby/regexp /[0-9]$/
106
+ - !ruby/regexp /[A-Z]/
107
+ accept: []
108
+ UnusedParameters:
109
+ enabled: true
110
+ exclude: []
111
+ UtilityFunction:
112
+ enabled: true
113
+ exclude:
114
+ - Axiom::Relation::Gateway#gateway?
115
+ max_helper_calls: 0
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 100
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ require 'axiom/adapter/data_objects'
4
+ require 'axiom/relation/gateway'
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'axiom'
4
+ require 'axiom-sql-generator'
5
+ require 'data_objects'
6
+
7
+ module Axiom
8
+ module Adapter
9
+
10
+ # An adapter wrapping a DataObjects connection
11
+ class DataObjects
12
+ include Adamantium
13
+
14
+ # Initialize a DataObjects adapter
15
+ #
16
+ # @param [String] uri
17
+ #
18
+ # @return [undefined]
19
+ #
20
+ # @api private
21
+ def initialize(uri)
22
+ @uri = uri
23
+ end
24
+
25
+ # Read the results from the SQL representation of the relation
26
+ #
27
+ # @example
28
+ # adapter.read(relation) { |row| ... }
29
+ #
30
+ # @param [Relation] relation
31
+ #
32
+ # @yield [row]
33
+ #
34
+ # @yieldparam [Array] row
35
+ # each row in the results
36
+ #
37
+ # @return [self]
38
+ #
39
+ # @api public
40
+ def read(relation)
41
+ return to_enum(__method__, relation) unless block_given?
42
+ connection = ::DataObjects::Connection.new(@uri)
43
+ Statement.new(connection, relation).each { |row| yield row }
44
+ self
45
+ ensure
46
+ connection.close if connection
47
+ end
48
+
49
+ end # class DataObjects
50
+ end # module Adapter
51
+ end # module Axiom
52
+
53
+ require 'axiom/adapter/data_objects/version'
54
+
55
+ require 'axiom/adapter/data_objects/statement'