params_extractor 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,5 +1,13 @@
1
1
  module Params
2
2
  module Base
3
+ def clean_params params
4
+ Hash[params.collect do |key, value|
5
+ value = nil if value == "na"
6
+ [key, value]
7
+ end
8
+ ]
9
+ end
10
+
3
11
  def use_crypter?
4
12
  crypter? || Params::Crypter.on?
5
13
  end
@@ -26,6 +26,10 @@ module Params
26
26
  end
27
27
  end
28
28
 
29
+ def as_clean_hash mode = :str
30
+ clean_params(as_hash mode)
31
+ end
32
+
29
33
  # decode in reverse order!
30
34
  def decoded
31
35
  @decoded ||= use_crypter? ? crypter.decrypt(decoded_params) : decoded_params
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "params_extractor"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-05-07"
12
+ s.date = "2012-05-08"
13
13
  s.description = "Encode and encrypt prams and leter unencryt and decode them - useful when sending invites with tokens"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -5,5 +5,9 @@ shared_examples 'a decoder' do
5
5
  subject.as_hash.should == decoded_data
6
6
  end
7
7
 
8
+ specify do
9
+ subject.as_clean_hash.should == decoded_clean_data
10
+ end
11
+
8
12
  specify { subject.as_hash(:sym).should == data }
9
13
  end
@@ -15,16 +15,16 @@ describe Params::Decoder do
15
15
  end
16
16
 
17
17
  let(:data) do
18
- {:id => '7', :name => 'kris'}
18
+ {:id => '7', :name => 'kris', :lang => 'na'}
19
19
  end
20
20
 
21
21
  let(:decoded_data) do
22
- {'id' => '7', 'name' => 'kris'}
22
+ {'id' => '7', 'name' => 'kris', 'lang' => 'na'}
23
23
  end
24
24
 
25
- # before do
26
- # Params::Crypter.on!
27
- # end
25
+ let(:decoded_clean_data) do
26
+ {'id' => '7', 'name' => 'kris', 'lang' => nil}
27
+ end
28
28
 
29
29
  describe 'crypter?' do
30
30
  specify { subject.crypter?.should be_true }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: params_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
12
+ date: 2012-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gibberish
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -448216205111061566
154
+ hash: -1069122987872932119
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements: