sbfaulkner-sequel_timestamped 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2009 unwwwired.net
2
-
2
+
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
5
5
  "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@ without limitation the rights to use, copy, modify, merge, publish,
7
7
  distribute, sublicense, and/or sell copies of the Software, and to
8
8
  permit persons to whom the Software is furnished to do so, subject to
9
9
  the following conditions:
10
-
10
+
11
11
  The above copyright notice and this permission notice shall be
12
12
  included in all copies or substantial portions of the Software.
13
-
13
+
14
14
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
data/README.markdown CHANGED
@@ -7,12 +7,15 @@ my take on a timestamping plugin for sequel
7
7
  The existing implementations I saw checked for the attributes every time a
8
8
  record was saved. This version checks when plugged in.
9
9
 
10
+ Additionally, the updated\_by attribute is explicitly settable in at least one
11
+ other implementation. It's not in this one (by design).
12
+
10
13
  ## Installation
11
14
 
12
15
  Run the following if you haven't already:
13
16
 
14
17
  $ gem sources -a http://gems.github.com
15
-
18
+
16
19
  Install the gem(s):
17
20
 
18
21
  $ sudo gem install -r sbfaulkner-sequel_timestamped
@@ -21,19 +24,24 @@ Install the gem(s):
21
24
 
22
25
  require 'rubygems'
23
26
  require 'sequel'
24
-
27
+
25
28
  class Post < Sequel::Model
26
- is :timestamped
29
+ is :timestamped, :using => :utc
27
30
  end
28
31
 
32
+ ## UPDATES
33
+
34
+ ### 1.0.3
35
+
36
+ - add support for utc (or localtime) by passing option :using => :utc (or :localtime)
37
+
29
38
  ## TODO
30
39
 
31
- - add tests
32
40
  - maybe rename sequel\_audited
33
- - add created_by and updated_by support?
41
+ - add created\_by and updated\_by support?
34
42
  - publish in sequel www/pages/plugins
35
43
 
36
44
  ## Legal
37
45
 
38
- **Author:** S. Brent Faulkner <brentf@unwwwired.net>
46
+ **Author:** S. Brent Faulkner <brentf@unwwwired.net>
39
47
  **License:** Copyright &copy; 2009 unwwwired.net, released under the MIT license
@@ -2,8 +2,9 @@ module Sequel
2
2
  module Plugins
3
3
  module Timestamped
4
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)
5
+ using = options[:using] || :localtime
6
+ model.class_eval "before_create { self.created_at = Time.now.#{using} if self.created_at.nil? }" if model.columns.include?(:created_at)
7
+ model.class_eval "before_save { self.updated_at = Time.now.#{using} }" if model.columns.include?(:updated_at)
7
8
  end
8
9
  end
9
10
  end
@@ -1,19 +1,19 @@
1
- SPEC = Gem::Specification.new do |s|
1
+ SPEC = Gem::Specification.new do |s|
2
2
  # identify the gem
3
- s.name = "sequel_timestamped"
4
- s.version = "1.0.2"
5
- s.author = "S. Brent Faulkner"
6
- s.email = "brentf@unwwwired.net"
7
- s.homepage = "http://github.com/sbfaulkner/sequel_timestamped"
3
+ s.name = "sequel_timestamped"
4
+ s.version = "1.0.3"
5
+ s.author = "S. Brent Faulkner"
6
+ s.email = "brentf@unwwwired.net"
7
+ s.homepage = "http://github.com/sbfaulkner/sequel_timestamped"
8
8
  # platform of choice
9
9
  s.platform = Gem::Platform::RUBY
10
10
  # description of gem
11
11
  s.summary = "my take on a timestamping plugin for sequel"
12
12
  s.files = %w(lib/sequel_timestamped.rb MIT-LICENSE Rakefile README.markdown sequel_timestamped.gemspec test/sequel_timestamped_test.rb)
13
13
  s.require_path = "lib"
14
- s.test_file = "test/sequel_timestamped_test.rb"
15
- s.has_rdoc = true
16
- s.extra_rdoc_files = ["README.markdown"]
14
+ s.test_file = "test/sequel_timestamped_test.rb"
15
+ s.has_rdoc = true
16
+ s.extra_rdoc_files = ["README.markdown"]
17
17
  s.add_dependency "sequel"
18
18
  # s.rubyforge_project = "sequel_timestamped"
19
- end
19
+ end
@@ -3,7 +3,6 @@ require 'test/unit'
3
3
  require 'sequel'
4
4
 
5
5
  DB = Sequel.connect('sqlite:/')
6
- # DB.execute("SET client_min_messages TO 'WARNING'")
7
6
 
8
7
  class ItemWithoutTimestamps < Sequel::Model
9
8
  set_schema do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbfaulkner-sequel_timestamped
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-11 00:00:00 -08:00
12
+ date: 2009-02-05 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency