axiom-do-adapter 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-gemset +1 -0
  4. data/.travis.yml +17 -23
  5. data/CONTRIBUTING.md +1 -2
  6. data/Gemfile +10 -5
  7. data/Gemfile.devtools +39 -27
  8. data/README.md +3 -6
  9. data/axiom-do-adapter.gemspec +5 -7
  10. data/config/devtools.yml +2 -0
  11. data/config/reek.yml +2 -7
  12. data/config/rubocop.yml +59 -0
  13. data/lib/axiom/adapter/data_objects/statement.rb +4 -7
  14. data/lib/axiom/adapter/data_objects/version.rb +1 -1
  15. data/lib/axiom/relation/gateway.rb +3 -3
  16. data/spec/shared/binary_relation_method_behaviour.rb +11 -11
  17. data/spec/shared/unary_relation_method_behaviour.rb +4 -4
  18. data/spec/spec_helper.rb +13 -18
  19. data/spec/support/config_alias.rb +2 -0
  20. data/spec/unit/axiom/adapter/data_objects/class_methods/new_spec.rb +1 -1
  21. data/spec/unit/axiom/adapter/data_objects/read_spec.rb +14 -18
  22. data/spec/unit/axiom/adapter/data_objects/statement/class_methods/new_spec.rb +3 -3
  23. data/spec/unit/axiom/adapter/data_objects/statement/each_spec.rb +23 -24
  24. data/spec/unit/axiom/adapter/data_objects/statement/to_s_spec.rb +9 -9
  25. data/spec/unit/axiom/relation/gateway/class_methods/new_spec.rb +2 -2
  26. data/spec/unit/axiom/relation/gateway/difference_spec.rb +3 -3
  27. data/spec/unit/axiom/relation/gateway/drop_spec.rb +6 -6
  28. data/spec/unit/axiom/relation/gateway/each_spec.rb +19 -23
  29. data/spec/unit/axiom/relation/gateway/extend_spec.rb +10 -12
  30. data/spec/unit/axiom/relation/gateway/intersect_spec.rb +3 -3
  31. data/spec/unit/axiom/relation/gateway/join_spec.rb +11 -11
  32. data/spec/unit/axiom/relation/gateway/materialize_spec.rb +9 -9
  33. data/spec/unit/axiom/relation/gateway/optimize_spec.rb +4 -4
  34. data/spec/unit/axiom/relation/gateway/product_spec.rb +3 -3
  35. data/spec/unit/axiom/relation/gateway/project_spec.rb +6 -6
  36. data/spec/unit/axiom/relation/gateway/remove_spec.rb +6 -6
  37. data/spec/unit/axiom/relation/gateway/rename_spec.rb +6 -6
  38. data/spec/unit/axiom/relation/gateway/respond_to_spec.rb +2 -2
  39. data/spec/unit/axiom/relation/gateway/restrict_spec.rb +10 -12
  40. data/spec/unit/axiom/relation/gateway/reverse_spec.rb +6 -6
  41. data/spec/unit/axiom/relation/gateway/sort_by_spec.rb +10 -12
  42. data/spec/unit/axiom/relation/gateway/summarize_spec.rb +48 -54
  43. data/spec/unit/axiom/relation/gateway/take_spec.rb +6 -6
  44. data/spec/unit/axiom/relation/gateway/union_spec.rb +3 -3
  45. metadata +23 -44
  46. data/.rvmrc +0 -1
  47. data/spec/support/example_group_methods.rb +0 -7
  48. data/spec/support/ice_nine_config.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed1710fbd739ac85f9d3b0df14915062a10b88ed
4
- data.tar.gz: 228074550829123b935ab2daf643d0fc79896bd3
3
+ metadata.gz: 270901849bbfcdf472e90a23f7af192de8066de4
4
+ data.tar.gz: 8b92a29aaeaddae594887efe1d6c917fe10b6c1a
5
5
  SHA512:
6
- metadata.gz: ec7449b950c3f710b2718d3ead6275b86529fdc372e3db25ab02c89ef701cb07f050fa81a85f0342d7fe0610b31891612a5ad472baab9c3dfc2e6dea16802f09
7
- data.tar.gz: ed431cca2abaa3126f61726686a788775c11c1752dc0c127332338da9b518b92487cc15c52a7fdbf7bb8a9a5c5e0623457cc13287cac3ef7038af33fbff6ab5d
6
+ metadata.gz: 1251cd36d581ca65b99692e266869f9f1f76b7bb9a4273027a54e7b82c5f68015aacea4c5ad05f610f1b0100570e2e266787f0b71f0c53ff2344e6f7456dc272
7
+ data.tar.gz: 5164f07072d6cc73038eb2da479ffd3eb0e065ee251438823e5762310da90b4462acb370fd2f2b233b4aaae1bd86118401d329e14140c166205978130727c733
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ Includes:
3
+ - 'Gemfile'
4
+ Excludes:
5
+ - 'Gemfile.devtools'
6
+ - 'vendor/**'
@@ -0,0 +1 @@
1
+ axiom-do-adapter
@@ -1,35 +1,29 @@
1
1
  language: ruby
