sbfaulkner-sequel_timestamped 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +32 -0
- data/Rakefile +10 -0
- data/lib/sequel_timestamped.rb +10 -0
- data/sequel_timestamped.gemspec +19 -0
- metadata +65 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 unwwwired.net
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# sequel\_timestamped
|
2
|
+
|
3
|
+
my take on a timestamping plugin for sequel
|
4
|
+
|
5
|
+
## WHY?
|
6
|
+
|
7
|
+
The existing implementations I saw checked for the attributes every time a
|
8
|
+
record was saved. This version checks when plugged in.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Run the following if you haven't already:
|
13
|
+
|
14
|
+
$ gem sources -a http://gems.github.com
|
15
|
+
|
16
|
+
Install the gem(s):
|
17
|
+
|
18
|
+
$ sudo gem install -r sbfaulkner-sequel_timestamped
|
19
|
+
|
20
|
+
## Example
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'sequel'
|
24
|
+
|
25
|
+
class Post < Sequel::Model
|
26
|
+
is :timestamped
|
27
|
+
end
|
28
|
+
|
29
|
+
## Legal
|
30
|
+
|
31
|
+
**Author:** S. Brent Faulkner <brentf@unwwwired.net>
|
32
|
+
**License:** Copyright © 2009 unwwwired.net, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module Sequel
|
2
|
+
module Plugins
|
3
|
+
module Timestamped
|
4
|
+
def self.apply(model, options = {})
|
5
|
+
model.before_create { self.created_at = Time.now if self.created_at.nil? } if model.columns.include?(:created_at)
|
6
|
+
model.before_save { self.updated_at = Time.now } if model.columns.include?(:updated_at)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
SPEC = Gem::Specification.new do |s|
|
2
|
+
# identify the gem
|
3
|
+
s.name = "sequel_timestamped"
|
4
|
+
s.version = "1.0.0"
|
5
|
+
s.author = "S. Brent Faulkner"
|
6
|
+
s.email = "brentf@unwwwired.net"
|
7
|
+
s.homepage = "http://github.com/sbfaulkner/sequel_timestamped"
|
8
|
+
# platform of choice
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
# description of gem
|
11
|
+
s.summary = "my take on a timestamping plugin for sequel"
|
12
|
+
s.files = %w(lib/sequel_timestamped.rb MIT-LICENSE Rakefile README.markdown sequel_timestamped.gemspec)
|
13
|
+
s.require_path = "lib"
|
14
|
+
# s.test_file = "test/sequel_timestamped.rb"
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.extra_rdoc_files = ["README.markdown"]
|
17
|
+
s.add_dependency "sequel"
|
18
|
+
# s.rubyforge_project = "sequel_timestamped"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sbfaulkner-sequel_timestamped
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- S. Brent Faulkner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-22 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sequel
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email: brentf@unwwwired.net
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.markdown
|
32
|
+
files:
|
33
|
+
- lib/sequel_timestamped.rb
|
34
|
+
- MIT-LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- README.markdown
|
37
|
+
- sequel_timestamped.gemspec
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/sbfaulkner/sequel_timestamped
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.2.0
|
61
|
+
signing_key:
|
62
|
+
specification_version: 2
|
63
|
+
summary: my take on a timestamping plugin for sequel
|
64
|
+
test_files: []
|
65
|
+
|