rom-sql 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f9129b51494f9c6e4e78dd37a3700e103012ee7
4
- data.tar.gz: 72e8eb116c43a411fb250ee866cdeeb9e5edb0a9
3
+ metadata.gz: 17d07fe9555b80ab518029eb126f90e93e8b4c3d
4
+ data.tar.gz: 9beb66309d64a2aa65f7c4ab47d57cc274b53085
5
5
  SHA512:
6
- metadata.gz: 468a0785cb4d9d132bcdd344cf0bb72b12ece60b5e118d8ae7a5ac095d1be5adb7eca861ae0bf70167c79bf911c2fca30e4d814cb514c44cfc8e53b421266dcb
7
- data.tar.gz: f081da3b8fe5f27c6b9c40f80f5b374a230ffd3e30d71b8ce70d82edeac09c176bce328bf8015d50e7f2dd51f88ea54aeb36d7661f90e5f1a6ff23807436b500
6
+ metadata.gz: 3d72099961426bc8cd2a60faa7001f0a7b65a353bd5a93e4e12c9a233002c340f7c928ce21df42c14a9e59fdd06a14740f5f477c88a065ad3cd929c6f6a86c73
7
+ data.tar.gz: 562af5a84d07462549511657df45cdbc18e4e9904d3a7cd3742c9d1ad846f2e3c6c136873a54da7661940dc6c41feb3e7490da6e03243595e12c01b6ad34de84
@@ -0,0 +1,41 @@
1
+ # FIXME: Lower by refactoring biggest offenders
2
+ Metrics/AbcSize:
3
+ Max: 27
4
+
5
+ # FIXME: Lower by refactoring biggest offenders
6
+ Metrics/MethodLength:
7
+ Max: 32
8
+
9
+ # FIXME: Lower by refactoring biggest offenders
10
+ Metrics/PerceivedComplexity:
11
+ Max: 9
12
+
13
+ # This file is not worth fixing
14
+ Metrics/LineLength:
15
+ Exclude:
16
+ - spec/support/active_support_notifications_spec.rb
17
+
18
+ # The enforced style doesn’t match Vim’s defaults
19
+ Style/AlignParameters:
20
+ Enabled: false
21
+
22
+ # Documentation checked by Inch CI
23
+ Style/Documentation:
24
+ Enabled: false
25
+
26
+ # This is a shim file for those who require 'rom-mongo'
27
+ Style/FileName:
28
+ Exclude:
29
+ - lib/rom-sql.rb
30
+
31
+ # The default style doesn’t match Vim’s defaults
32
+ Style/IndentHash:
33
+ EnforcedStyle: consistent
34
+
35
+ # Even a single escaped slash can be confusing
36
+ Style/RegexpLiteral:
37
+ MaxSlashes: 0
38
+
39
+ # Accept both single and double quotes
40
+ Style/StringLiterals:
41
+ Enabled: false
@@ -8,6 +8,7 @@ script: "bundle exec rake spec"
8
8
  rvm:
9
9
  - 2.0
10
10
  - 2.1
11
+ - 2.2
11
12
  - rbx-2
12
13
  - jruby
13
14
  - ruby-head
