columns 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3ff33be328367ac7f16150d7c87cec4891b54ca
4
- data.tar.gz: 817bf28d02f4c310be9832a7bcbd5e40560a7ffb
3
+ metadata.gz: de6e4150d7daa5d6a80c2a0e2471d2a0ee4291e3
4
+ data.tar.gz: 4309ec347e7aa28699a18e0022a08a82b5ac4d97
5
5
  SHA512:
6
- metadata.gz: aef0e376d466374e9878fc72932f286cc8eb4e37c1c464373ab0a42b78ff07e8a96b6e8beff265c535130845e098a36ca2ce2fc52a00c0dfea25b3f4f9ac654a
7
- data.tar.gz: cd57c85f88899b8a71eb1c0522885a8cbe616f06a06ed2aadfd9f5335a6d481edb97709c98bc20cde82b5a887db1ee5c76e20b5afa27d9b52eda2734560b85cd
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
 
@@ -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'
@@ -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
- # Ok, this is really idiot, I know, I know. Must use inflectors in
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" }
@@ -1,3 +1,3 @@
1
1
  module Columns
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -39,5 +39,8 @@ ActiveRecord::Schema.define(version: 20140522124819) do
39
39
  t.string "name"
40
40
  end
41
41
 
42
+ create_table "policies", force: true do |t|
43
+ t.string "name"
44
+ end
42
45
  end
43
46
 
@@ -2,19 +2,38 @@ require 'spec_helper'
2
2
 
3
3
  describe ModelData do
4
4
 
5
- before do
6
- table = Table.new(schema_file)
7
- raw = RawData.new('assignments', table.content_for('assignments'))
8
- @subject = ModelData.new(raw)
9
- end
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
- it 'provides the name of the model' do
12
- expect(@subject.name).to eq 'assignment'
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
- it 'provides a «ready to paste» column names/types' do
16
- content = "# integer \"foo\"\n# string \"bar\"\n"
17
- expect(@subject.content).to eq content
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
 
@@ -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 4
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.1.1
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-18 00:00:00.000000000 Z
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.0.rc.1
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`.