peegee 0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in peegee.gemspec
4
+ gemspec
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ peegee (0.0.1)
5
+ activerecord
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.7)
12
+ actionpack (= 3.0.7)
13
+ mail (~> 2.2.15)
14
+ actionpack (3.0.7)
15
+ activemodel (= 3.0.7)
16
+ activesupport (= 3.0.7)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.5.0)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.14)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.7)
25
+ activesupport (= 3.0.7)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.7)
29
+ activemodel (= 3.0.7)
30
+ activesupport (= 3.0.7)
31
+ arel (~> 2.0.2)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.7)
34
+ activemodel (= 3.0.7)
35
+ activesupport (= 3.0.7)
36
+ activesupport (3.0.7)
37
+ arel (2.0.10)
38
+ aruba (0.3.6)
39
+ childprocess (>= 0.1.7)
40
+ cucumber (>= 0.10.0)
41
+ rspec (>= 2.5.0)
42
+ builder (2.1.2)
43
+ childprocess (0.1.9)
44
+ ffi (~> 1.0.6)
45
+ columnize (0.3.2)
46
+ cucumber (0.10.3)
47
+ builder (>= 2.1.2)
48
+ diff-lcs (>= 1.1.2)
49
+ gherkin (>= 2.3.8)
50
+ json (>= 1.4.6)
51
+ term-ansicolor (>= 1.0.5)
52
+ diff-lcs (1.1.2)
53
+ erubis (2.6.6)
54
+ abstract (>= 1.0.0)
55
+ ffi (1.0.9)
56
+ gherkin (2.3.10)
57
+ json (>= 1.4.6)
58
+ i18n (0.5.0)
59
+ json (1.5.1)
60
+ linecache (0.43)
61
+ mail (2.2.19)
62
+ activesupport (>= 2.3.6)
63
+ i18n (>= 0.4.0)
64
+ mime-types (~> 1.16)
65
+ treetop (~> 1.4.8)
66
+ mime-types (1.16)
67
+ pg (0.11.0)
68
+ polyglot (0.3.1)
69
+ rack (1.2.3)
70
+ rack-mount (0.6.14)
71
+ rack (>= 1.0.0)
72
+ rack-test (0.5.7)
73
+ rack (>= 1.0)
74
+ rails (3.0.7)
75
+ actionmailer (= 3.0.7)
76
+ actionpack (= 3.0.7)
77
+ activerecord (= 3.0.7)
78
+ activeresource (= 3.0.7)
79
+ activesupport (= 3.0.7)
80
+ bundler (~> 1.0)
81
+ railties (= 3.0.7)
82
+ railties (3.0.7)
83
+ actionpack (= 3.0.7)
84
+ activesupport (= 3.0.7)
85
+ rake (>= 0.8.7)
86
+ thor (~> 0.14.4)
87
+ rake (0.8.7)
88
+ rspec (2.6.0)
89
+ rspec-core (~> 2.6.0)
90
+ rspec-expectations (~> 2.6.0)
91
+ rspec-mocks (~> 2.6.0)
92
+ rspec-core (2.6.3)
93
+ rspec-expectations (2.6.0)
94
+ diff-lcs (~> 1.1.2)
95
+ rspec-mocks (2.6.0)
96
+ ruby-debug (0.10.4)
97
+ columnize (>= 0.1)
98
+ ruby-debug-base (~> 0.10.4.0)
99
+ ruby-debug-base (0.10.4)
100
+ linecache (>= 0.3)
101
+ term-ansicolor (1.0.5)
102
+ thor (0.14.6)
103
+ treetop (1.4.9)
104
+ polyglot (>= 0.3.1)
105
+ tzinfo (0.3.27)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ aruba
112
+ cucumber
113
+ peegee!
114
+ pg
115
+ rails (= 3.0.7)
116
+ rspec-core
117
+ rspec-expectations
118
+ ruby-debug
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ Feature: Adding PostgreSQL specific indexes in a Rails migration
2
+ As a developer
3
+ I can add PostgreSQL index types in a migration
4
+ So that I can make better use of PostgreSQL indexes
5
+
6
+ Scenario: Adding a partial index
7
+ Given I create and configure the "peegee_test" rails app
8
+ And I run `script/rails generate model User name:string active:boolean`
9
+ And I run `script/rails generate migration add_index_to_active_users`
10
+ And I implement the latest migration as:
11
+ """
12
+ def self.up
13
+ add_index :users, :name, :name => 'users_name_where_active_true', :where => 'active = true'
14
+ end
15
+ def self.down
16
+ remove_index :users, :name
17
+ end
18
+ """
19
+ And I run `bundle exec rake db:migrate`
20
+ Then the "users" table should have the following index:
21
+ | CREATE INDEX users_name_where_active_true ON users USING btree (id) where active = true |
@@ -0,0 +1,10 @@
1
+ Given /^I implement the latest migration as:$/ do |implementation|
2
+ in_current_dir do
3
+ migrations = Dir["db/migrate/*rb"].to_a
4
+ path = migrations.last
5
+ contents = IO.read(path)
6
+ class_declaration = contents.split("\n").first
7
+ new_contents = "#{class_declaration}\n#{implementation}\nend"
8
+ File.open(path, "w") { |file| file.write(new_contents) }
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ Then /^the "(\w+)" table should have the following index(?:es)?:$/ do |table_name, indexes|
2
+ actual_indexes = select_all(<<-INDEX_SQL).map { |r| r["index_def"] }
3
+ SELECT pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) as index_def
4
+ FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
5
+ WHERE c.oid = '#{oid(table_name)}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
6
+ INDEX_SQL
7
+ actual_indexes.should include(*indexes.raw.flatten)
8
+ end
@@ -0,0 +1,22 @@
1
+ Given /^I create and configure the "(\w+)" rails app$/ do |name|
2
+ Given %{I run `rails new #{name} --database=postgresql -J -T -G`}
3
+ And %{I cd to "peegee_test"}
4
+
5
+ database_config = <<-CONFIG
6
+ development: &default
7
+ adapter: postgresql
8
+ encoding: unicode
9
+ database: peegee_development
10
+ pool: 5
11
+ min_messages: warning
12
+ test:
13
+ << default
14
+ database: peegee_test
15
+
16
+ CONFIG
17
+ in_current_dir do
18
+ File.open('config/database.yml', 'w') { |file| file.write(database_config) }
19
+ end
20
+ And %{I run `bundle install`}
21
+ And %{I run `bundle exec rake db:drop:all db:create:all`}
22
+ end
@@ -0,0 +1,6 @@
1
+ require 'aruba/cucumber'
2
+ require 'ruby-debug'
3
+
4
+ Before do
5
+ @aruba_timeout_seconds = 10
6
+ end
@@ -0,0 +1,30 @@
1
+ require 'active_record'
2
+ module SqlHelpers
3
+ def connection
4
+ @connection || begin
5
+ ActiveRecord::Base.establish_connection(
6
+ :adapter => 'postgresql',
7
+ :encoding => 'unicode',
8
+ :database => 'peegee_development'
9
+ )
10
+ ActiveRecord::Base.connection
11
+ end
12
+ end
13
+
14
+ def select_all(sql)
15
+ connection.select_all sql
16
+ end
17
+
18
+ def oid(table_name)
19
+ select_all(<<-SQL).first['oid']
20
+ SELECT c.oid
21
+ FROM pg_catalog.pg_class c
22
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
23
+ WHERE c.relname = '#{table_name}'
24
+ AND pg_catalog.pg_table_is_visible(c.oid);
25
+ SQL
26
+ end
27
+
28
+ end
29
+
30
+ World(SqlHelpers)
@@ -0,0 +1,3 @@
1
+ module Peegee
2
+ # Your code goes here...
3
+ end
@@ -0,0 +1,3 @@
1
+ module Peegee
2
+ VERSION = "0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "peegee/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "peegee"
7
+ s.version = Peegee::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Harold Giménez"]
10
+ s.email = ["hgimenez@thoughtbot.com"]
11
+ s.homepage = "http://github.com/peegee"
12
+ s.summary = %q{PostgreSQL extensions for ActiveRecord}
13
+ s.description = %q{Not much going on here yet.}
14
+
15
+ s.add_dependency 'activerecord'
16
+ s.add_development_dependency 'pg'
17
+ s.add_development_dependency 'cucumber'
18
+ s.add_development_dependency 'aruba'
19
+ s.add_development_dependency 'rspec-core'
20
+ s.add_development_dependency 'rspec-expectations'
21
+ s.add_development_dependency 'rails', '3.0.7'
22
+ s.add_development_dependency 'ruby-debug'
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
+ s.require_paths = ["lib"]
28
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peegee
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ version: "0"
9
+ platform: ruby
10
+ authors:
11
+ - "Harold Gim\xC3\xA9nez"
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2011-06-04 00:00:00 Z
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: activerecord
20
+ prerelease: false
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: pg
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: cucumber
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ type: :development
59
+ version_requirements: *id003
60
+ - !ruby/object:Gem::Dependency
61
+ name: aruba
62
+ prerelease: false
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ type: :development
73
+ version_requirements: *id004
74
+ - !ruby/object:Gem::Dependency
75
+ name: rspec-core
76
+ prerelease: false
77
+ requirement: &id005 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ version_requirements: *id005
88
+ - !ruby/object:Gem::Dependency
89
+ name: rspec-expectations
90
+ prerelease: false
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ type: :development
101
+ version_requirements: *id006
102
+ - !ruby/object:Gem::Dependency
103
+ name: rails
104
+ prerelease: false
105
+ requirement: &id007 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - "="
109
+ - !ruby/object:Gem::Version
110
+ hash: 9
111
+ segments:
112
+ - 3
113
+ - 0
114
+ - 7
115
+ version: 3.0.7
116
+ type: :development
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: ruby-debug
120
+ prerelease: false
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ type: :development
131
+ version_requirements: *id008
132
+ description: Not much going on here yet.
133
+ email:
134
+ - hgimenez@thoughtbot.com
135
+ executables: []
136
+
137
+ extensions: []
138
+
139
+ extra_rdoc_files: []
140
+
141
+ files:
142
+ - .gitignore
143
+ - Gemfile
144
+ - Gemfile.lock
145
+ - Rakefile
146
+ - features/create_indexes_in_migrations.feature
147
+ - features/step_definitions/migration_steps.rb
148
+ - features/step_definitions/postgres_steps.rb
149
+ - features/step_definitions/rails_steps.rb
150
+ - features/support/env.rb
151
+ - features/support/sql_helpers.rb
152
+ - lib/peegee.rb
153
+ - lib/peegee/version.rb
154
+ - peegee.gemspec
155
+ homepage: http://github.com/peegee
156
+ licenses: []
157
+
158
+ post_install_message:
159
+ rdoc_options: []
160
+
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 3
178
+ segments:
179
+ - 0
180
+ version: "0"
181
+ requirements: []
182
+
183
+ rubyforge_project:
184
+ rubygems_version: 1.7.2
185
+ signing_key:
186
+ specification_version: 3
187
+ summary: PostgreSQL extensions for ActiveRecord
188
+ test_files:
189
+ - features/create_indexes_in_migrations.feature
190
+ - features/step_definitions/migration_steps.rb
191
+ - features/step_definitions/postgres_steps.rb
192
+ - features/step_definitions/rails_steps.rb
193
+ - features/support/env.rb
194
+ - features/support/sql_helpers.rb