@@ -1,3 +1,12 @@
1
+ ## v0.3.1 2014-12-31
2
+
3
+ ### Added
4
+
5
+ * `Adapter#disconnect` (solnic)
6
+ * Support for extra connection options (solnic)
7
+
8
+ [Compare v0.3.0...v0.3.1](https://github.com/rom-rb/rom-sql/compare/v0.3.0...v0.3.1)
9
+
1
10
  ## v0.3.0 2014-12-19
2
11
 
3
12
  ### Changed
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master'
6
+ gem 'rom', '~> 0.5.0', github: 'rom-rb/rom', branch: 'master'
7
+ gem 'virtus'
7
8
  gem 'activesupport'
8
9
  gem 'rspec', '~> 3.1'
9
10
  gem 'codeclimate-test-reporter', require: false
data/Rakefile CHANGED
@@ -1,3 +1,10 @@
1
1
  require "rspec/core/rake_task"
2
+ require "rubocop/rake_task"
3
+
4
+ task default: [:spec, :rubocop]
2
5
 
3
6
  RSpec::Core::RakeTask.new(:spec)
7
+
8
+ RuboCop::RakeTask.new do |task|
9
+ task.options << "--display-cop-names"
10
+ end
@@ -4,19 +4,37 @@ require 'rom/sql/commands'
4
4
 
5
5
  module ROM
6
6
  module SQL
7
-
8
7
  class Adapter < ROM::Adapter
9
8
  attr_reader :logger
10
9
 
11
10
  def self.schemes
12
- [:ado, :amalgalite, :cubrid, :db2, :dbi, :do, :fdbsql, :firebird, :ibmdb,
13
- :informix, :jdbc, :mysql, :mysql2, :odbc, :openbase, :oracle, :postgres,
14
- :sqlanywhere, :sqlite, :swift, :tinytds]
11
+ [:ado, :amalgalite, :cubrid, :db2, :dbi, :do, :fdbsql, :firebird,
12
+ :ibmdb, :informix, :jdbc, :mysql, :mysql2, :odbc, :openbase, :oracle,
13
+ :postgres, :sqlanywhere, :sqlite, :sqlite3, :swift, :tinytds]
14
+ end
15
+
16
+ def self.normalize_scheme(input)
17
+ scheme = input.dup
18
+ scheme = 'sqlite' if scheme == 'sqlite3'
19
+
20
+ if RUBY_ENGINE == 'jruby' && scheme != 'postgres'
21
+ scheme.prepend('jdbc:')
22
+ end
23
+
24
+ scheme
25
+ end
26
+
27
+ def self.database_file?(scheme)
28
+ scheme.to_s.include?('sqlite')
15
29
  end
16
30
 
17
31
  def initialize(*args)
18
32
  super
19
- @connection = ::Sequel.connect(uri.to_s)
33
+ @connection = ::Sequel.connect(uri.to_s, options)
34
+ end
35
+
36
+ def disconnect
37
+ connection.disconnect
20
38
  end
21
39
 
22
40
  def [](name)
@@ -77,9 +95,6 @@ module ROM
77
95
  def map_schema_type(type)
78
96
  connection.class::SCHEMA_TYPE_CLASSES.fetch(type)
79
97
  end
80
-
81
- ROM::Adapter.register(self)
82
98
  end
83
-
84
99
  end
85
100
  end
@@ -7,7 +7,6 @@ module ROM
7
7
  ].freeze
8
8
 
9
9
  class Create < ROM::Commands::Create
10
-
11
10
  def execute(tuples)
12
11
  pks = Array([tuples]).flatten.map do |tuple|
13
12
  attributes = input[tuple]
@@ -22,7 +21,6 @@ module ROM
22
21
  end
23
22
 
24
23
  class Update < ROM::Commands::Update
25
-
26
24
  def execute(tuple)
27
25
  attributes = input[tuple]
28
26
  validator.call(attributes)
@@ -32,19 +30,15 @@ module ROM
32
30
  relation.update(attributes.to_h)
33
31
  relation.unfiltered.where(relation.model.primary_key => pks)
34
32
  end
35
-
36
33
  end
37
34
 
38
35
  class Delete < ROM::Commands::Delete
39
-
40
36
  def execute
41
37
  deleted = target.to_a
42
38
  target.delete
43
39
  deleted
44
40
  end
45
-
46
41
  end
47
-
48
42
  end
49
43
  end
50
44
  end
@@ -1,6 +1,5 @@
1
1
  module ROM
2
2
  module SQL
3
-
4
3
  # @private
5
4
  class Header
6
5
  include Charlatan.new(:columns)
@@ -19,10 +18,10 @@ module ROM
19
18
  alias_method :to_a, :to_ary
20
19
 
21
20
  def to_h
22
- columns.each_with_object({}) { |col, h|
21
+ columns.each_with_object({}) do |col, h|
23
22
  left, right = col.to_s.split('___')
24
23
  h[left.to_sym] = (right || left).to_sym
25
- }
24
+ end
26
25
  end
27
26
 
28
27
  def names
@@ -38,7 +37,7 @@ module ROM
38
37
  end
39
38
 
40
39
  def rename(options)
41
- map { |col|
40
+ map do |col|
42
41
  new_name = options[col]
43
42
 
44
43
  if new_name
@@ -46,14 +45,12 @@ module ROM
46
45
  else
47
46
  col
48
47
  end
49
- }
48
+ end
50
49
  end
