spare 0.0.2 → 0.0.3

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: 936d9a097a732959b140e86baec575092a4aa84a
4
- data.tar.gz: 7276ce1dc0323e3fe339542961bfe77181342752
3
+ metadata.gz: e6133fdf40c180092996247c0206ff5278ff0166
4
+ data.tar.gz: b608da7b494052e5b256c79430a0e981cd44fcb4
5
5
  SHA512:
6
- metadata.gz: c14abbcd3286eb0b31c20387d6b9b8eae5cc9cdb014f85b0ab3d4c1efa9f7b5e86e79d631d1ef614c9a9d6399881d0f56425ad8ffd1fbc1d5d3c37cd1740a98a
7
- data.tar.gz: b12e825ab02b15cefde63f18dab160b61ad62e9f221eb4d0ce4f3a7f80843eab1b89997692a25867b586dac7463c75e1eac13a168d4ac3c44526dcd6f16c330f
6
+ metadata.gz: 64c4fe6d1b26abef7503887f555df388c36cb9045f7002406c3e3072fa5d08d261884c94de93a703aa81c05e881a8b6520f522d9cdcca3eecc190704fe66bfda
7
+ data.tar.gz: 0252c0c7438670edc38276a9c1e232ddf02ef15debbbf512611f4ef09cc4ad4d27b5253616f67fe4a0a6189df74e4aacca6660bab7d27603c3d9d9ace1d9be04
data/lib/spare/core.rb CHANGED
@@ -2,7 +2,7 @@ module Spare
2
2
  module Core
3
3
  # Returns a string like 'MyStoredProcedure(p_id:integer, p_title:string, p_body:text)'
4
4
  def inspect
5
- if self == Base
5
+ if self == ActiveRecord::Base
6
6
  super
7
7
  elsif abstract_class?
8
8
  super
@@ -0,0 +1,4 @@
1
+ require 'active_record'
2
+ module ActiveRecord
3
+ class StoredProcedureNotFound < StandardError; end
4
+ end
@@ -1,3 +1,4 @@
1
+ require 'spare/exceptions'
1
2
  require 'active_record/connection_adapters/abstract_mysql_adapter'
2
3
  module ActiveRecord
3
4
  module ConnectionAdapters
@@ -5,15 +6,15 @@ module ActiveRecord
5
6
 
6
7
  # Returns hash describing the stored procedure.
7
8
  def stored_procedure(name)#:nodoc:
8
- name = name.split('.').reverse
9
+ sp_name = name.split('.').reverse
9
10
 
10
- sql = "SELECT db,specific_name,param_list,db_collation FROM mysql.proc WHERE specific_name = #{quote(name[0])}"
11
- sql << " AND db = #{quote(name[1])}" if name[1]
11
+ sql = "SELECT db,specific_name,param_list,db_collation FROM mysql.proc WHERE specific_name = #{quote(sp_name[0])}"
12
+ sql << " AND db = #{quote(sp_name[1])}" if sp_name[1]
12
13
 
13
14
  result = execute(sql)
14
15
  keys = result.fields.collect{|k| k.to_sym}
15
16
  values = result.to_a[0]
16
- return nil unless values
17
+ raise ActiveRecord::StoredProcedureNotFound, "#{name} was not found" unless values
17
18
  sp = Hash[keys.zip(values)]
18
19
  sp[:param_list] = stored_procedure_params(sp[:param_list], sp[:db_collation])
19
20
  sp
data/lib/spare/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spare
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/spare.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "active_record"
2
+ require "spare/exceptions"
2
3
  require "spare/core"
3
4
  require "spare/attributes"
4
5
  require "spare/mysql_abstract_adapter"
@@ -4,7 +4,7 @@ describe ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter do
4
4
  describe '#stored_procedure' do
5
5
 
6
6
  context "stored procedure does not exist" do
7
- it {expect(ActiveRecord::Base.connection.stored_procedure("bad")).to be_nil}
7
+ it {expect {ActiveRecord::Base.connection.stored_procedure("bad")}.to raise_error(ActiveRecord::StoredProcedureNotFound) }
8
8
  end
9
9
 
10
10
  context "stored procedure does exist" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Mckinney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -138,6 +138,7 @@ files:
138
138
  - lib/spare.rb
139
139
  - lib/spare/attributes.rb
140
140
  - lib/spare/core.rb
141
+ - lib/spare/exceptions.rb
141
142
  - lib/spare/model_schema.rb
142
143
  - lib/spare/mysql_abstract_adapter.rb
143
144
  - lib/spare/schema_cache.rb