dumbo 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -1
  4. data/bin/dumbo +65 -24
  5. data/config/boot.rb +2 -3
  6. data/dumbo.gemspec +1 -2
  7. data/lib/dumbo.rb +17 -16
  8. data/lib/dumbo/aggregate.rb +3 -5
  9. data/lib/dumbo/base_type.rb +17 -17
  10. data/lib/dumbo/binding_loader.rb +50 -0
  11. data/lib/dumbo/cast.rb +5 -5
  12. data/lib/dumbo/composite_type.rb +4 -4
  13. data/lib/dumbo/db_task.rb +6 -5
  14. data/lib/dumbo/dependency_resolver.rb +17 -18
  15. data/lib/dumbo/enum_type.rb +3 -4
  16. data/lib/dumbo/extension.rb +64 -20
  17. data/lib/dumbo/extension_migrator.rb +11 -11
  18. data/lib/dumbo/extension_version.rb +29 -11
  19. data/lib/dumbo/function.rb +21 -21
  20. data/lib/dumbo/operator.rb +4 -6
  21. data/lib/dumbo/pg_object.rb +17 -21
  22. data/lib/dumbo/rake_task.rb +63 -53
  23. data/lib/dumbo/range_type.rb +6 -9
  24. data/lib/dumbo/test.rb +8 -0
  25. data/lib/dumbo/test/fixture.rb +51 -0
  26. data/lib/dumbo/test/helper.rb +64 -0
  27. data/lib/dumbo/test/matchers.rb +76 -0
  28. data/lib/dumbo/test/regression_helper.rb +20 -0
  29. data/lib/dumbo/test/silence_unknown_oid.rb +12 -0
  30. data/lib/dumbo/type.rb +3 -4
  31. data/lib/dumbo/version.rb +1 -1
  32. data/spec/aggregate_spec.rb +9 -10
  33. data/spec/cast_spec.rb +5 -5
  34. data/spec/{Makefile → dumbo_sample/Makefile} +4 -0
  35. data/spec/{dumbo_sample--0.0.1.sql → dumbo_sample/dumbo_sample--0.0.1.sql} +0 -0
  36. data/spec/{dumbo_sample--0.0.2.sql → dumbo_sample/dumbo_sample--0.0.2.sql} +0 -0
  37. data/spec/dumbo_sample/dumbo_sample--0.0.3.sql +7 -0
  38. data/spec/dumbo_sample/dumbo_sample--0.0.4.sql +13 -0
  39. data/spec/{dumbo_sample.control → dumbo_sample/dumbo_sample.control} +0 -0
  40. data/spec/dumbo_sample/src/dumbo_sample.c +13 -0
  41. data/spec/dumbo_sample/src/dumbo_sample.h +17 -0
  42. data/spec/extension_migrator_spec.rb +12 -11
  43. data/spec/extension_spec.rb +41 -12
  44. data/spec/extension_version_spec.rb +27 -0
  45. data/spec/operator_spec.rb +6 -7
  46. data/spec/spec_helper.rb +15 -9
  47. data/spec/support/extension_helper.rb +31 -0
  48. data/spec/support/silence_unknown_oid.rb +12 -0
  49. data/spec/type_spec.rb +59 -55
  50. data/template/Rakefile +6 -6
  51. data/template/spec/sample_spec.rb.erb +1 -1
  52. metadata +33 -31
  53. data/config/database.yml +0 -31
  54. data/lib/tasks/db.rake +0 -52
  55. data/lib/tasks/dumbo.rake +0 -23
  56. data/spec/support/sql_helper.rb +0 -23
@@ -1,15 +1,15 @@
1
1
  require 'rake'
2
2
  require 'rspec/core/rake_task'
3
- require 'dumbo/rake_task'
4
- require 'dumbo/db_task'
5
- require 'dumbo'
3
+ require 'dumbo/rake_task'
4
+ require 'dumbo/db_task'
5
+ require 'dumbo'
6
6
 
7
- load File.expand_path('../config/boot.rb',__FILE__)
7
+ load File.expand_path('../config/boot.rb', __FILE__)
8
8
 
9
9
  Dumbo::RakeTask.new(:dumbo)
10
10
  Dumbo::DbTask.new(:db)
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
 
13
- Dir.glob("lib/tasks/**/*.rake").each { |taskfile| load taskfile }
13
+ Dir.glob('lib/tasks/**/*.rake').each { |taskfile| load taskfile }
14
14
 
