wisper-sequel 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c068f6803ae42acab6e48913b17870e779a9554
4
+ data.tar.gz: ed8b344055445ddd96a1c308d624d79020a4b2d6
5
+ SHA512:
6
+ metadata.gz: 2cea9a27c006c22b87d7691ea0d9a07c89ff04a4392ea8ff18aad0d51d25ef19cebc03fbc45b04f853a223061376259f6693f84cc17069c3cf6f0cf42b049137
7
+ data.tar.gz: 384fc7c5fa3bbb2359aaa223a98402f68fb11151df85fa14cb3682a1c471bdcd8c763d927b5f0afe4fac8abe4aa6e337d2e356204e3452c19b89dba51947357d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler -v 1.10.3
5
+ addons:
6
+ code_climate:
7
+ repo_token: 078feb8cc776f7d5374f34bd988a983bbf6d4b69655f299cda5dec1e2b18c947
@@ -0,0 +1,28 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all
4
+ people who contribute through reporting issues, posting feature requests,
5
+ updating documentation, submitting pull requests or patches, and other
6
+ activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, or religion.
12
+
13
+ Examples of unacceptable behavior by participants include the use of sexual
14
+ language or imagery, derogatory comments or personal attacks, trolling, public
15
+ or private harassment, insults, or other unprofessional conduct.
16
+
17
+ Project maintainers have the right and responsibility to remove, edit, or
18
+ reject comments, commits, code, wiki edits, issues, and other contributions
19
+ that are not aligned to this Code of Conduct. Project maintainers who do not
20
+ follow the Code of Conduct may be removed from the project team.
21
+
22
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
23
+ reported by opening an issue or contacting one or more of the project
24
+ maintainers.
25
+
26
+ This Code of Conduct is adapted from the [Contributor
27
+ Covenant](http://contributor-covenant.org), version 1.0.0, available at
28
+ [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wisper-sequel.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Damián Silvani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # Wisper::Sequel
2
+
3
+ [![Build Status](https://travis-ci.org/munshkr/wisper-sequel.svg)](https://travis-ci.org/munshkr/wisper-sequel)
4
+ [![Code Climate](https://codeclimate.com/github/munshkr/wisper-sequel/badges/gpa.svg)](https://codeclimate.com/github/munshkr/wisper-sequel)
5
+ [![Test Coverage](https://codeclimate.com/github/munshkr/wisper-sequel/badges/coverage.svg)](https://codeclimate.com/github/munshkr/wisper-sequel/coverage)
6
+
7
+ A Sequel plugin for broadcasting model hooks as
8
+ [Wisper](https://github.com/krisleech/wisper) events.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'wisper-sequel', github: 'munshkr/wisper-sequel'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install wisper-sequel
25
+
26
+ ## Usage
27
+
28
+ Please refer to the [Wisper README](https://github.com/krisleech/wisper) for
29
+ full details about subscribing.
30
+
31
+ Some of the events which are automatically broadcast are
32
+
33
+ * `create_<model_name>_{successful,failed}`
34
+ * `update_<model_name>_{successful,failed}`
35
+ * `destroy_<model_name>_{successful,failed}`
36
+
37
+ There is also an event per each model hook available. The complete list is:
38
+
39
+ * `before_validation`
40
+ * `after_validation`
41
+ * `before_save`
42
+ * `after_save`
43
+ * `before_create`
44
+ * `after_create`
45
+ * `before_update`
46
+ * `after_update`
47
+ * `before_destroy`
48
+ * `after_destroy`
49
+ * `after_commit`
50
+ * `after_rollback`
51
+ * `after_destroy_commit`
52
+ * `after_destroy_rollback`
53
+
54
+ Please refer to [Sequel Model
55
+ Hooks](http://sequel.jeremyevans.net/rdoc/files/doc/model_hooks_rdoc.html)
56
+ document for full details about model hooks.
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
61
+ `rake rspec` to run the tests. You can also run `bin/console` for an
62
+ interactive prompt that will allow you to experiment.
63
+
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To
65
+ release a new version, update the version number in `version.rb`, and then run
66
+ `bundle exec rake release`, which will create a git tag for the version, push
67
+ git commits and tags, and push the `.gem` file to
68
+ [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at
73
+ https://github.com/munshkr/wisper-sequel. This project is intended to be a
74
+ safe, welcoming space for collaboration, and contributors are expected to
75
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
76
+
77
+ ## License
78
+
79
+ The gem is available as open source under the terms of the [MIT
80
+ License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wisper/sequel"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,133 @@
1
+ module Sequel
2
+ module Plugins
3
+ module Wisper
4
+ def self.apply(model, *attrs)
5
+ require 'sequel/extensions/inflector'
6
+ require 'wisper'
7
+
8
+ model.send(:include, ::Wisper::Publisher)
9
+ end
10
+
11
+ def self.configure(model, *attrs)
12
+ end
13
+
14
+ module ClassMethods
15
+ end
16
+
17
+ module InstanceMethods
18
+ def save(*args)
19
+ on_save { super }
20
+ end
21
+
22
+ def before_validation
23
+ broadcast(:before_validation, self)
24
+ super
25
+ end
26
+
27
+ def after_validation
28
+ super
29
+ broadcast(:after_validation, self)
30
+ end
31
+
32
+ def before_save
33
+ broadcast(:before_save, self)
34
+ super
35
+ end
36
+
37
+ def after_save
38
+ super
39
+ broadcast(:after_save, self)
40
+ end
41
+
42
+ def before_create
43
+ broadcast(:before_create, self)
44
+ super
45
+ end
46
+
47
+ def after_create
48
+ super
49
+ broadcast(:after_create, self)
50
+ db.after_commit { broadcast(:"create_#{model_name}_successful", self) }
51
+ db.after_rollback { broadcast(:"create_#{model_name}_failed", self) }
52
+ end
53
+
54
+ def before_update
55
+ broadcast(:before_update, self)
56
+ super
57
+ end
58
+
59
+ def after_update
60
+ super
61
+ broadcast(:after_update, self)
62
+ db.after_commit { broadcast(:"update_#{model_name}_successful", self) }
63
+ db.after_rollback { broadcast(:"update_#{model_name}_failed", self) }
64
+ end
65
+
66
+ def before_destroy
67
+ broadcast(:before_destroy, self)
68
+ super
69
+ end
70
+
71
+ def after_destroy
72
+ super
73
+ broadcast(:after_destroy, self)
74
+ end
75
+
76
+ def after_commit
77
+ super
78
+ broadcast(:after_commit, self)
79
+ end
80
+
81
+ def after_rollback
82
+ super
83
+ broadcast(:after_rollback, self)
84
+ end
85
+
86
+ def after_destroy_commit
87
+ super
88
+ broadcast(:after_destroy_commit, self)
89
+ broadcast(:"destroy_#{model_name}_successful", self)
90
+ end
91
+
92
+ def after_destroy_rollback
93
+ super
94
+ broadcast(:after_destroy_rollback, self)
95
+ broadcast(:"destroy_#{model_name}_failed", self)
96
+ end
97
+
98
+ def around_validation
99
+ res = super
100
+ rescue => error
101
+ res = nil
102
+ ensure
103
+ if on_save? && !res
104
+ action = new? ? 'create' : 'update'
105
+ broadcast(:"#{action}_#{model_name}_failed", self)
106
+ end
107
+ raise error if error
108
+ end
109
+
110
+ private
111
+
112
+ def model_name
113
+ model.name.underscore
114
+ end
115
+
116
+ def on_save
117
+ @on_save ||= 0
118
+ @on_save += 1
119
+ yield
120
+ ensure
121
+ @on_save -= 1
122
+ end
123
+
124
+ def on_save?
125
+ @on_save && @on_save > 0
126
+ end
127
+ end
128
+
129
+ module DatasetMethods
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,5 @@
1
+ module Wisper
2
+ module Sequel
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "wisper/sequel/version"
2
+ require "sequel/plugins/wisper"
data/travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.0
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wisper/sequel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wisper-sequel"
8
+ spec.version = Wisper::Sequel::VERSION
9
+ spec.authors = ["Damián Silvani"]
10
+ spec.email = ["munshkr@gmail.com"]
11
+
12
+ spec.summary = %q{A Sequel plugin for broadcasting model hooks as Wisper events.}
13
+ spec.description = %q{Transparently publish model lifecycle events to subscribers.}
14
+ spec.homepage = "https://github.com/munshkr/wisper-sequel"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "wisper-rspec"
26
+ spec.add_development_dependency "sqlite3"
27
+
28
+ spec.add_runtime_dependency "wisper", "~> 1.6"
29
+ spec.add_runtime_dependency "sequel"
30
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wisper-sequel
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Damián Silvani
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: wisper-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: wisper
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sequel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Transparently publish model lifecycle events to subscribers.
112
+ email:
113
+ - munshkr@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/sequel/plugins/wisper.rb
129
+ - lib/wisper/sequel.rb
130
+ - lib/wisper/sequel/version.rb
131
+ - travis.yml
132
+ - wisper-sequel.gemspec
133
+ homepage: https://github.com/munshkr/wisper-sequel
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.3
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: A Sequel plugin for broadcasting model hooks as Wisper events.
157
+ test_files: []