2
2
  before_install: gem install bundler
3
3
  bundler_args: --without yard guard benchmarks
4
- script: "bundle exec rake ci"
4
+ script: "bundle exec rake ci:metrics"
5
5
  rvm:
6
- - ree
7
- - 1.8.7
8
- - 1.9.2
9
6
  - 1.9.3
10
7
  - 2.0.0
8
+ - 2.1.0
11
9
  - 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
10
+ - rbx
26
11
  matrix:
27
12
  include:
28
13
  - rvm: jruby-19mode
29
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
14
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
15
+ - rvm: jruby-20mode
16
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
17
+ - rvm: jruby-21mode
18
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
30
19
  - rvm: jruby-head
31
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
20
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
32
21
  allow_failures:
33
- # mutant fails
34
- - rvm: 1.9.3
35
- - rvm: rbx-19mode
22
+ - rvm: 2.1.0 # buggy runtime
23
+ fast_finish: true
24
+ notifications:
25
+ irc:
26
+ channels:
27
+ - irc.freenode.org#rom-rb
28
+ on_success: never
29
+ on_failure: change
@@ -1,5 +1,4 @@
1
- Contributing
2
- ------------
1
+ # Contributing
3
2
 
4
3
  * 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
4
  * Fork the project.
data/Gemfile CHANGED
@@ -2,9 +2,14 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
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'
5
+ gemspec
8
6
 
9
- gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
10
- eval File.read('Gemfile.devtools')
7
+ platform :rbx do
8
+ gem 'rubysl-bigdecimal', '~> 2.0.2'
9
+ end
10
+
11
+ group :development, :test do
12
+ gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
13
+ end
14
+
15
+ eval_gemfile 'Gemfile.devtools'
@@ -1,48 +1,60 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  group :development do
4
- gem 'rake', '~> 10.0.4'
5
- gem 'rspec', '~> 2.13.0'
6
- gem 'yard', '~> 0.8.5.2'
4
+ gem 'rake', '~> 10.1.0'
5
+ gem 'rspec', '~> 2.14.1'
6
+ gem 'yard', '~> 0.8.7'
7
+
8
+ platform :rbx do
9
+ gem 'rubysl-singleton', '~> 2.0.0'
10
+ end
7
11
  end
8
12
 
9
13
  group :yard do
10
- gem 'kramdown', '~> 1.0.1'
14
+ gem 'kramdown', '~> 1.3.0'
11
15
  end
12
16
 
13
17
  group :guard do
14
- gem 'guard', '~> 1.7.0'
15
- gem 'guard-bundler', '~> 1.0.0'
16
- gem 'guard-rspec', '~> 2.5.2'
18
+ gem 'guard', '~> 2.3.0'
19
+ gem 'guard-bundler', '~> 2.0.0'
20
+ gem 'guard-rspec', '~> 4.2.0'
21
+ gem 'guard-rubocop', '~> 1.0.0'
17
22
 
18
23
  # 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
24
+ gem 'listen', '~> 2.4.0'
25
+ gem 'rb-fchange', '~> 0.0.6', require: false
26
+ gem 'rb-fsevent', '~> 0.9.3', require: false
27
+ gem 'rb-inotify', '~> 0.9.0', require: false
23
28
 
24
29
  # 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
30
+ gem 'libnotify', '~> 0.8.0', require: false
31
+ gem 'rb-notifu', '~> 0.0.4', require: false
32
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
28
33
  end
29
34
 
30
35
  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'
36
+ gem 'coveralls', '~> 0.7.0'
37
+ gem 'flay', '~> 2.4.0'
38
+ gem 'flog', '~> 4.2.0'
39
+ gem 'reek', '~> 1.3.2'
40
+ gem 'rubocop', '~> 0.16.0'
41
+ gem 'simplecov', '~> 0.8.2'
42
+ gem 'yardstick', '~> 0.9.9'
43
+
44
+ platforms :mri do
45
+ gem 'mutant', '~> 0.3.4'
46
+ end
47
+
48
+ platforms :ruby_19, :ruby_20 do
49
+ gem 'yard-spellcheck', '~> 0.1.5'
42
50
  end
43
51
 
