columns 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/columns.gemspec +2 -0
- data/lib/columns/model_data.rb +3 -3
- data/lib/columns/version.rb +1 -1
- data/spec/fixtures/schema.rb +3 -0
- data/spec/model_data_spec.rb +29 -10
- data/spec/table_spec.rb +2 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6e4150d7daa5d6a80c2a0e2471d2a0ee4291e3
|
4
|
+
data.tar.gz: 4309ec347e7aa28699a18e0022a08a82b5ac4d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c2bd283ce7ea7c757a5811891d7d7b685dfef639bacf2ae626c4360ca7ba44caa00fdf011a25fd881085f0fc55936006f9af20d04e4e75f4e1953bf30a9b40
|
7
|
+
data.tar.gz: 55767d8e905644a81eb796ec84cab9c7492bac88f3c63d3dc84ad683b08f3a5cf33c234a853adf3e0efc96125240b4d13812861c2ff4f8030466921ef659236d
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Columns [![Gem Version](https://badge.fury.io/rb/columns.svg)](http://badge.fury.io/rb/columns)
|
1
|
+
# Columns [![Gem Version](https://badge.fury.io/rb/columns.svg)](http://badge.fury.io/rb/columns) [![Inline docs](http://inch-ci.org/github/tigerlily/columns.png?branch=master)](http://inch-ci.org/github/tigerlily/columns) [![Dependency Status](https://gemnasium.com/tigerlily/columns.svg)](https://gemnasium.com/tigerlily/columns)
|
2
2
|
|
3
3
|
Annotates activerecord models using `db/schema.rb`.
|
4
4
|
|
data/columns.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.required_ruby_version = ['>=2.0.0', '<2.2.0']
|
20
20
|
|
21
|
+
spec.add_runtime_dependency "activesupport"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6.0"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
spec.add_development_dependency "rspec", '~>3.0.0'
|
data/lib/columns/model_data.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
1
3
|
module Columns
|
2
4
|
|
3
5
|
# Stores data about a model.
|
@@ -31,9 +33,7 @@ module Columns
|
|
31
33
|
#
|
32
34
|
# raw_data - A RawData object.
|
33
35
|
def initialize(raw_data)
|
34
|
-
|
35
|
-
# the future.
|
36
|
-
@name = raw_data.name[0...-1]
|
36
|
+
@name = raw_data.name.singularize
|
37
37
|
|
38
38
|
contents = raw_data.content.split("\n")
|
39
39
|
contents.map! {|line| "# #{line.gsub(/^\s*t\./, '')}\n" }
|
data/lib/columns/version.rb
CHANGED
data/spec/fixtures/schema.rb
CHANGED
data/spec/model_data_spec.rb
CHANGED
@@ -2,19 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ModelData do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
context 'with a simple singular' do
|
6
|
+
before do
|
7
|
+
table = Table.new(schema_file)
|
8
|
+
raw = RawData.new('assignments', table.content_for('assignments'))
|
9
|
+
@subject = ModelData.new(raw)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'provides the name of the model' do
|
13
|
+
expect(@subject.name).to eq 'assignment'
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
|
16
|
+
it 'provides a «ready to paste» column names/types' do
|
17
|
+
content = "# integer \"foo\"\n# string \"bar\"\n"
|
18
|
+
expect(@subject.content).to eq content
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
22
|
+
context 'with a complex singular' do
|
23
|
+
before do
|
24
|
+
table = Table.new(schema_file)
|
25
|
+
raw = RawData.new('policies', table.content_for('policies'))
|
26
|
+
@subject = ModelData.new(raw)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'provides the name of the model' do
|
30
|
+
expect(@subject.name).to eq 'policy'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'provides a «ready to paste» column names/types' do
|
34
|
+
content = "# string \"name\"\n"
|
35
|
+
expect(@subject.content).to eq content
|
36
|
+
end
|
18
37
|
end
|
19
38
|
end
|
20
39
|
|
data/spec/table_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Table do
|
|
5
5
|
before { @table = Table.new(schema_file) }
|
6
6
|
|
7
7
|
it 'find the right count of tables in the schema' do
|
8
|
-
expect(@table.names.size).to eq
|
8
|
+
expect(@table.names.size).to eq 5
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'find the right count of tables in a fake schema' do
|
@@ -14,7 +14,7 @@ describe Table do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "find the right table's names in the schema" do
|
17
|
-
names = ['assignments', 'products', 'users', 'users_3']
|
17
|
+
names = ['assignments', 'products', 'users', 'users_3', 'policies']
|
18
18
|
@table.names.each do |name|
|
19
19
|
expect(names.include?(name)).to be true
|
20
20
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: columns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lkdjiin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
157
|
requirements:
|
144
158
|
- sed
|
145
159
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.2.
|
160
|
+
rubygems_version: 2.2.2
|
147
161
|
signing_key:
|
148
162
|
specification_version: 4
|
149
163
|
summary: Annotates activerecord models using `db/schema.rb`.
|