51
50
 
52
51
  def prefix(col_prefix)
53
52
  rename(Hash[map { |col| [col, :"#{col_prefix}_#{col}"] }])
54
53
  end
55
-
56
54
  end
57
-
58
55
  end
59
56
  end
@@ -1,23 +1,21 @@
1
1
  module ROM
2
2
  module SQL
3
-
4
3
  # Sequel-specific relation extensions
5
4
  #
6
5
  module RelationInclusion
7
-
8
6
  def self.included(klass)
9
7
  klass.extend(AssociationDSL)
10
8
 
11
9
  klass.send(:undef_method, :select)
12
10
  klass.send(:attr_reader, :model)
13
11
 
14
- klass.class_eval {
12
+ klass.class_eval do
15
13
  class << self
16
14
  attr_accessor :model
17
15
  end
18
16
 
19
17
  self.model = Class.new(Sequel::Model)
20
- }
18
+ end
21
19
  end
22
20
 
23
21
  def initialize(*args)
@@ -96,7 +94,9 @@ module ROM
96
94
  select: l_select, implicit_qualifier: self.name
97
95
  )
98
96
 
99
- l_graph.graph(name, { primary_key => assoc[:right_key] }, select: r_select)
97
+ l_graph.graph(
98
+ name, { primary_key => assoc[:right_key] }, select: r_select
99
+ )
100
100
  else
101
101
  join_keys =
102
102
  if type == :many_to_one
@@ -114,7 +114,6 @@ module ROM
114
114
  end
115
115
 
116
116
  module AssociationDSL
117
-
118
117
  def one_to_many(name, options)
119
118
  associations << [__method__, name, options.merge(relation: name)]
120
119
  end
@@ -124,7 +123,8 @@ module ROM
124
123
  end
125
124
 
126
125
  def many_to_one(name, options = {})
127
- associations << [__method__, name, options.merge(relation: Inflecto.pluralize(name).to_sym)]
126
+ new_options = options.merge(relation: Inflecto.pluralize(name).to_sym)
127
+ associations << [__method__, name, new_options]
128
128
  end
129
129
 
130
130
  def finalize(relations, relation)
@@ -143,9 +143,7 @@ module ROM
143
143
  def associations
144
144
  @associations ||= []
145
145
  end
146
-
147
146
  end
148
147
  end
149
-
150
148
  end
151
149
  end
@@ -16,7 +16,7 @@ def seed(db = DB)
16
16
  db.run("CREATE TABLE users (id INTEGER PRIMARY KEY, name STRING)")
17
17
 
18
18
  db[:users].insert(id: 1, name: 'Jane')
19
- db[:users].insert(id:2, name: 'Joe')
19
+ db[:users].insert(id: 2, name: 'Joe')
20
20
  end
21
21
 
22
22
  def deseed(db = DB)
@@ -2,15 +2,13 @@ require 'sequel/database/logging'
2
2
  require 'active_support/notifications'
3
3
 
4
4
  module Sequel
5
-
6
5
  class Database
7
-
8
6
  def log_yield_with_instrumentation(sql, args = nil, &block)
9
7
  ActiveSupport::Notifications.instrument(
10
8
  'sql.rom',
11
- :sql => sql,
12
- :name => instrumentation_name,
13
- :binds => args
9
+ sql: sql,
10
+ name: instrumentation_name,
11
+ binds: args
14
12
  ) do
15
13
  log_yield_without_instrumentation(sql, args, &block)
16
14
  end
@@ -24,6 +22,5 @@ module Sequel
24
22
  def instrumentation_name
25
23
  "ROM[#{database_type}]"
26
24
  end
27
-
28
25
  end
29
26
  end
@@ -2,9 +2,7 @@ require 'active_support/log_subscriber'
2
2
 
3
3
  module ROM
4
4
  module SQL
5
-
6
5
  class RailsLogSubscriber < ActiveSupport::LogSubscriber
7
-
8
6
  def sql(event)
9
7
  return unless logger.debug?
10
8
 
@@ -27,9 +25,7 @@ module ROM
27
25
  def odd?
28
26
  @odd_or_even = !@odd_or_even