44
- platforms :rbx do
45
- gem 'pelusa', '~> 0.2.2'
52
+ platform :rbx do
53
+ gem 'json', '~> 1.8.1'
54
+ gem 'racc', '~> 1.4'
55
+ gem 'rubysl-logger', '~> 2.0.0'
56
+ gem 'rubysl-open-uri', '~> 2.0.0'
57
+ gem 'rubysl-prettyprint', '~> 2.0.2'
46
58
  end
47
59
  end
48
60
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- axiom-do-adapter
2
- ================
1
+ # axiom-do-adapter
3
2
 
4
3
  Use Axiom relations with an SQL based RDBMS
5
4
 
@@ -15,12 +14,10 @@ Use Axiom relations with an SQL based RDBMS
15
14
  [codeclimate]: https://codeclimate.com/github/dkubb/axiom-do-adapter
16
15
  [coveralls]: https://coveralls.io/r/dkubb/axiom-do-adapter
17
16
 
18
- Contributing
19
- ------------
17
+ ## Contributing
20
18
 
21
19
  See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
22
20
 
23
- Copyright
24
- ---------
21
+ ## Copyright
25
22
 
26
23
  Copyright © 2011-2013 Dan Kubb. See LICENSE for details.
@@ -10,18 +10,16 @@ Gem::Specification.new do |gem|
10
10
  gem.description = 'Use Axiom relations with an RDBMS'
11
11
  gem.summary = 'Vertias DataObjects adapter'
12
12
  gem.homepage = 'https://github.com/dkubb/axiom-do-adapter'
13
- gem.licenses = %w[MIT]
13
+ gem.license = 'MIT'
14
14
 
15
15
  gem.require_paths = %w[lib]
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
18
18
  gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
19
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')
20
+ gem.add_runtime_dependency('axiom', '~> 0.2.0')
21
+ gem.add_runtime_dependency('axiom-sql-generator', '~> 0.2.0')
22
+ gem.add_runtime_dependency('data_objects', '~> 0.10.13')
23
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')
24
+ gem.add_development_dependency('bundler', '~> 1.5', '>= 1.5.2')
27
25
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ unit_test_timeout: 1.0
@@ -67,13 +67,8 @@ TooManyMethods:
67
67
  max_methods: 10
68
68
  TooManyStatements:
69
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
70
+ exclude: []
71
+ max_statements: 5
77
72
  UncommunicativeMethodName:
78
73
  enabled: true
79
74
  exclude: []
@@ -0,0 +1,59 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ # Avoid parameter lists longer than five parameters.
4
+ ParameterLists:
5
+ Max: 3
6
+ CountKeywordArgs: true
7
+
8
+ # Avoid more than `Max` levels of nesting.
9
+ BlockNesting:
10
+ Max: 3
11
+
12
+ # Align with the style guide.
13
+ CollectionMethods:
14
+ PreferredMethods:
15
+ collect: 'map'
16
+ inject: 'reduce'
17
+ find: 'detect'
18
+ find_all: 'select'
19
+
20
+ # Do not force public/protected/private keyword to be indented at the same
21
+ # level as the def keyword. My personal preference is to outdent these keywords
22
+ # because I think when scanning code it makes it easier to identify the
23
+ # sections of code and visually separate them. When the keyword is at the same
24
+ # level I think it sort of blends in with the def keywords and makes it harder
25
+ # to scan the code and see where the sections are.
26
+ AccessModifierIndentation:
27
+ Enabled: false
28
+
29
+ # Limit line length
30
+ LineLength:
31
+ Max: 114 # TODO: lower to 79
32
+
33
+ # Disable documentation checking until a class needs to be documented once
34
+ Documentation:
35
+ Enabled: false
36
+
37
+ # Do not always use &&/|| instead of and/or.
38
+ AndOr:
39
+ Enabled: false
40
+
41
+ # Do not favor modifier if/unless usage when you have a single-line body
42
+ IfUnlessModifier:
43
+ Enabled: false
44
+
45
+ # Allow case equality operator (in limited use within the specs)
46
+ CaseEquality:
47
+ Enabled: false
48
+
49
+ # Constants do not always have to use SCREAMING_SNAKE_CASE
50
+ ConstantName:
51
+ Enabled: false
52
+
53
+ # Not all trivial readers/writers can be defined with attr_* methods
54
+ TrivialAccessors:
55
+ Enabled: false
56
+
57
+ # Allow empty lines around body
58
+ EmptyLinesAroundBody:
59
+ Enabled: false
@@ -6,7 +6,7 @@ module Axiom
6
6
 
7
7
  # Executes generated SQL statements
8
8
  class Statement
9
- include Enumerable, Adamantium
9
+ include Enumerable, Adamantium::Flat
10
10
 
11
11
  # Initialize a statement
12
12
  #
@@ -24,7 +24,6 @@ module Axiom
24
24
  @connection = connection
25
25
  @relation = relation
26
26
  @visitor = visitor
