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 CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in pickle-surprise.gemspec
4
4
  gemspec
5
+
6
+ gem 'rb-fsevent', require: false if RUBY_PLATFORM =~ /darwin/i
7
+ gem 'pry'
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', version: 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -2,20 +2,30 @@ require "pickle-surprise/version"
2
2
  require "pickle-surprise/pickle"
3
3
 
4
4
  module Pickle
5
- module Surprise
6
- def Pickle(params=nil)
7
- return unless params
5
+ def self.count
6
+ Surprise::Pickle.count
7
+ end
8
8
 
9
- if params.respond_to? :each_pair
10
- create_pickle params
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
- create_pickle msg: params.inspect
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
@@ -1,5 +1,5 @@
1
1
  module Pickle
2
2
  module Surprise
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'mongoid', '~> 3.0.0'
21
+ gem.add_development_dependency 'rspec', '~> 2.11.0'
22
+ gem.add_development_dependency 'guard-rspec'
21
23
  end
@@ -0,0 +1,5 @@
1
+ require 'pickle-surprise/pickle'
2
+
3
+ describe Pickle::Surprise::Pickle do
4
+ pending 'not implemented yet'
5
+ end
@@ -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
@@ -0,0 +1,9 @@
1
+ def use_mongoid
2
+ require 'mongoid'
3
+ ENV['MONGOID_ENV'] = 'development'
4
+ Mongoid.load! 'examples/config.yml'
5
+ end
6
+
7
+ def use_pickle_surprise
8
+ include Pickle::Surprise
9
+ end
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.1
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-10 00:00:00.000000000 Z
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