29
27
  end
30
-
31
28
  end
32
-
33
29
  end
34
30
  end
35
31
 
@@ -1,33 +1,33 @@
1
- class Sequel::Dataset
1
+ module Sequel
2
+ class Dataset
3
+ def header
4
+ ROM::SQL::Header.new(opts.fetch(:select) { columns }, opts[:from].first)
5
+ end
2
6
 
3
- def header
4
- ROM::SQL::Header.new(opts.fetch(:select) { columns }, opts[:from].first)
5
- end
6
-
7
- def project(*names)
8
- select(*header.project(*names))
9
- end
7
+ def project(*names)
8
+ select(*header.project(*names))
9
+ end
10
10
 
11
- def rename(options)
12
- select(*header.rename(options))
13
- end
11
+ def rename(options)
12
+ select(*header.rename(options))
13
+ end
14
14
 
15
- def prefix(col_prefix = default_prefix)
16
- rename(header.prefix(col_prefix).to_h)
17
- end
15
+ def prefix(col_prefix = default_prefix)
16
+ rename(header.prefix(col_prefix).to_h)
17
+ end
18
18
 
19
- def qualified
20
- select(*qualified_columns)
21
- end
19
+ def qualified
20
+ select(*qualified_columns)
21
+ end
22
22
 
23
- def qualified_columns
24
- header.qualified.to_a
25
- end
23
+ def qualified_columns
24
+ header.qualified.to_a
25
+ end
26
26
 
27
- private
27
+ private
28
28
 
29
- def default_prefix
30
- Inflecto.singularize(opts[:from].first)
29
+ def default_prefix
30
+ Inflecto.singularize(opts[:from].first)
31
+ end
31
32
  end
32
-
33
33
  end
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module SQL
3
- VERSION = "0.3.0".freeze
3
+ VERSION = "0.3.1".freeze
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ROM::SQL::VERSION.dup
9
9
  spec.authors = ["Piotr Solnica"]
10
10
  spec.email = ["piotr.solnica@gmail.com"]
11
- spec.summary = %q{RDBMS support for ROM}
11
+ spec.summary = 'SQL databases support for ROM'
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "http://rom-rb.org"
14
14
  spec.license = "MIT"
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency "sequel", "~> 4.17"
22
22
  spec.add_runtime_dependency "equalizer", "~> 0.0", ">= 0.0.9"
23
- spec.add_runtime_dependency "rom", "~> 0.4", ">= 0.4.0"
23
+ spec.add_runtime_dependency "rom", "~> 0.5", ">= 0.5.0"
24
24
 
25
25
  spec.add_development_dependency "bundler"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rubocop", "~> 0.28.0"
27
28
  end
@@ -26,9 +26,9 @@ describe 'Commands / Create' do
26
26
  end
27
27
 
28
28
  it 'returns tuples when result is set to :many' do
29
- result = users.try {
29
+ result = users.try do
30
30
  create_many([{ id: 2, name: 'Jane' }, { id: 3, name: 'Jack' }])
31
- }
31
+ end
32
32
 
