README.md in refcode-0.1.0 vs README.md in refcode-0.1.1
- old
+ new
@@ -1,15 +1,14 @@
# Refcode
-Currently a standalone gem for converting arbitrary Ruby objects into encrypted,
-URL-safe strings. The strings can be simply decrypted later to be used by your
+A ruby gem for converting arbitrary Ruby objects into encrypted,
+URL-safe strings. The strings can be easily decrypted later for use in your
application.
-Refcode was conceived as a way to attach referral data to tracking links. Encryption
+RefCode was conceived as a way to attach referral data to tracking links. Encryption
makes it unlikely that the links will be tampered with. Still, it is not recommended
-for critically sensitive applications! It was designed to power a simple referral
-link tracking system.
+for critically sensitive data!
## Implementation
- **Encryption** using the AES-256-CBC algorithm with https://github.com/attr-encrypted/encryptor which wraps the Ruby OpenSSL library.
@@ -31,44 +30,53 @@
$ gem install refcode
## Usage
-Refcode can be used in two ways. Most simply, you can use the `Refcode::Encoder` class directly.
+RefCode can be used in two ways. Most simply, you can use the `Refcode::Encoder` class directly.
- encoder = Refcode::Encoder.new do |e|
- e.secret = "a long crunchy secret"
- e.salt = "some salt"
- end
+```ruby
+encoder = Refcode::Encoder.new do |e|
+ e.secret = "a long crunchy secret"
+ e.salt = "some salt"
+end
- something = OpenStruct.new(channel: 'facebook', action: 'message', user_id: 43765)
- encoded_param = encoder.encode something
+something = OpenStruct.new(channel: 'facebook', action: 'message', user_id: 43765)
+encoded_param = encoder.encode something
- # in some future request:
+# in some future request:
- something = encoder.decode params[:encoded_param]
- puts something.channel # 'facebook'
+something = encoder.decode params[:encoded_param]
+puts something.channel #=> 'facebook'
+```
For added convenience when using Refcode with an ORM such as ActiveRecord, a module called `Refcode::Encodable` is also provided.
- class Job < ActiveRecord::Base
- include Refcode::Encodable
- has_refcode secret: 'a long crunchy secret', salt: :id
- end
+```ruby
+class Job < ActiveRecord::Base
+ include Refcode::Encodable
+ has_refcode secret: 'a long crunchy secret', salt: :id
+end
- # the salt option of the has_refcode method can accept a proc/lambda, string
- # or a symbol representing an existing method on the class (id in this case)
+# the salt option of the has_refcode method can accept a proc/lambda, string
+# or a symbol representing an existing method on the class (id in this case)
- # in some controller code:
+# in some controller code:
- @job = Job.find params[:id]
- referral_code = @job.generate_refcode channel: 'facebook', action: 'message', user_id: 43765
+@job = Job.find params[:id]
+referral_code = @job.generate_refcode channel: 'facebook', action: 'message', user_id: 43765
- # and in another action:
+# and in another action:
- @job = Job.find params[:id]
- referral_data = @job.parse_refcode params[:encoded_param]
+@job = Job.find params[:id]
+referral_data = @job.parse_refcode params[:encoded_param]
+```
+## Features for 1.0
+
+- ~~Encodable mixin~~
+- ~~Better exception handling~~
+- More complete tests against encoding non-core ruby class values
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)