15
- task :default => ['dumbo:all', 'db:test:prepare', :spec]
15
+ task default: ['dumbo:all', 'db:test:prepare', :spec]
@@ -7,7 +7,7 @@ describe '<%= ext_name %>' do
7
7
 
8
8
  describe "function foo" do
9
9
  it "shoul return the input" do
10
- sql("SELECT foo(10)", 'foo').first.should eq 10
10
+ query("SELECT foo(10)").should match '10'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Kniep
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,28 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.14.0
47
+ version: 3.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.14.0
55
- - !ruby/object:Gem::Dependency
56
- name: factory_girl
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4.0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.0'
54
+ version: 3.0.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: activerecord
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -151,11 +137,11 @@ files:
151
137
  - Rakefile
152
138
  - bin/dumbo
153
139
  - config/boot.rb
154
- - config/database.yml
155
140
  - dumbo.gemspec
156
141
  - lib/dumbo.rb
157
142
  - lib/dumbo/aggregate.rb
158
143
  - lib/dumbo/base_type.rb
144
+ - lib/dumbo/binding_loader.rb
159
145
  - lib/dumbo/cast.rb
160
146
  - lib/dumbo/composite_type.rb
161
147
  - lib/dumbo/db_task.rb
@@ -169,21 +155,31 @@ files:
169
155
  - lib/dumbo/pg_object.rb
170
156
  - lib/dumbo/rake_task.rb
171
157
  - lib/dumbo/range_type.rb
158
+ - lib/dumbo/test.rb
159
+ - lib/dumbo/test/fixture.rb
160
+ - lib/dumbo/test/helper.rb
161
+ - lib/dumbo/test/matchers.rb
162
+ - lib/dumbo/test/regression_helper.rb
163
+ - lib/dumbo/test/silence_unknown_oid.rb
172
164
  - lib/dumbo/type.rb
173
165
  - lib/dumbo/version.rb
174
- - lib/tasks/db.rake
175
- - lib/tasks/dumbo.rake
176
- - spec/Makefile
177
166
  - spec/aggregate_spec.rb
178
167
  - spec/cast_spec.rb
179
- - spec/dumbo_sample--0.0.1.sql
180
- - spec/dumbo_sample--0.0.2.sql
181
- - spec/dumbo_sample.control
168
+ - spec/dumbo_sample/Makefile
169
+ - spec/dumbo_sample/dumbo_sample--0.0.1.sql
170
+ - spec/dumbo_sample/dumbo_sample--0.0.2.sql
171
+ - spec/dumbo_sample/dumbo_sample--0.0.3.sql
172
+ - spec/dumbo_sample/dumbo_sample--0.0.4.sql
173
+ - spec/dumbo_sample/dumbo_sample.control
174
+ - spec/dumbo_sample/src/dumbo_sample.c
175
+ - spec/dumbo_sample/src/dumbo_sample.h
182
176
  - spec/extension_migrator_spec.rb
183
177
  - spec/extension_spec.rb
178
+ - spec/extension_version_spec.rb
184
179
  - spec/operator_spec.rb
185
180
  - spec/spec_helper.rb
186
- - spec/support/sql_helper.rb
181
+ - spec/support/extension_helper.rb
182
+ - spec/support/silence_unknown_oid.rb
187
183
  - spec/type_spec.rb
188
184
  - template/Gemfile
189
185
  - template/Makefile.erb
@@ -216,15 +212,21 @@ signing_key:
216
212
  specification_version: 4
217
213
  summary: postgres extension with fun
218
214
  test_files:
219
- - spec/Makefile
220
215
  - spec/aggregate_spec.rb
221
216
  - spec/cast_spec.rb
222
- - spec/dumbo_sample--0.0.1.sql
223
- - spec/dumbo_sample--0.0.2.sql
224
- - spec/dumbo_sample.control
217
+ - spec/dumbo_sample/Makefile
218
+ - spec/dumbo_sample/dumbo_sample--0.0.1.sql
219
+ - spec/dumbo_sample/dumbo_sample--0.0.2.sql
220
+ - spec/dumbo_sample/dumbo_sample--0.0.3.sql
221
+ - spec/dumbo_sample/dumbo_sample--0.0.4.sql
222
+ - spec/dumbo_sample/dumbo_sample.control
223
+ - spec/dumbo_sample/src/dumbo_sample.c
224
+ - spec/dumbo_sample/src/dumbo_sample.h
225
225
  - spec/extension_migrator_spec.rb
226
226
  - spec/extension_spec.rb
227
+ - spec/extension_version_spec.rb
227
228
  - spec/operator_spec.rb
