pickle-surprise 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Guardfile +8 -0
- data/Rakefile +5 -1
- data/lib/pickle-surprise.rb +21 -11
- data/lib/pickle-surprise/pickle.rb +5 -0
- data/lib/pickle-surprise/version.rb +1 -1
- data/pickle-surprise.gemspec +2 -0
- data/spec/pickle-surprise/pickle_spec.rb +5 -0
- data/spec/pickle-surprise_spec.rb +35 -0
- data/spec/spec_helper.rb +9 -0
- metadata +42 -3
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/Rakefile
CHANGED
data/lib/pickle-surprise.rb
CHANGED
@@ -2,20 +2,30 @@ require "pickle-surprise/version"
|
|
2
2
|
require "pickle-surprise/pickle"
|
3
3
|
|
4
4
|
module Pickle
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def self.count
|
6
|
+
Surprise::Pickle.count
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
def self.last
|
10
|
+
Surprise::Pickle.last
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.reset
|
14
|
+
Surprise::Pickle.delete_all
|
15
|
+
end
|
16
|
+
|
17
|
+
module Surprise
|
18
|
+
def Pickle(params=nil,&block)
|
19
|
+
if block
|
20
|
+
begin
|
21
|
+
yield
|
22
|
+
rescue Exception => ex
|
23
|
+
Pickle.factory ex
|
24
|
+
raise
|
25
|
+
end
|
11
26
|
else
|
12
|
-
|
27
|
+
Pickle.factory params
|
13
28
|
end
|
14
29
|
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def create_pickle(params)
|
18
|
-
Pickle.create(params)
|
19
|
-
end
|
20
30
|
end
|
21
31
|
end
|
@@ -10,6 +10,11 @@ module Pickle
|
|
10
10
|
field :ns, type: String
|
11
11
|
field :ts, type: Time, default: -> { Time.now }
|
12
12
|
field :msg, type: String
|
13
|
+
|
14
|
+
def self.factory(params)
|
15
|
+
params = { msg: params.to_s } unless params.respond_to? :to_hash
|
16
|
+
create params.to_hash
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
data/pickle-surprise.gemspec
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pickle-surprise'
|
3
|
+
|
4
|
+
class SomeException < Exception; end
|
5
|
+
|
6
|
+
describe Pickle do
|
7
|
+
pending 'not implemented yet'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Pickle::Surprise do
|
11
|
+
use_mongoid
|
12
|
+
use_pickle_surprise
|
13
|
+
after { Pickle.reset }
|
14
|
+
|
15
|
+
it 'should accept a string' do
|
16
|
+
pickle = Pickle 'string'
|
17
|
+
expect(pickle.msg).to eq('string')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should accept a hash' do
|
21
|
+
pickle = Pickle msg: 'hash'
|
22
|
+
expect(pickle.msg).to eq('hash')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should accept a block' do
|
26
|
+
expect {
|
27
|
+
Pickle do
|
28
|
+
raise SomeException, 'from an exception'
|
29
|
+
end
|
30
|
+
}.to raise_error(SomeException)
|
31
|
+
|
32
|
+
pickle = Pickle.last
|
33
|
+
expect(pickle.msg).to eq('from an exception')
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pickle-surprise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-09-
|
12
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.11.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.11.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
30
62
|
description: Save anything you don't expect at your database
|
31
63
|
email:
|
32
64
|
- daniellibanori@gmail.com
|
@@ -37,6 +69,7 @@ files:
|
|
37
69
|
- .gitignore
|
38
70
|
- .rbenv-version
|
39
71
|
- Gemfile
|
72
|
+
- Guardfile
|
40
73
|
- LICENSE.txt
|
41
74
|
- README.md
|
42
75
|
- Rakefile
|
@@ -47,6 +80,9 @@ files:
|
|
47
80
|
- lib/pickle-surprise/pickle.rb
|
48
81
|
- lib/pickle-surprise/version.rb
|
49
82
|
- pickle-surprise.gemspec
|
83
|
+
- spec/pickle-surprise/pickle_spec.rb
|
84
|
+
- spec/pickle-surprise_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
50
86
|
homepage: http://dlibanori.github.com
|
51
87
|
licenses: []
|
52
88
|
post_install_message:
|
@@ -71,4 +107,7 @@ rubygems_version: 1.8.23
|
|
71
107
|
signing_key:
|
72
108
|
specification_version: 3
|
73
109
|
summary: Where is the pickle? It is not a surprise anymore...
|
74
|
-
test_files:
|
110
|
+
test_files:
|
111
|
+
- spec/pickle-surprise/pickle_spec.rb
|
112
|
+
- spec/pickle-surprise_spec.rb
|
113
|
+
- spec/spec_helper.rb
|