acts_as_sweepable 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +2 -0
- data/Rakefile +1 -1
- data/acts_as_sweepable.gemspec +9 -11
- data/lib/acts_as_sweepable.rb +7 -4
- data/spec/acts_as_sweepable_spec.rb +3 -2
- metadata +39 -67
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -2
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('acts_as_sweepable', '0.1.
|
5
|
+
Echoe.new('acts_as_sweepable', '0.1.3') do |p|
|
6
6
|
p.description = "Adds a class method called sweep to ActiveRecord - used to remove old elements"
|
7
7
|
p.url = "https://github.com/mensfeld/Acts-as-Sweepable"
|
8
8
|
p.author = "Maciej Mensfeld"
|
data/acts_as_sweepable.gemspec
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.1.
|
4
|
+
s.name = "acts_as_sweepable"
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Maciej Mensfeld"]
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.email = %q{maciej@mensfeld.pl}
|
9
|
+
s.date = "2012-01-28"
|
10
|
+
s.description = "Adds a class method called sweep to ActiveRecord - used to remove old elements"
|
11
|
+
s.email = "maciej@mensfeld.pl"
|
13
12
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md", "lib/acts_as_sweepable.rb"]
|
14
13
|
s.files = ["CHANGELOG.rdoc", "Gemfile", "MIT-LICENSE", "Manifest", "README.md", "Rakefile", "init.rb", "lib/acts_as_sweepable.rb", "spec/acts_as_sweepable_spec.rb", "spec/spec_helper.rb", "acts_as_sweepable.gemspec"]
|
15
|
-
s.homepage =
|
14
|
+
s.homepage = "https://github.com/mensfeld/Acts-as-Sweepable"
|
16
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Acts_as_sweepable", "--main", "README.md"]
|
17
16
|
s.require_paths = ["lib"]
|
18
|
-
s.rubyforge_project =
|
19
|
-
s.rubygems_version =
|
20
|
-
s.
|
21
|
-
s.summary = %q{Adds a class method called sweep to ActiveRecord - used to remove old elements}
|
17
|
+
s.rubyforge_project = "acts_as_sweepable"
|
18
|
+
s.rubygems_version = "1.8.15"
|
19
|
+
s.summary = "Adds a class method called sweep to ActiveRecord - used to remove old elements"
|
22
20
|
|
23
21
|
if s.respond_to? :specification_version then
|
24
22
|
s.specification_version = 3
|
data/lib/acts_as_sweepable.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module Acts
|
3
3
|
module AsSweepable
|
4
4
|
|
5
|
+
class InvalidTime < StandardError; end
|
6
|
+
|
5
7
|
def self.included(base)
|
6
8
|
base.extend ClassMethods
|
7
9
|
end
|
@@ -10,17 +12,18 @@ module Acts
|
|
10
12
|
def sweep(*sources)
|
11
13
|
# time_ago = nil, conditions = nil, created_or_updated = true
|
12
14
|
options = sources.extract_options!.stringify_keys
|
15
|
+
options = options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
13
16
|
|
14
|
-
time_ago = options.delete(
|
15
|
-
conditions = options.delete(
|
16
|
-
created_or_updated = options.delete(
|
17
|
+
time_ago = options.delete(:time)
|
18
|
+
conditions = options.delete(:conditions)
|
19
|
+
created_or_updated = options.delete(:created_or_updated)
|
17
20
|
created_or_updated = true if created_or_updated.nil?
|
18
21
|
|
19
22
|
time = case time_ago
|
20
23
|
when /^(\d+)m$/ then Time.now - $1.to_i.minute
|
21
24
|
when /^(\d+)h$/ then Time.now - $1.to_i.hour
|
22
25
|
when /^(\d+)d$/ then Time.now - $1.to_i.day
|
23
|
-
else
|
26
|
+
else raise(InvalidTime, time_ago)
|
24
27
|
end
|
25
28
|
|
26
29
|
statement = "updated_at < '#{time.to_s(:db)}'"
|
@@ -62,9 +62,10 @@ describe CoolElement do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should not sweep recently updated objects" do
|
65
|
-
el = subject.create(:updated_at => 1.days.ago, :created_at =>
|
66
|
-
subject.sweep(:time => '9d', :active => false)
|
65
|
+
el = subject.create(:updated_at => 1.days.ago, :created_at => 11.days.ago)
|
67
66
|
subject.all.count.should eql(1)
|
67
|
+
subject.sweep(:time => '9d', :created_or_updated => false)
|
68
|
+
subject.all.count.should eql(1)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
metadata
CHANGED
@@ -1,72 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_sweepable
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Maciej Mensfeld
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
ZWoxGDAWBgoJkiaJk/IsZAEZFghtZW5zZmVsZDESMBAGCgmSJomT8ixkARkWAnBs
|
16
|
-
MB4XDTExMDQwOTA5NDcyMloXDTEyMDQwODA5NDcyMlowPzEPMA0GA1UEAwwGbWFj
|
17
|
-
aWVqMRgwFgYKCZImiZPyLGQBGRYIbWVuc2ZlbGQxEjAQBgoJkiaJk/IsZAEZFgJw
|
18
|
-
bDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0+nG3V4/exIeiJ0IN+
|
19
|
-
wVfq8Utcu4Qpo+58EIVMIu3FiK+8w6MBvatZnUrRu12pqWLw9xrUkCiYeRErD+jF
|
20
|
-
AmdggIM/tu9CcjvURXH7VeTzOVA+pnV+eJWMD61o8HljFVcb/nyEYYVKErtr9/O4
|
21
|
-
QrIGv5lnszq1PMj2sBMy2gOP1YnzawncMLmkpp/T5SU4JZ5gAktGMRVz8RxmZzF5
|
22
|
-
6NVqFLbuqSRSU5U//WJvZVJt8dycCGgQzBM4Vi3nkOWyjIF0BANf1TqnlU2u6s8d
|
23
|
-
UK1AoDZfg5feef5e8eqoomHebX1opNGM/SOQhu3LRgax4rJfnl6VS3I2wighohsf
|
24
|
-
AgcCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUGlrWBqxVieAPk7NEzBDp
|
25
|
-
kM+iAMMwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAJMoyBaJs8boiz
|
26
|
-
lFpbw6MWjk+7ZhqoHpFrWEV4nzb5GzyHZ7GU/pa1fSEQR0SCs+LnTLQbAYNQyUTT
|
27
|
-
O+UsTuA7xzI//v6cSodv3Q9NbfoDlou74xv1NXorWoosQFMpVWrXv+c/1RqU3cq4
|
28
|
-
WUr+rRiveEXG4tXOwkrpX8KH8xVp2vQZcGw3AXPqhzfqDGzpHd6ws3lk+8HoSrSo
|
29
|
-
2L68tDoxraF2Z2toAg9vfFw1+mOeDk1xVIPVcBy3tJxstHfHGHlQuMiRiDQX2b2D
|
30
|
-
YYU8UWVt2841IwB5Dgl4O+atXhe9ZTBO0W32pl4Bq5CP9lhQRT1KL7sxfznJlF7Y
|
31
|
-
BH3YFsdk
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
|
34
|
-
date: 2011-04-23 00:00:00 +02:00
|
35
|
-
default_executable:
|
36
|
-
dependencies:
|
37
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
38
15
|
name: rspec
|
39
|
-
|
40
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &23459120 !ruby/object:Gem::Requirement
|
41
17
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
45
21
|
version: 2.0.0
|
46
22
|
type: :development
|
47
|
-
version_requirements: *id001
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: active_record
|
50
23
|
prerelease: false
|
51
|
-
|
24
|
+
version_requirements: *23459120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: active_record
|
27
|
+
requirement: &23458460 !ruby/object:Gem::Requirement
|
52
28
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
57
33
|
type: :development
|
58
|
-
|
59
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *23458460
|
36
|
+
description: Adds a class method called sweep to ActiveRecord - used to remove old
|
37
|
+
elements
|
60
38
|
email: maciej@mensfeld.pl
|
61
39
|
executables: []
|
62
|
-
|
63
40
|
extensions: []
|
64
|
-
|
65
|
-
extra_rdoc_files:
|
41
|
+
extra_rdoc_files:
|
66
42
|
- CHANGELOG.rdoc
|
67
43
|
- README.md
|
68
44
|
- lib/acts_as_sweepable.rb
|
69
|
-
files:
|
45
|
+
files:
|
70
46
|
- CHANGELOG.rdoc
|
71
47
|
- Gemfile
|
72
48
|
- MIT-LICENSE
|
@@ -78,38 +54,34 @@ files:
|
|
78
54
|
- spec/acts_as_sweepable_spec.rb
|
79
55
|
- spec/spec_helper.rb
|
80
56
|
- acts_as_sweepable.gemspec
|
81
|
-
has_rdoc: true
|
82
57
|
homepage: https://github.com/mensfeld/Acts-as-Sweepable
|
83
58
|
licenses: []
|
84
|
-
|
85
59
|
post_install_message:
|
86
|
-
rdoc_options:
|
60
|
+
rdoc_options:
|
87
61
|
- --line-numbers
|
88
62
|
- --inline-source
|
89
63
|
- --title
|
90
64
|
- Acts_as_sweepable
|
91
65
|
- --main
|
92
66
|
- README.md
|
93
|
-
require_paths:
|
67
|
+
require_paths:
|
94
68
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
70
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version:
|
101
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
76
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version:
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.2'
|
107
81
|
requirements: []
|
108
|
-
|
109
82
|
rubyforge_project: acts_as_sweepable
|
110
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.15
|
111
84
|
signing_key:
|
112
85
|
specification_version: 3
|
113
86
|
summary: Adds a class method called sweep to ActiveRecord - used to remove old elements
|
114
87
|
test_files: []
|
115
|
-
|
data.tar.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
��>�y~}�F�l��x(�����Qߴ ,�[nY��I$����L+�ù�e��7`����ENU�D@��G���u�J��
|
metadata.gz.sig
DELETED