33
33
  expect(result.value.to_a).to match_array([
34
34
  { id: 2, name: 'Jane' }, { id: 3, name: 'Jack' }
@@ -22,11 +22,12 @@ describe 'Commands / Delete' do
22
22
  it 'deletes all tuples' do
23
23
  result = users.try { delete }
24
24
 
25
- expect(result.value.to_a).to match_array([{ id: 1, name: 'Piotr' }, { id: 2, name: 'Jane' }])
25
+ expect(result.value.to_a)
26
+ .to match_array([{ id: 1, name: 'Piotr' }, { id: 2, name: 'Jane' }])
26
27
  end
27
28
 
28
29
  it 'deletes all tuples in a restricted relation' do
29
- result = users.try { delete(:by_name, 'Jane').execute }
30
+ result = users.try { delete(:by_name, 'Jane') }
30
31
 
31
32
  expect(result.value).to match_array([{ id: 2, name: 'Jane' }])
32
33
  end
@@ -15,7 +15,7 @@ describe 'Commands / Update' do
15
15
  setup.commands(:users) do
16
16
  define(:update) do
17
17
  input Hash
18
- validator Proc.new {}
18
+ validator proc {}
19
19
  end
20
20
  end
21
21
 
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require 'virtus'
3
+
4
+ describe 'Reading relations' do
5
+ include_context 'users and tasks'
6
+
7
+ it 'loads domain objects' do
8
+ class Task
9
+ include Virtus.value_object(coerce: true)
10
+
11
+ values do
12
+ attribute :id, Integer
13
+ attribute :title, String
14
+ end
15
+ end
16
+
17
+ class User
18
+ include Virtus.value_object(coerce: true)
19
+
20
+ values do
21
+ attribute :id, Integer
22
+ attribute :name, String
23
+ attribute :tasks, Array[Task]
24
+ end
25
+ end
26
+
27
+ setup.relation(:tasks)
28
+
29
+ setup.relation(:users) do
30
+ one_to_many :tasks, key: :user_id
31
+
32
+ def by_name(name)
33
+ where(name: name)
34
+ end
35
+
36
+ def with_tasks
37
+ association_left_join(:tasks, select: [:id, :title])
38
+ end
39
+
40
+ def all
41
+ select(:id, :name)
42
+ end
43
+ end
44
+
45
+ setup.mappers do
46
+ define(:users) do
47
+ model User
48
+
49
+ group :tasks do
50
+ model Task
51
+
52
+ attribute :id, from: :tasks_id
53
+ attribute :title
54
+ end
55
+ end
56
+ end
57
+
58
+ user = rom.read(:users).with_tasks.by_name('Piotr').to_a.first
59
+
60
+ expect(user).to eql(
61
+ User.new(
62
+ id: 1, name: 'Piotr', tasks: [Task.new(id: 1, title: 'Finish ROM')]
63
+ ))
64
+ end
65
+ end
@@ -31,6 +31,5 @@ shared_context 'database setup' do
31
31
  Integer :tag_id
32
32
  Integer :task_id
33
33
  end
34
-
35
34
  end
36
35
  end
@@ -11,7 +11,7 @@ describe 'ActiveSupport::Notifications support' do
11
11
 
12
12
  sql = nil
13
13
 
14
- ActiveSupport::Notifications.subscribe('sql.rom') do |name, start, finish, id, payload|
14
+ ActiveSupport::Notifications.subscribe('sql.rom') do |_name, _start, _finish, _id, payload|
15
15
  sql = payload[:sql]
16
16
  end
17
17
 
@@ -3,9 +3,31 @@ require 'spec_helper'
3
3
  describe ROM::Adapter do
4
4
  subject(:adapter) { rom.postgres.adapter }
5
5
 
6
- let(:setup) { ROM.setup(postgres: "postgres://localhost/rom") }
6
+ let(:setup) { ROM.setup(postgres: 'postgres://localhost/rom') }
7
7
  let(:rom) { setup.finalize }
8
8
 
9
+ describe 'setting up' do
10
+ it 'works with database.yml-style hash' do
11
+ setup = ROM.setup(adapter: 'postgres', database: 'rom')
12
+ expect(setup[:default]).to eql(setup.repositories[:default])
13
+ end
14
+
15
+ it 'accepts additional options' do
16
+ test = false
17
+
18
+ setup = ROM.setup(
19
+ adapter: 'postgres',
20
+ database: 'rom',
21
+ test: true,
22
+ after_connect: proc { test = true }
23
+ )
24
+
25
+ setup.finalize
26
+
27
+ expect(test).to be(true)
28
+ end
29
+ end
30
+
9
31
  describe '#dataset?' do
10
32
  it 'returns true if a table exists' do
11
33
  expect(adapter.dataset?(:users)).to be(true)
@@ -15,4 +37,12 @@ describe ROM::Adapter do
15
37
  expect(adapter.dataset?(:not_here)).to be(false)
16
38
  end
17
39
  end
40
+
41
+ describe '#disconnect' do
42
+ it 'disconnects via sequel connection' do
43
+ # FIXME: no idea how to test it in a different way
44
+ expect(adapter.connection).to receive(:disconnect)
45
+ adapter.disconnect
46
+ end
47
+ end
18
48
  end
@@ -12,7 +12,6 @@ describe 'Defining multiple associations' do
12
12
  setup.relation(:tags)
13
13
 
14
14
  setup.relation(:tasks) do
15
-
16
15
  many_to_one :users, key: :user_id
17
16
 
18
17
  many_to_many :tags,
@@ -43,7 +42,6 @@ describe 'Defining multiple associations' do
43
42
  def sorted_by_tags_name
44
43
  order(Sequel.desc(:tags__name))
45
44
  end
46
-
47
45
  end
48
46
 
49
47
  tasks = rom.relations.tasks
@@ -68,7 +66,7 @@ describe 'Defining multiple associations' do
68
66
  ])
