postgres_ext 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +125 -7
  2. data/lib/postgres_ext/version.rb +1 -1
  3. metadata +4 -4
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
1
  # PostgresExt
2
2
 
3
- ## Current Status: [![Build Status](https://secure.travis-ci.org/dockyard/postgres_ext.png?branch=master)](http://travis-ci.org/dockyard/postgres_ext)
4
-
5
3
  Adds support for missing PostgreSQL data types to ActiveRecord.
6
4
 
7
- ## Data Type Supported by postgres_ext
5
+ ## Current Status: [![Build Status](https://secure.travis-ci.org/dockyard/postgres_ext.png?branch=master)](http://travis-ci.org/dockyard/postgres_ext)
8
6
 
9
- * INET
10
- * CIDR
11
- * MACADDR
12
- * Arrays
7
+ ## Roadmap
8
+
9
+ * Arel support for INET, CIDR and Array related where clauses
10
+ * Backport HStore code from Rails 4.0
13
11
 
14
12
  ## Installation
15
13
 
@@ -30,6 +28,126 @@ Or install it yourself as:
30
28
  Just `require 'postgres_ext'` and use ActiveRecord as you normally would! postgres_ext extends
31
29
  ActiveRecord's data type handling.
32
30
 
31
+ * [Migration/Schema.rb support](#migrationschemarb-support)
32
+ * [Type Casting support](#type-casting-support)
33
+
34
+ ## Migration/Schema.rb support
35
+
36
+ ### INET
37
+
38
+ ```ruby
39
+ create_table :testing do |t|
40
+ t.inet :inet_column
41
+ # or
42
+ t.inet :inet_column_1, :inet_column_2
43
+ # or
44
+ t.column :inet_column, :inet
45
+ end
46
+ ```
47
+
48
+ ### CIDR
49
+
50
+ ```ruby
51
+ create_table :testing do |t|
52
+ t.cidr :cidr_column
53
+ # or
54
+ t.cidr :cidr_column_1, :cidr_column_2
55
+ # or
56
+ t.column :cidr_column, :cidr
57
+ end
58
+ ```
59
+
60
+ ### MACADDR
61
+
62
+ ```ruby
63
+ create_table :testing do |t|
64
+ t.macaddr :macaddr_column
65
+ # or
66
+ t.macaddr :macaddr_column_1, :macaddr_column_2
67
+ # or
68
+ t.column :macaddr_column, :macaddr
69
+ end
70
+ ```
71
+
72
+ ### UUID
73
+
74
+ ```ruby
75
+ create_table :testing do |t|
76
+ t.uuid :uuid_column
77
+ # or
78
+ t.uuid :uuid_column_1, :uuid_column_2
79
+ # or
80
+ t.column :uuid_column, :uuid
81
+ end
82
+ ```
83
+
84
+ ### Arrays
85
+ Arrays are created from any ActiveRecord supported datatype (including
86
+ ones added by postgre\_ext), and respect length constraints
87
+
88
+ ```ruby
89
+ create_table :testing do |t|
90
+ t.integer :int_array, :array => true
91
+ # integer[]
92
+ t.integer :int_array, :array => true, :length => 2
93
+ # smallint[]
94
+ t.string :macaddr_column_1, :array => true, :length => 30
95
+ # char varying(30)[]
96
+ end
97
+ ```
98
+
99
+ ## Type Casting support
100
+
101
+ ### INET and CIDR
102
+ INET and CIDR values are converted to
103
+ [IPAddr](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/ipaddr/rdoc/IPAddr.html)
104
+ objects when retrieved from the database, or set as a string.
105
+
106
+ ```ruby
107
+ create_table :inet_examples do |t|
108
+ t.inet :ip_address
109
+ end
110
+
111
+ class InetExample < ActiveRecord::Base
112
+ end
113
+
114
+ inetExample = InetExample.new
115
+ inetExample.ip_address = '127.0.0.0/24'
116
+ inetExample.ip_address
117
+ # => #<IPAddr: IPv4:127.0.0.0/255.255.255.0>
118
+ inetExample.save
119
+
120
+ inet_2 = InetExample.first
121
+ inet_2.ip_address
122
+ # => #<IPAddr: IPv4:127.0.0.0/255.255.255.0>
123
+ ```
124
+
125
+ ### Arrays
126
+ Array values can be set with Array objects. Any array stored in the
127
+ database will be converted to a properly casted array of values on the
128
+ way out.
129
+
130
+ ```ruby
131
+ create_table :people do |t|
132
+ t.integer :favorite_numbers, :array => true
133
+ end
134
+
135
+ class Person < ActiveRecord::Base
136
+ end
137
+
138
+ person = Person.new
139
+ person.favorite_numbers = [1,2,3]
140
+ person.favorite_numbers
141
+ # => [1,2,3]
142
+ person.save
143
+
144
+ person_2 = Person.first
145
+ person_2.favoite_numbers
146
+ # => [1,2,3]
147
+ person_2.favoite_numbers.first.class
148
+ # => Fixnum
149
+ ```
150
+
33
151
  ## Authors
34
152
 
35
153
  Dan McClain [twitter](http://twitter.com/_danmcclain) [github](http://github.com/danmcclain)
@@ -1,3 +1,3 @@
1
1
  module PostgresExt
2
- VERSION = "0.0.4"
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-13 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -260,7 +260,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
260
  version: '0'
261
261
  segments:
262
262
  - 0
263
- hash: 3732167881334618764
263
+ hash: -2955778538883923768
264
264
  required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  none: false
266
266
  requirements:
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  segments:
271
271
  - 0
272
- hash: 3732167881334618764
272
+ hash: -2955778538883923768
273
273
  requirements: []
274
274
  rubyforge_project:
275
275
  rubygems_version: 1.8.23