activerecord-postgres-hstore 0.1.0 → 0.1.2

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.
Files changed (66) hide show
  1. data/.rspec +1 -0
  2. data/Gemfile +14 -0
  3. data/Gemfile.lock +38 -0
  4. data/README.textile +23 -6
  5. data/Rakefile +37 -28
  6. data/VERSION +1 -1
  7. data/activerecord-postgres-hstore.gemspec +127 -0
  8. data/app/.gitignore +4 -0
  9. data/app/Gemfile +27 -0
  10. data/app/Gemfile.lock +75 -0
  11. data/app/README +256 -0
  12. data/app/Rakefile +7 -0
  13. data/app/app/controllers/application_controller.rb +3 -0
  14. data/app/app/helpers/application_helper.rb +2 -0
  15. data/app/app/models/bar.rb +3 -0
  16. data/app/app/models/foo.rb +3 -0
  17. data/app/app/views/layouts/application.html.erb +14 -0
  18. data/app/bench.rb +76 -0
  19. data/app/bench_results.txt +13 -0
  20. data/app/config.ru +4 -0
  21. data/app/config/application.rb +42 -0
  22. data/app/config/boot.rb +13 -0
  23. data/app/config/database.yml +51 -0
  24. data/app/config/environment.rb +5 -0
  25. data/app/config/environments/development.rb +22 -0
  26. data/app/config/environments/production.rb +49 -0
  27. data/app/config/environments/test.rb +35 -0
  28. data/app/config/initializers/activerecord_postgres_hstore.rb +0 -0
  29. data/app/config/initializers/backtrace_silencers.rb +7 -0
  30. data/app/config/initializers/inflections.rb +10 -0
  31. data/app/config/initializers/mime_types.rb +5 -0
  32. data/app/config/initializers/secret_token.rb +7 -0
  33. data/app/config/initializers/session_store.rb +8 -0
  34. data/app/config/locales/en.yml +5 -0
  35. data/app/config/routes.rb +58 -0
  36. data/app/db/development_structure.sql +578 -0
  37. data/app/db/migrate/20100906191151_add_hstore.rb +276 -0
  38. data/app/db/migrate/20100906191457_create_foos.rb +13 -0
  39. data/app/db/migrate/20100906191506_create_bars.rb +12 -0
  40. data/app/db/schema.rb +15 -0
  41. data/app/db/seeds.rb +7 -0
  42. data/app/doc/README_FOR_APP +2 -0
  43. data/app/generate_copy_files.rb +47 -0
  44. data/app/lib/tasks/.gitkeep +0 -0
  45. data/app/public/404.html +26 -0
  46. data/app/public/422.html +26 -0
  47. data/app/public/500.html +26 -0
  48. data/app/public/favicon.ico +0 -0
  49. data/app/public/images/rails.png +0 -0
  50. data/app/public/index.html +262 -0
  51. data/app/public/javascripts/.gitkeep +0 -0
  52. data/app/public/javascripts/application.js +0 -0
  53. data/app/public/robots.txt +5 -0
  54. data/app/public/stylesheets/.gitkeep +0 -0
  55. data/app/script/rails +6 -0
  56. data/app/test/performance/browsing_test.rb +9 -0
  57. data/app/test/test_helper.rb +6 -0
  58. data/app/test/unit/bar_test.rb +133 -0
  59. data/app/test/unit/foo_test.rb +8 -0
  60. data/app/vendor/plugins/.gitkeep +0 -0
  61. data/lib/activerecord-postgres-hstore/hash.rb +1 -1
  62. data/lib/activerecord-postgres-hstore/string.rb +4 -0
  63. data/spec/activerecord-postgres-hstore_spec.rb +13 -9
  64. data/spec/spec_helper.rb +4 -4
  65. metadata +162 -20
  66. data/.gitignore +0 -21
File without changes
@@ -5,7 +5,7 @@ class Hash
5
5
  def to_hstore
6
6
  return "''" if empty?
7
7
  #@todo DIOGO! Check security issues with this quoting pleaz