69
67
 
70
68
  expect(tasks.where(title: 'Go to sleep').to_a).to eql(
71
- [{ id: 2, user_id: 1, title: 'Go to sleep'}]
69
+ [{ id: 2, user_id: 1, title: 'Go to sleep' }]
72
70
  )
73
71
  end
74
72
  end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::Config do
4
+ let(:root) { '/somewhere' }
5
+
6
+ describe '.build' do
7
+ it 'rewrites database config hash to a URI for sqlite' do
8
+ db_config = { adapter: 'sqlite', database: 'testing.sqlite', root: root }
9
+
10
+ config = ROM::Config.build(db_config)
11
+
12
+ if RUBY_ENGINE == 'jruby'
13
+ expect(config)
14
+ .to eql(default: "jdbc:sqlite:///somewhere/testing.sqlite")
15
+ else
16
+ expect(config).to eql(default: "sqlite:///somewhere/testing.sqlite")
17
+ end
18
+ end
19
+
20
+ it 'rewrites database config hash to a URI for mysql' do
21
+ db_config = {
22
+ adapter: 'mysql',
23
+ database: 'testing',
24
+ username: 'piotr',
25
+ hostname: 'localhost',
26
+ password: 'secret',
27
+ root: '/foo'
28
+ }
29
+
30
+ config = ROM::Config.build(db_config)
31
+
32
+ if RUBY_ENGINE == 'jruby'
33
+ expect(config)
34
+ .to eql(default: "jdbc:mysql://piotr:secret@localhost/testing")
35
+ else
36
+ expect(config)
37
+ .to eql(default: "mysql://piotr:secret@localhost/testing")
38
+ end
39
+
40
+ db_config = {
41
+ adapter: 'mysql',
42
+ database: 'testing'
43
+ }
44
+
45
+ config = ROM::Config.build(db_config)
46
+
47
+ if RUBY_ENGINE == 'jruby'
48
+ expect(config).to eql(default: "jdbc:mysql://localhost/testing")
49
+ else
50
+ expect(config).to eql(default: "mysql://localhost/testing")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -9,7 +9,6 @@ describe 'Defining many-to-one association' do
9
9
 
10
10
  it 'extends relation with association methods' do
11
11
  setup.relation(:tasks) do
12
-
13
12
  many_to_many :tags,
14
13
  join_table: :task_tags,
15
14
  left_key: :task_id,
@@ -18,7 +18,7 @@ describe ROM::Relation do
18
18
  projected = users.sorted.project(:name)
19
19
 
20
20
  expect(projected.header).to match_array([:name])
21
- expect(projected.to_a).to eql([{ name: 'Piotr'}])
21
+ expect(projected.to_a).to eql([{ name: 'Piotr' }])
22
22
  end
23
23
  end
24
24
 
@@ -26,7 +26,7 @@ describe ROM::Relation do
26
26
  it 'projects the dataset using new column names' do
27
27
  renamed = users.sorted.rename(id: :user_id, name: :user_name)
28
28
 
29
- expect(renamed.to_a).to eql([{ user_id: 1, user_name: 'Piotr'}])
29
+ expect(renamed.to_a).to eql([{ user_id: 1, user_name: 'Piotr' }])
30
30
  end
31
31
  end
32
32
 
@@ -34,13 +34,13 @@ describe ROM::Relation do
34
34
  it 'projects the dataset using new column names' do
35
35
  prefixed = users.sorted.prefix(:user)
36
36
 
37
- expect(prefixed.to_a).to eql([{ user_id: 1, user_name: 'Piotr'}])
37
+ expect(prefixed.to_a).to eql([{ user_id: 1, user_name: 'Piotr' }])
38
38
  end
39
39
 
