Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated readme and gemspec

  • Loading branch information...
commit 3cca18393258c11461f9226150fa889f8c44edda 1 parent c9f1269
@t27duck authored
View
2  Gemfile
@@ -5,5 +5,3 @@ gemspec
gem "activerecord", "~> 2.3.0", :require => "active_record"
gem "activesupport", "~> 2.3.0", :require => "active_support"
-
-gem "pg"
View
32 README.markdown
@@ -7,7 +7,7 @@ This is a gem that provides some very basic functionality for working with
Postgresql's Hstore columns in ActiveRecord 2.
Documentation about the Postgresql Hstore feature can be found
-[here](http://www.postgresql.org/docs/9.1/static/hstore.html)
+**[here](http://www.postgresql.org/docs/9.1/static/hstore.html)**.
Requirements (aka boring stuff)
-------------------------------
@@ -99,6 +99,32 @@ Which means you can then do...
Peep.infos_likes_eq("Cuddling while watching TV")
Peep.searchlogic(:infos_age_neq => "23")
+But Wait, There's More!
+-----------------------
+
+The gem also adds a helper method to the Hash and String objects for converting
+hashes to hstore strings and back again.
+
+These methods were originally implemented in a gem by
+[softa](https://github.com/softa/activerecord-postgres-hstore) to add hstore
+to ActiveReocord 3 and tweaked slightly for this gem.
+
+Converting a hash into a hstore string that can be used to direclty store data
+in a query...
+
+ {"something something" => "something", :dark => "side"}.to_hstore
+ >> "\"something something\"=>something,dark=>side"
+
+Converting a hstore string that is returned from the database into a hash so
+you can actually do something with it...
+
+ "\"something something\"=>something,dark=>side".from_hstore
+ >> {"something something" => "something", "dark" => "side"}
+
+Note that taking a string from hstore into a hash will produce a hash where its
+keys and values are all strings.
+
+
Running Tests
-------------
For the tests to run, it's assumed there is a Postgres database called
@@ -106,6 +132,10 @@ activerecord2\_hstore\_test. The specs will create a test table and populate
it with data for you. If you want to use a different database, then edit
spec/hstore\_spec.rb to your liking.
+Then just run...
+
+ rake spec
+
Background / Why make this? / Me Rambling
-----------------------------------------
At my current employor, I'm helping to support a rather large Rails 2.3 app
View
8 activerecord2-hstore.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.email = ["t27duck@gmail.com"]
s.homepage = "https://github.com/t27duck/activerecord2-hstore"
s.summary = %q{Some basic support to help integrate Postgresql's HStore into a Rails 2.3 app}
- s.description = %q{TODO: Write a gem description}
+ s.description = %q{Allows you to mark a column in a model as a HStore column letting you pass in a hash for its setter and retrieve a hash from its getter method. Also provides a series to named scopes for easy querying of data.}
s.rubyforge_project = "activerecord2-hstore"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
# specify any dependencies here; for example:
s.add_development_dependency "rspec", ">=2.0.0"
- s.add_dependency "pg"
-
- # s.add_runtime_dependency "rest-client"
+ s.add_runtime_dependency "activerecord", "~> 2.3.0"
+ s.add_runtime_dependency "activesupport", "~> 2.3.0"
+ s.add_runtime_dependency "pg"
end
View
2  lib/activerecord2-hstore/version.rb
@@ -1,5 +1,5 @@
module Activerecord2
module Hstore
- VERSION = "0.0.1"
+ VERSION = "1.0.0"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.