schema_plus_columns 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +18 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +123 -0
- data/Rakefile +9 -0
- data/gemfiles/Gemfile.base +4 -0
- data/gemfiles/activerecord-4.2/Gemfile.base +3 -0
- data/gemfiles/activerecord-4.2/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-4.2/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-4.2/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/columns.rb +7 -0
- data/lib/schema_plus/columns/active_record/connection_adapters/column.rb +65 -0
- data/lib/schema_plus/columns/middleware/model.rb +16 -0
- data/lib/schema_plus/columns/version.rb +5 -0
- data/lib/schema_plus_columns.rb +1 -0
- data/schema_dev.yml +8 -0
- data/schema_plus_columns.gemspec +29 -0
- data/spec/column_spec.rb +156 -0
- data/spec/sanity_spec.rb +13 -0
- data/spec/spec_helper.rb +22 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2e50ad0886c5c588922f16d17e739cf967af4a9
|
4
|
+
data.tar.gz: ab16108afe29a0887682963e9e15ac75345222a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ad20f2b42667c98fe210b2b6a825c8cd7b7359c49d7beea5c7145b141b1d753a3113ae09cb70ffdbd5a60a4d2640cee3d087d8d7833f13b0b1dbd321af671c3
|
7
|
+
data.tar.gz: 6b642322e885a7ef600d0b322de619283168b33b6d45b4f4ceff6187c3dbbf2524637b4add79747b676878a4758b0a66cc59aaecb07fbb4d0590f327d555d4af
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was auto-generated by the schema_dev tool, based on the data in
|
2
|
+
# ./schema_dev.yml
|
3
|
+
# Please do not edit this file; any changes will be overwritten next time
|
4
|
+
# schema_dev gets run.
|
5
|
+
---
|
6
|
+
sudo: false
|
7
|
+
rvm:
|
8
|
+
- 2.1.5
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
11
|
+
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
12
|
+
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
13
|
+
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
14
|
+
addons:
|
15
|
+
postgresql: '9.3'
|
16
|
+
before_script: bundle exec rake create_databases
|
17
|
+
after_script: bundle exec rake drop_databases
|
18
|
+
script: bundle exec rake travis
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 ronen barzel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/schema_plus_columns.svg)](http://badge.fury.io/rb/schema_plus_columns)
|
2
|
+
[![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_columns.svg)](http://travis-ci.org/SchemaPlus/schema_plus_columns)
|
3
|
+
[![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_plus_columns.svg)](https://coveralls.io/r/SchemaPlus/schema_plus_columns)
|
4
|
+
[![Dependency Status](https://gemnasium.com/lomba/schema_plus_columns.svg)](https://gemnasium.com/SchemaPlus/schema_plus_columns)
|
5
|
+
|
6
|
+
# SchemaPlus::Columns
|
7
|
+
|
8
|
+
SchemaPlus::Columns adds some useful accessors the objects returned by ActiveRecord's [`Model.columns`](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/SchemaStatements.html#method-i-columns) database introspection query.
|
9
|
+
|
10
|
+
SchemaPlus::Columns is part of the [SchemaPlus](https://github.com/SchemaPlus/) family of Ruby on Rails extension gems.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
<!-- SCHEMA_DEV: TEMPLATE INSTALLATION - begin -->
|
15
|
+
<!-- These lines are auto-inserted from a schema_dev template -->
|
16
|
+
As usual:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem "schema_plus_columns" # in a Gemfile
|
20
|
+
gem.add_dependency "schema_plus_columns" # in a .gemspec
|
21
|
+
```
|
22
|
+
|
23
|
+
To use with a rails app, also include
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem "schema_monkey_rails"
|
27
|
+
```
|
28
|
+
|
29
|
+
which creates a Railtie to that will insert SchemaPlus::Columns appropriately into the rails stack. To use with Padrino, see [schema_monkey_padrino](https://github.com/SchemaPlus/schema_monkey_padrino).
|
30
|
+
|
31
|
+
<!-- SCHEMA_DEV: TEMPLATE INSTALLATION - end -->
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
SchemaPlus::Columns makes these accessors available:
|
36
|
+
|
37
|
+
#### `column.indexes`
|
38
|
+
|
39
|
+
Returns a list of index definitions for each index that refers to this column. Returns an empty list if there are no such indexes.
|
40
|
+
|
41
|
+
#### `column.unique?`
|
42
|
+
|
43
|
+
Returns true if the column is in a unique index.
|
44
|
+
|
45
|
+
#### `column.unique_scope`
|
46
|
+
|
47
|
+
If the column is in a unique index, returns a list of names of other columns in the index. Returns an empty list if it's a single-column index. Returns nil if the column is not in a unique index.
|
48
|
+
|
49
|
+
#### `column.case_sensitive?`
|
50
|
+
|
51
|
+
Returns true if the column is in one or more indexes that are case sensitive. *Requires the index definitions to respond to `:case_sensitive?`* -- i.e. Only works with `schema_plus_pg_indexes` having been loaded.
|
52
|
+
|
53
|
+
#### `column.required_on`
|
54
|
+
|
55
|
+
Returns an indicator of the circumstance in which the column must have a value:
|
56
|
+
|
57
|
+
* `nil` If the column may be null
|
58
|
+
* `:save` If the column has no default value
|
59
|
+
* `:update` Otherwise
|
60
|
+
|
61
|
+
|
62
|
+
## Compatibility
|
63
|
+
|
64
|
+
SchemaPlus::Columns is tested on:
|
65
|
+
|
66
|
+
<!-- SCHEMA_DEV: MATRIX - begin -->
|
67
|
+
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
68
|
+
* ruby **2.1.5** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
|
69
|
+
|
70
|
+
<!-- SCHEMA_DEV: MATRIX - end -->
|
71
|
+
|
72
|
+
|
73
|
+
## History
|
74
|
+
|
75
|
+
* 0.1.0 - Initial release, extracted from SchemaPlus 1.x
|
76
|
+
|
77
|
+
## Development & Testing
|
78
|
+
|
79
|
+
Are you interested in contributing to SchemaPlus::Columns? Thanks! Please follow
|
80
|
+
the standard protocol: fork, feature branch, develop, push, and issue pull
|
81
|
+
request.
|
82
|
+
|
83
|
+
Some things to know about to help you develop and test:
|
84
|
+
|
85
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - begin -->
|
86
|
+
<!-- These lines are auto-inserted from a schema_dev template -->
|
87
|
+
* **schema_dev**: SchemaPlus::Columns uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
88
|
+
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
89
|
+
versions that the gem supports, both locally and on
|
90
|
+
[travis-ci](http://travis-ci.org/SchemaPlus/schema_plus_columns)
|
91
|
+
|
92
|
+
To to run rspec locally on the full matrix, do:
|
93
|
+
|
94
|
+
$ schema_dev bundle install
|
95
|
+
$ schema_dev rspec
|
96
|
+
|
97
|
+
You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README.
|
98
|
+
|
99
|
+
The matrix of configurations is specified in `schema_dev.yml` in
|
100
|
+
the project root.
|
101
|
+
|
102
|
+
|
103
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
|
104
|
+
|
105
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin -->
|
106
|
+
<!-- These lines are auto-inserted from a schema_dev template -->
|
107
|
+
* **schema_plus_core**: SchemaPlus::Columns uses the SchemaPlus::Core API that
|
108
|
+
provides middleware callback stacks to make it easy to extend
|
109
|
+
ActiveRecord's behavior. If that API is missing something you need for
|
110
|
+
your contribution, please head over to
|
111
|
+
[schema_plus_core](https://github/SchemaPlus/schema_plus_core) and open
|
112
|
+
an issue or pull request.
|
113
|
+
|
114
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - end -->
|
115
|
+
|
116
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_MONKEY - begin -->
|
117
|
+
<!-- These lines are auto-inserted from a schema_dev template -->
|
118
|
+
* **schema_monkey**: SchemaPlus::Columns is implemented as a
|
119
|
+
[schema_monkey](https://github.com/SchemaPlus/schema_monkey) client,
|
120
|
+
using [schema_monkey](https://github.com/SchemaPlus/schema_monkey)'s
|
121
|
+
convention-based protocols for extending ActiveRecord and using middleware stacks.
|
122
|
+
|
123
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_MONKEY - end -->
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
module SchemaPlus::Columns
|
2
|
+
module ActiveRecord
|
3
|
+
module ConnectionAdapters
|
4
|
+
|
5
|
+
#
|
6
|
+
# SchemaPlus::Index adds several methods to Column
|
7
|
+
#
|
8
|
+
module Column
|
9
|
+
|
10
|
+
attr_writer :model # model assigned set by Middleware::Model::Columns
|
11
|
+
|
12
|
+
# Returns the list of IndexDefinition instances for each index that
|
13
|
+
# refers to this column. Returns an empty list if there are no
|
14
|
+
# such indexes.
|
15
|
+
def indexes
|
16
|
+
@indexes ||= @model.indexes.select{|index| index.columns.include? self.name}
|
17
|
+
end
|
18
|
+
|
19
|
+
# If the column is in a unique index, returns a list of names of other columns in
|
20
|
+
# the index. Returns an empty list if it's a single-column index.
|
21
|
+
# Returns nil if the column is not in a unique index.
|
22
|
+
def unique_scope
|
23
|
+
if index = indexes.select{|i| i.unique}.sort_by{|i| i.columns.size}.first
|
24
|
+
index.columns.reject{|name| name == self.name}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns true if the column is in a unique index. See also
|
29
|
+
# unique_scope
|
30
|
+
def unique?
|
31
|
+
indexes.any?{|i| i.unique}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns true if the column is in one or more indexes that are
|
35
|
+
# case sensitive. Will raise exception if
|
36
|
+
# IndexDefinition#case_sensitive? isn't defined, i.e. if
|
37
|
+
# schema_plus_pg_indexes hasn't been loaded.
|
38
|
+
def case_sensitive?
|
39
|
+
indexes.any?{|i| i.case_sensitive?}
|
40
|
+
end
|
41
|
+
|
42
|
+
# The default as_jon includes all instance variables. but
|
43
|
+
# @model can't be dumped (it contains circular references)
|
44
|
+
def as_json(options=nil)
|
45
|
+
instance_values.except "model", "adapter"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the circumstance in which the column must have a value:
|
49
|
+
# nil if the column may be null
|
50
|
+
# :save if the column has no default value
|
51
|
+
# :update otherwise
|
52
|
+
def required_on
|
53
|
+
if null
|
54
|
+
nil
|
55
|
+
elsif default.nil?
|
56
|
+
:save
|
57
|
+
else
|
58
|
+
:update
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'schema_plus/columns'
|
data/schema_dev.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'schema_plus/columns/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "schema_plus_columns"
|
8
|
+
gem.version = SchemaPlus::Columns::VERSION
|
9
|
+
gem.authors = ["ronen barzel"]
|
10
|
+
gem.email = ["ronen@barzel.org"]
|
11
|
+
gem.summary = %q{Adds useful accessors to ActiveRecord's Column object.}
|
12
|
+
gem.homepage = "https://github.com/SchemaPlus/schema_plus_columns"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = `git ls-files -z`.split("\x0")
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "activerecord", "~> 4.2"
|
21
|
+
gem.add_dependency "schema_plus_indexes", "~> 0.1"
|
22
|
+
|
23
|
+
gem.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
25
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
gem.add_development_dependency "schema_dev", "~> 3.2", ">= 3.2.2"
|
27
|
+
gem.add_development_dependency "simplecov"
|
28
|
+
gem.add_development_dependency "simplecov-gem-profile"
|
29
|
+
end
|
data/spec/column_spec.rb
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Column" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
class User < ::ActiveRecord::Base ; end
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:migration) { ::ActiveRecord::Migration }
|
10
|
+
|
11
|
+
context "JSON serialization" do
|
12
|
+
before(:each) do
|
13
|
+
create_table(User, :login => { :index => true})
|
14
|
+
@login = User.columns.find{|column| column.name == "login"}
|
15
|
+
end
|
16
|
+
it "works properly" do
|
17
|
+
type = case
|
18
|
+
when SchemaDev::Rspec::Helpers.mysql?
|
19
|
+
{ "sql_type" => "varchar(255)" }
|
20
|
+
when SchemaDev::Rspec::Helpers.postgresql?
|
21
|
+
{ "sql_type" => "character varying" }
|
22
|
+
when SchemaDev::Rspec::Helpers.sqlite3?
|
23
|
+
{ "sql_type" => "varchar" }
|
24
|
+
end
|
25
|
+
expect(JSON.parse(@login.to_json)).to include(type.merge("name" => "login"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "regarding indexes" do
|
30
|
+
|
31
|
+
context "if not unique" do
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
create_table(User, :login => { :index => true})
|
35
|
+
@login = User.columns.find{|column| column.name == "login"}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should report not unique" do
|
39
|
+
expect(@login).not_to be_unique
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should report nil unique scope" do
|
43
|
+
create_table(User, :login => { :index => true})
|
44
|
+
expect(@login.unique_scope).to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "if unique single column" do
|
49
|
+
before(:each) do
|
50
|
+
create_table(User, :login => { :index => :unique})
|
51
|
+
@login = User.columns.find{|column| column.name == "login"}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should report unique" do
|
55
|
+
expect(@login).to be_unique
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should report an empty unique scope" do
|
59
|
+
expect(@login.unique_scope).to eq([])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "if unique multicolumn" do
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
create_table(User, :first => {}, :middle => {}, :last => { :index => {:with => [:first, :middle], :unique => true}})
|
67
|
+
@first = User.columns.find{|column| column.name == "first"}
|
68
|
+
@middle = User.columns.find{|column| column.name == "middle"}
|
69
|
+
@last = User.columns.find{|column| column.name == "last"}
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should report unique for each" do
|
73
|
+
expect(@first).to be_unique
|
74
|
+
expect(@middle).to be_unique
|
75
|
+
expect(@last).to be_unique
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should report unique scope for each" do
|
79
|
+
expect(@first.unique_scope).to match_array(%W[middle last])
|
80
|
+
expect(@middle.unique_scope).to match_array(%W[first last])
|
81
|
+
expect(@last.unique_scope).to match_array(%W[first middle])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with case insensitive" do
|
86
|
+
before(:each) do
|
87
|
+
create_table(User, :login => { :index => {}})
|
88
|
+
User.reset_column_information
|
89
|
+
@column = User.columns.find(&its.name == "login")
|
90
|
+
end
|
91
|
+
|
92
|
+
context "index", :mysql => :skip do
|
93
|
+
|
94
|
+
it "reports column as case insensitive" do
|
95
|
+
allow(User.indexes.first).to receive(:case_sensitive?).and_return(false);
|
96
|
+
expect(@column).not_to be_case_sensitive
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "database", :mysql => :only do
|
101
|
+
|
102
|
+
# make sure we haven't broken mysql's method
|
103
|
+
it "reports column as case insensitive" do
|
104
|
+
allow(migration).to receive(:collation).and_return("utf8_unicode_ci") # mysql determines case insensitivity its own way
|
105
|
+
expect(@column).not_to be_case_sensitive
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
context "regarding when it requires a value" do
|
113
|
+
|
114
|
+
it "not required if the column can be null" do
|
115
|
+
create_table(User, :login => { :null => true})
|
116
|
+
expect(User.columns.find{|column| column.name == "login"}.required_on).to be_nil
|
117
|
+
end
|
118
|
+
|
119
|
+
it "must have a value on :save if there's no default" do
|
120
|
+
create_table(User, :login => { :null => false })
|
121
|
+
expect(User.columns.find{|column| column.name == "login"}.required_on).to eq(:save)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "must have a value on :update if there's default" do
|
125
|
+
create_table(User, :login => { :null => false, :default => "foo" })
|
126
|
+
expect(User.columns.find{|column| column.name == "login"}.required_on).to eq(:update)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context "Postgresql array", :postgresql => :only do
|
132
|
+
|
133
|
+
before(:each) do
|
134
|
+
create_table(User, :alpha => { :default => [], :array => true })
|
135
|
+
end
|
136
|
+
|
137
|
+
it "respects array: true" do
|
138
|
+
column = User.columns.find(&its.name == "alpha")
|
139
|
+
expect(column.array).to be_truthy
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
protected
|
144
|
+
|
145
|
+
def create_table(model, columns_with_options)
|
146
|
+
migration.suppress_messages do
|
147
|
+
migration.create_table model.table_name, :force => true do |t|
|
148
|
+
columns_with_options.each_pair do |column, options|
|
149
|
+
t.send :string, column, options
|
150
|
+
end
|
151
|
+
end
|
152
|
+
model.reset_column_information
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
data/spec/sanity_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
# A basic sanity check to have as a spec when first starting. Feel free to delete this
|
5
|
+
# once you've got real content.
|
6
|
+
|
7
|
+
describe "Sanity Check" do
|
8
|
+
|
9
|
+
it "database is connected" do
|
10
|
+
expect(ActiveRecord::Base).to be_connected
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'simplecov-gem-profile'
|
3
|
+
SimpleCov.start "gem"
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
|
8
|
+
require 'rspec'
|
9
|
+
require 'active_record'
|
10
|
+
require 'schema_plus_columns'
|
11
|
+
require 'schema_dev/rspec'
|
12
|
+
|
13
|
+
SchemaDev::Rspec.setup
|
14
|
+
|
15
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.warnings = true
|
19
|
+
end
|
20
|
+
|
21
|
+
SimpleCov.command_name "[ruby #{RUBY_VERSION} - ActiveRecord #{::ActiveRecord::VERSION::STRING} - #{ActiveRecord::Base.connection.adapter_name}]"
|
22
|
+
|
metadata
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: schema_plus_columns
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ronen barzel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: schema_plus_indexes
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: schema_dev
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.2.2
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '3.2'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.2.2
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: simplecov
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: simplecov-gem-profile
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
description:
|
132
|
+
email:
|
133
|
+
- ronen@barzel.org
|
134
|
+
executables: []
|
135
|
+
extensions: []
|
136
|
+
extra_rdoc_files: []
|
137
|
+
files:
|
138
|
+
- ".gitignore"
|
139
|
+
- ".travis.yml"
|
140
|
+
- Gemfile
|
141
|
+
- LICENSE.txt
|
142
|
+
- README.md
|
143
|
+
- Rakefile
|
144
|
+
- gemfiles/Gemfile.base
|
145
|
+
- gemfiles/activerecord-4.2/Gemfile.base
|
146
|
+
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
147
|
+
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
148
|
+
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
149
|
+
- lib/schema_plus/columns.rb
|
150
|
+
- lib/schema_plus/columns/active_record/connection_adapters/column.rb
|
151
|
+
- lib/schema_plus/columns/middleware/model.rb
|
152
|
+
- lib/schema_plus/columns/version.rb
|
153
|
+
- lib/schema_plus_columns.rb
|
154
|
+
- schema_dev.yml
|
155
|
+
- schema_plus_columns.gemspec
|
156
|
+
- spec/column_spec.rb
|
157
|
+
- spec/sanity_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
homepage: https://github.com/SchemaPlus/schema_plus_columns
|
160
|
+
licenses:
|
161
|
+
- MIT
|
162
|
+
metadata: {}
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 2.2.2
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: Adds useful accessors to ActiveRecord's Column object.
|
183
|
+
test_files:
|
184
|
+
- spec/column_spec.rb
|
185
|
+
- spec/sanity_spec.rb
|
186
|
+
- spec/spec_helper.rb
|