40
40
  it 'uses singularized table name as the default prefix' do
41
41
  prefixed = users.sorted.prefix
42
42
 
43
- expect(prefixed.to_a).to eql([{ user_id: 1, user_name: 'Piotr'}])
43
+ expect(prefixed.to_a).to eql([{ user_id: 1, user_name: 'Piotr' }])
44
44
  end
45
45
  end
46
46
 
metadata CHANGED
@@ -1,107 +1,122 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.17'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: equalizer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.0'
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: 0.0.9
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ~>
41
+ - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0.0'
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.0.9
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rom
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.4'
54
- - - '>='
53
+ version: '0.5'
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.0
56
+ version: 0.5.0
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0.4'
64
- - - '>='
63
+ version: '0.5'
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 0.4.0
66
+ version: 0.5.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rake
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ~>
85
+ - - "~>"
86
86
  - !ruby/object:Gem::Version
87
87
  version: '10.0'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ~>
92
+ - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '10.0'
95
- description: RDBMS support for ROM
95
+ - !ruby/object:Gem::Dependency
96
+ name: rubocop
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.28.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.28.0
109
+ description: SQL databases support for ROM
96
110
  email:
97
111
  - piotr.solnica@gmail.com
98
112
  executables: []
99
113
  extensions: []
100
114
  extra_rdoc_files: []
101
115
  files:
102
- - .gitignore
103
- - .rspec
104
- - .travis.yml
116
+ - ".gitignore"
117
+ - ".rspec"
118
+ - ".rubocop.yml"
119
+ - ".travis.yml"
105
120
  - CHANGELOG.md
106
121
  - Gemfile
107
122
  - LICENSE.txt
@@ -123,6 +138,7 @@ files:
123
138
  - spec/integration/commands/create_spec.rb
124
139
  - spec/integration/commands/delete_spec.rb
125
140
  - spec/integration/commands/update_spec.rb
141
+ - spec/integration/read_spec.rb
126
142
  - spec/shared/database_setup.rb
127
143
  - spec/shared/users_and_tasks.rb
128
144
  - spec/spec_helper.rb
@@ -130,6 +146,7 @@ files:
130
146
  - spec/support/rails_log_subscriber_spec.rb
131
147
  - spec/unit/adapter_spec.rb
132
148
  - spec/unit/combined_associations_spec.rb
149
+ - spec/unit/config_spec.rb
133
150
  - spec/unit/logger_spec.rb
134
151
  - spec/unit/many_to_many_spec.rb
135
152
  - spec/unit/many_to_one_spec.rb
@@ -146,24 +163,25 @@ require_paths:
146
163
  - lib
147
164
  required_ruby_version: !ruby/object:Gem::Requirement
148
165
  requirements:
149
- - - '>='
166
+ - - ">="
150
167
  - !ruby/object:Gem::Version
151
168
  version: '0'
152
169
  required_rubygems_version: !ruby/object:Gem::Requirement
153
170
  requirements:
154
- - - '>='
171
+ - - ">="
155
172
  - !ruby/object:Gem::Version
156
173
  version: '0'
157
174
  requirements: []
158
175
  rubyforge_project:
159
- rubygems_version: 2.0.14
176
+ rubygems_version: 2.2.2
160
177
  signing_key:
161
178
  specification_version: 4
162
- summary: RDBMS support for ROM
179
+ summary: SQL databases support for ROM
163
180
  test_files:
164
181
  - spec/integration/commands/create_spec.rb
165
182
  - spec/integration/commands/delete_spec.rb
166
183
  - spec/integration/commands/update_spec.rb
184
+ - spec/integration/read_spec.rb
167
185
  - spec/shared/database_setup.rb
168
186
  - spec/shared/users_and_tasks.rb
169
187
  - spec/spec_helper.rb
@@ -171,6 +189,7 @@ test_files:
171
189
  - spec/support/rails_log_subscriber_spec.rb
172
190
  - spec/unit/adapter_spec.rb
173
191
  - spec/unit/combined_associations_spec.rb
192
+ - spec/unit/config_spec.rb
174
193
  - spec/unit/logger_spec.rb
175
194
  - spec/unit/many_to_many_spec.rb
176
195
  - spec/unit/many_to_one_spec.rb