27
- freeze
28
27
  end
29
28
 
30
29
  # Iterate over each row in the results
@@ -73,9 +72,7 @@ module Axiom
73
72
  # @api private
74
73
  def each_row
75
74
  reader = command.execute_reader
76
- while reader.next!
77
- yield reader.values
78
- end
75
+ yield reader.values while reader.next!
79
76
  ensure
80
77
  reader.close if reader
81
78
  end
@@ -97,11 +94,11 @@ module Axiom
97
94
  #
98
95
  # @api private
99
96
  def column_types
100
- @relation.header.map { |attribute| attribute.class.primitive }
97
+ @relation.header.map { |attribute| attribute.type.primitive }
101
98
  end
102
99
 
103
100
  memoize :to_s
104
- memoize :command, :freezer => :flat
101
+ memoize :command, freezer: :flat
105
102
 
106
103
  end # class Statement
107
104
  end # class DataObjects
@@ -5,7 +5,7 @@ module Axiom
5
5
  class DataObjects
6
6
 
7
7
  # Gem version
8
- VERSION = '0.1.0'.freeze
8
+ VERSION = '0.2.0'.freeze
9
9
 
10
10
  end # class DataObjects
11
11
  end # module Adapter
@@ -9,8 +9,8 @@ module Axiom
9
9
  DECORATED_CLASS = superclass
10
10
 
11
11
  # remove methods so they can be proxied
12
- undef_method *DECORATED_CLASS.public_instance_methods(false).map(&:to_s) - %w[ materialize ]
13
- undef_method :project, :remove, :extend, :rename, :restrict, :sort_by, :reverse, :drop, :take
12
+ undef_method(*DECORATED_CLASS.public_instance_methods(false).map(&:to_s) - %w[materialize])
13
+ undef_method(:project, :remove, :extend, :rename, :restrict, :sort_by, :reverse, :drop, :take)
14
14
 
15
15
  # The adapter the gateway will use to fetch results
16
16
  #
@@ -184,7 +184,7 @@ module Axiom
184
184
  # end
185
185
  #
186
186
  # @example with a header
187
- # summarization = gateway.summarize([ :name ]) do |context|
187
+ # summarization = gateway.summarize([:name]) do |context|
188
188
  # context.add(:count, context[:id].count)
189
189
  # end
190
190
  #
@@ -2,49 +2,49 @@
2
2
 
3
3
  shared_examples_for 'a binary relation method' do
4
4
  describe 'when other has the same adapter' do
5
- let(:other_relation) { mock('Other Relation') }
5
+ let(:other_relation) { double('Other Relation') }
6
6
  let(:other) { described_class.new(adapter, other_relation) }
7
- let(:gateway) { mock('Other Gateway') }
7
+ let(:gateway) { double('Other Gateway') }
8
8
 
9
9
  before do
10
- relation.stub!(operation).and_return(gateway)
10
+ allow(relation).to receive(operation).and_return(gateway)
11
11
  end
12
12
 
13
13
  it { should equal(gateway) }
14
14
 
15
15
  it 'passes the other relation to the binary operation' do
16
- relation.should_receive(operation).with(other_relation)
16
+ expect(relation).to receive(operation).with(other_relation)
17
17
  subject
18
18
  end
19
19
  end
20
20
 
21
21
  describe 'when other has a different adapter' do
22
- let(:other_adapter) { mock('Other Adapter') }
23
- let(:other) { described_class.new(other_adapter, stub) }
22
+ let(:other_adapter) { double('Other Adapter') }
23
+ let(:other) { described_class.new(other_adapter, double) }
24
24
 
25
25
  before do
26
- factory.stub!(:new).and_return(binary_relation)
26
+ allow(factory).to receive(:new).and_return(binary_relation)
27
27
  end
28
28
 
29
29
  it { should equal(binary_relation) }
30
30
 
31
31
  it 'initializes the binary operation with the gateways' do
32
- factory.should_receive(:new).with(object, other)
32
+ expect(factory).to receive(:new).with(object, other)
33
33
  subject
34
34
  end
35
35
  end
36
36
 
37
37
  describe 'when other has no adapter' do
38
- let(:other) { mock('Other Relation') }
38
+ let(:other) { double('Other Relation') }
39
39
 
40
40
  before do
41
- factory.stub!(:new).and_return(binary_relation)
41
+ allow(factory).to receive(:new).and_return(binary_relation)
42
42
  end
43
43
 
44
44
  it { should equal(binary_relation) }
45
45
 
46
46
  it 'initializes the binary operation with the gateway and other relation' do
47
- factory.should_receive(:new).with(object, other)
47
+ expect(factory).to receive(:new).with(object, other)
48
48
  subject
49
49
  end
50
50
  end