consistent_schema_rb 0.0.2 → 0.0.4

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: 3ef82da687bff5132be2b8e1d75beaa49e17753a
4
- data.tar.gz: 500924f26d340fe006a90b161e9082153f516099
3
+ metadata.gz: f3b7df4e30d9571adedc9d56f63df6ade64f0a3d
4
+ data.tar.gz: 97c13625c0b435fdd40c7c7fa4697c1efbb83caf
5
5
  SHA512:
6
- metadata.gz: ac8ff40168979eae65d4074c7dc1b942cd63b5f04112dcc4a8107c0c56297f96ec83fd0e9408b18398fbf652dd560ca5a2702bb7f2614521b2ea06dc1671e49f
7
- data.tar.gz: 9f0c02e998574523224f703171887d36fc38c312c22b7af4e047d411f06d0b344ac4fd5aa85ec073ee8d4b16965b8b57c74d531e26297556fcf93826ce5ee580
6
+ metadata.gz: c72fee3e029d7d8e8473a85ae9578875a2ae5162bb57446d5252c9c6841fc9f370f2ae890a5de720231ecb08eb074f58f8d3b332fed0eebd6a5c46af52151d22
7
+ data.tar.gz: 9ddfc7c927c8c3a5cd2d5d023370de918b3a02f5419f1398285b1035c2eb61d3e4ef18acd0da6e8d89dc4b6f083562564809c24b96d87d98487b85c1892b8451
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,30 @@
1
+ require 'active_record/connection_adapters/postgresql_adapter'
2
+
3
+ module ActiveRecord
4
+ class Base
5
+ def self.ordered_column_postgresql_connection(config)
6
+ ConnectionAdapters::OrderedColumnPostgreSQLAdapterWrapper.new(postgresql_connection(config))
7
+ end
8
+ end
9
+
10
+ module ConnectionAdapters
11
+ class OrderedColumnPostgreSQLAdapterWrapper < Delegator
12
+ def initailize(postgresql_connection)
13
+ super
14
+ @postgresql_connection = postgresql_connection
15
+ end
16
+
17
+ def columns(table_name, name = nil)
18
+ @postgresql_connection.columns(table_name, name).sort { |x,y| x.name <=> y.name }
19
+ end
20
+
21
+ def __getobj__
22
+ @postgresql_connection
23
+ end
24
+
25
+ def __setobj__(obj)
26
+ @postgresql_connection = obj
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module ConsistentSchemaRb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+
6
+ describe "created adapter" do
7
+ let(:config) { {} }
8
+
9
+ context "creates a postgresql connection" do
10
+ it "creates a postgresql connection" do
11
+ config = {}
12
+ ActiveRecord::Base.should_receive(:postgresql_connection).with(config).and_return { Object.new }
13
+
14
+ ActiveRecord::Base.ordered_column_postgresql_connection(config)
15
+ end
16
+ end
17
+ end
18
+
19
+ describe OrderedColumnPostgreSQLAdapterWrapper do
20
+ subject { ActiveRecord::Base.ordered_column_postgresql_connection({}) }
21
+
22
+ let(:stub_postresql_adapter) { double(PostgreSQLAdapter) }
23
+
24
+ before do
25
+ ActiveRecord::Base.stub(:postgresql_connection).and_return { stub_postresql_adapter }
26
+ end
27
+
28
+ it "delgates methods to the real postgres adapter" do
29
+ stub_postresql_adapter.should_receive(:table).with('name')
30
+
31
+ subject.table('name')
32
+ end
33
+
34
+ it "overrides columns and returns the columns sorted by name" do
35
+ stub_postresql_adapter.stub(:columns).and_return([
36
+ TestColumn.new('bbb'),
37
+ TestColumn.new('xb'),
38
+ TestColumn.new('abb'),
39
+ TestColumn.new('aaa')
40
+ ])
41
+
42
+ subject.columns('name').should eq [
43
+ TestColumn.new('aaa'),
44
+ TestColumn.new('abb'),
45
+ TestColumn.new('bbb'),
46
+ TestColumn.new('xb')
47
+ ]
48
+ end
49
+
50
+ class TestColumn < Struct.new(:name)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ lib = File.expand_path('../lib', File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'active_support'
5
+ require 'active_record'
6
+ require 'consistent_schema_rb'
7
+
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consistent_schema_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Aitken
@@ -89,13 +89,17 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - .gitignore
92
+ - .rspec
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md
95
96
  - Rakefile
96
97
  - consistent_schema_rb.gemspec
98
+ - lib/active_record/connection_adapters/ordered_column_postgresql_adapter.rb
97
99
  - lib/consistent_schema_rb.rb
98
100
  - lib/consistent_schema_rb/version.rb
101
+ - spec/active_record/connection_adapters/ordered_column_postgresql_apapter_spec.rb
102
+ - spec/spec_helper.rb
99
103
  homepage: http://github.com/alexaitken/consisten_schema_rb
100
104
  licenses:
101
105
  - MIT
@@ -121,4 +125,6 @@ signing_key:
121
125
  specification_version: 4
122
126
  summary: Orders columns from the active record adapters so the schema dumper will
123
127
  produce a consistent schema.rb
124
- test_files: []
128
+ test_files:
129
+ - spec/active_record/connection_adapters/ordered_column_postgresql_apapter_spec.rb
130
+ - spec/spec_helper.rb