228
229
  - spec/spec_helper.rb
229
- - spec/support/sql_helper.rb
230
+ - spec/support/extension_helper.rb
231
+ - spec/support/silence_unknown_oid.rb
230
232
  - spec/type_spec.rb
@@ -1,31 +0,0 @@
1
- # general postgres settings
2
- # Connect on a TCP socket. Omitted by default since the client uses a
3
- # domain socket that doesn't need configuration. Windows does not have
4
- # domain sockets, so uncomment these lines.
5
- # host: localhost
6
- # port: 5432
7
-
8
- # Schema search path. The server defaults to $user,public
9
- # schema_search_path: myapp,sharedapp,public
10
-
11
- # Minimum log levels, in increasing order:
12
- # debug5, debug4, debug3, debug2, debug1,
13
- # log, notice, warning, error, fatal, and panic
14
- # The server defaults to notice.
15
- # min_messages: warning
16
-
17
- postgres: &postgres
18
- adapter: postgresql
19
- encoding: utf8
20
- pool: 5
21
- username: postgres
22
- password:
23
- host: localhost
24
-
25
- development:
26
- <<: *postgres
27
- database: dumbo_development
28
-
29
- test:
30
- <<: *postgres
31
- database: dumbo_test
@@ -1,52 +0,0 @@
1
- require 'yaml'
2
- require 'logger'
3
- require 'active_record'
4
-
5
- task environment: ['db:configure_connection' ]
6
-
7
- task :test_env do
8
- ENV['DUMBO_ENV'] = 'test'
9
- end
10
-
11
- namespace :db do
12
- def create_database(config)
13
- ActiveRecord::Base.establish_connection config.merge('database' => nil)
14
- ActiveRecord::Base.connection.create_database config['database'], config
15
- ActiveRecord::Base.establish_connection config
16
- end
17
-
18
- task :configuration do
19
- @config = YAML.load_file('config/database.yml')[ENV['DUMBO_ENV']]
20
- end
21
-
22
- task configure_connection: :configuration do
23
- ActiveRecord::Base.establish_connection @config
24
- ActiveRecord::Base.logger = Logger.new STDOUT if @config['logger']
25
- end
26
-
27
- desc 'Create the database from config/database.yml for the current ENV'
28
- task create: :environment do
29
- create_database @config
30
- end
31
-
32
- desc 'Drops the database for the current ENV'
33
- task drop: :environment do
34
- ActiveRecord::Base.establish_connection @config.merge('database' => nil)
35
- ActiveRecord::Base.connection.drop_database @config['database']
36
- end
37
-
38
- namespace :test do
39
- task :environment do
40
- ENV['DUMBO_ENV'] ||= 'test'
41
- ActiveRecord::Schema.verbose = false
42
- end
43
-
44
- task load_structure: :environment do
45
- filename = ENV['DB_STRUCTURE'] || File.join("db", "structure.sql")
46
- ActiveRecord::Tasks::DatabaseTasks.structure_load(@config, filename)
47
- end
48
-
49
- desc "Re-create and prepare test database"
50
- task prepare: [:environment, :drop, :create]
51
- end
52
- end
@@ -1,23 +0,0 @@
1
- require 'erubis'
2
- require 'pathname'
3
-
4
- task :default => ['dumbo:all', :spec]
5
-
6
- namespace :dumbo do
7
- include Dumbo::RakeHelper
8
-
9
- task :all => ["#{extension}--#{version}.sql", :install]
10
-
11
- desc 'installs the extension'
12
- task :install do
13
- system('make clean && make && make install')
14
- end
15
-
16
- desc 'concatenates files'
17
- file "#{extension}--#{version}.sql" => file_list do |t|
18
- sql = t.prerequisites.map do |file|
19
- ["--source file #{file}"] + get_sql(file) + [" "]
20
- end.flatten
21
- concatenate sql, t.name
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- module SqlHelper
2
- def sql(sql, field = nil)
3
- result = ActiveRecord::Base.connection.select_all(sql, 'SQL', [])
4
- hash = result.to_hash
5
- result = hash.map do |h|
6
- hash_map = h.map do |k, v|
7
- type = result.column_types[k]
8
- casted_value = type.type_cast v
9
- [k, casted_value]
10
- end
11
- Hash[hash_map]
12
- end
13
- # binding.pry
14
- field ? result.map{|h| h[field]} : result
15
- end
16
-
17
- def install_extension
18
- sql "CREATE EXTENSION #{Dumbo::Extension.new.name}"
19
- end
20
- end
21
-
22
-
23
-