8
- map{|idx,val| "('#{idx}'=>'#{val.to_s.gsub(/'/,"''")}')" }.join(' || ')
8
+ map{|idx, val| "('#{idx.to_s.escape_quotes}'=>'#{val.to_s.escape_quotes}')" }.join(' || ')
9
9
  end
10
10
 
11
11
  # If the method from_hstore is called in a Hash, it just returns self.
@@ -28,4 +28,8 @@ class String
28
28
  Hash[ scan(/"([^"]+)"=>"([^"]+)"/) ]
29
29
  end
30
30
 
31
+ def escape_quotes
32
+ self.gsub(/'/,"''")
33
+ end
34
+
31
35
  end
@@ -2,28 +2,32 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "ActiverecordPostgresHstore" do
4
4
 
5
- it "should convert hstore string to hash" do
6
- ["('a'=>'1') || ('b'=>'2')", "('b'=>'2') || ('a'=>'1')"].should include({:a => 1, :b => 2}.to_hstore)
7
- end
8
-
9
5
  it "should convert hash to hstore string" do
10
- {:a => 1, :b => 2}.to_hstore.should == "('a'=>'1') || ('b'=>'2')"
6
+ ["('a'=>'1') || ('b'=>'2')", "('b'=>'2') || ('a'=>'1')"].should include({:a => 1, :b => 2}.to_hstore)
11
7
  end
12
8
 
13
9
  it "should convert hstore string to hash" do
14
- '"a"=>"1", "b"=>"2"'.from_hstore.should == {'a' => '1', 'b' => '2'}
10
+ '"a"=>"1", "b"=>"2"'.from_hstore.should eq({'a' => '1', 'b' => '2'})
15
11
  end
16
12
 
17
13
  it "should quote correctly" do
18
- {:a => "'a'"}.to_hstore.should == "('a'=>'''a''')"
14
+ {:a => "'a'"}.to_hstore.should eq("('a'=>'''a''')")
15
+ end
16
+
17
+ it "should quote keys correctly" do
18
+ {"'a'" => "a"}.to_hstore.should eq("('''a'''=>'a')")
19
+ end
20
+
21
+ it "should unquote keys correctly" do
22
+ "\"'a'\"=>\"a\"".from_hstore.should eq({"'a'" => "a"})
19
23
  end
20
24
 
21
25
  it "should convert empty hash" do
22
- {}.to_hstore.should == "''"
26
+ {}.to_hstore.should eq("''")
23
27
  end
24
28
 
25
29
  it "should convert empty string" do
26
- ''.from_hstore.should == {}
30
+ ''.from_hstore.should eq({})
27
31
  end
28
32
 
29
33
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'activerecord-postgres-hstore'
4
- require 'spec'
5
- require 'spec/autorun'
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+
7
+ RSpec.configure do |config|
6
8
 
7
- Spec::Runner.configure do |config|
8
-
9
9
  end
metadata CHANGED
@@ -1,39 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgres-hstore
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Juan Maiz
14
+ - Diogo Biazus
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-03-10 00:00:00 -03:00
19
+ date: 2011-08-02 00:00:00 -03:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: rspec
23
+ name: activerecord
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ type: :runtime
23
39
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
43
  - - ">="
28
44
  - !ruby/object:Gem::Version
29
- hash: 13
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: shoulda
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: bundler
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 23
30
74
  segments:
31
75
  - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
76
+ - 0
77
+ - 0
78
+ version: 1.0.0
79
+ requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: jeweler
35
82
  type: :development
36
- version_requirements: *id001
83
+ prerelease: false
84
+ version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 7
90
+ segments:
91
+ - 1
92
+ - 6
93
+ - 4
94
+ version: 1.6.4
95
+ requirement: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: rcov
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ requirement: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: rdoc
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ requirement: *id007
37
124
  description: This gem adds support for the postgres hstore type. It is the _just right_ alternative for storing hashes instead of using seralization or dynamic tables.
38
125
  email: juanmaiz@gmail.com
39
126
  executables: []
@@ -45,25 +132,81 @@ extra_rdoc_files:
45
132
  - README.textile
46
133
  files:
47
134
  - .document
48
- - .gitignore
135
+ - .rspec
136
+ - Gemfile
137
+ - Gemfile.lock
49
138
  - LICENSE
139
+ - README.textile
50
140
  - Rakefile
51
141
  - VERSION
142
+ - activerecord-postgres-hstore.gemspec
143
+ - app/.gitignore
144
+ - app/Gemfile
145
+ - app/Gemfile.lock
146
+ - app/README
147
+ - app/Rakefile
148
+ - app/app/controllers/application_controller.rb
149
+ - app/app/helpers/application_helper.rb
150
+ - app/app/models/bar.rb
151
+ - app/app/models/foo.rb
152
+ - app/app/views/layouts/application.html.erb
153
+ - app/bench.rb
154
+ - app/bench_results.txt
155
+ - app/config.ru
156
+ - app/config/application.rb
157
+ - app/config/boot.rb
158
+ - app/config/database.yml
159
+ - app/config/environment.rb
160
+ - app/config/environments/development.rb
161
+ - app/config/environments/production.rb
162
+ - app/config/environments/test.rb
163
+ - app/config/initializers/activerecord_postgres_hstore.rb
164
+ - app/config/initializers/backtrace_silencers.rb
165
+ - app/config/initializers/inflections.rb
166
+ - app/config/initializers/mime_types.rb
167
+ - app/config/initializers/secret_token.rb
168
+ - app/config/initializers/session_store.rb
169
+ - app/config/locales/en.yml
170
+ - app/config/routes.rb
171
+ - app/db/development_structure.sql
172
+ - app/db/migrate/20100906191151_add_hstore.rb
173
+ - app/db/migrate/20100906191457_create_foos.rb
174
+ - app/db/migrate/20100906191506_create_bars.rb
175
+ - app/db/schema.rb
176
+ - app/db/seeds.rb
177
+ - app/doc/README_FOR_APP
178
+ - app/generate_copy_files.rb
179
+ - app/lib/tasks/.gitkeep
180
+ - app/public/404.html
181
+ - app/public/422.html
182
+ - app/public/500.html
183
+ - app/public/favicon.ico
184
+ - app/public/images/rails.png
185
+ - app/public/index.html
186
+ - app/public/javascripts/.gitkeep
187
+ - app/public/javascripts/application.js
188
+ - app/public/robots.txt
189
+ - app/public/stylesheets/.gitkeep
190
+ - app/script/rails
191
+ - app/test/performance/browsing_test.rb
192
+ - app/test/test_helper.rb
193
+ - app/test/unit/bar_test.rb
194
+ - app/test/unit/foo_test.rb
195
+ - app/vendor/plugins/.gitkeep
52
196
  - lib/activerecord-postgres-hstore.rb
53
197
  - lib/activerecord-postgres-hstore/activerecord.rb
54
198
  - lib/activerecord-postgres-hstore/hash.rb
55
199
  - lib/activerecord-postgres-hstore/string.rb
56
200
  - lib/templates/setup_hstore.rb
57
201
  - spec/activerecord-postgres-hstore_spec.rb
58
- - README.textile
59
202
  - spec/spec_helper.rb
60
203
  has_rdoc: true
61
204
  homepage: http://github.com/softa/activerecord-postgres-hstore
62
- licenses: []
63
-
205
+ licenses:
206
+ - MIT
64
207
  post_install_message:
65
- rdoc_options:
66
- - --charset=UTF-8
208
+ rdoc_options: []
209
+
67
210
  require_paths:
68
211
  - lib
69
212
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -91,6 +234,5 @@ rubygems_version: 1.3.7
91
234
  signing_key:
92
235
  specification_version: 3
93
236
  summary: Goodbye serialize, hello hstore
94
- test_files:
95
- - spec/activerecord-postgres-hstore_spec.rb
96
- - spec/spec_helper.rb
237
+ test_files: []
238
+
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC