enju_core 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enju_core/bookmark_url.rb +45 -0
- data/lib/enju_core/calculate_stat.rb +30 -0
- data/lib/enju_core/engine.rb +3 -0
- data/lib/enju_core/version.rb +1 -1
- data/lib/enju_core.rb +2 -0
- metadata +36 -2
@@ -0,0 +1,45 @@
|
|
1
|
+
module BookmarkUrl
|
2
|
+
def my_host?
|
3
|
+
url = ::Addressable::URI.parse(self)
|
4
|
+
unless url.host
|
5
|
+
raise ::Addressable::URI::InvalidURIError
|
6
|
+
end
|
7
|
+
config_url = ::Addressable::URI.parse(LibraryGroup.site_config.url)
|
8
|
+
if url.host == config_url.host and url.port == config_url.port and ['http', 'https'].include?(url.scheme)
|
9
|
+
true
|
10
|
+
else
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def bookmarkable?
|
16
|
+
if self.my_host?
|
17
|
+
url = ::Addressable::URI.parse(self)
|
18
|
+
path = url.path.split("/").reverse
|
19
|
+
if path[1] == "manifestations" and Manifestation.where(:id => path[0]).first
|
20
|
+
true
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
else
|
25
|
+
true
|
26
|
+
end
|
27
|
+
rescue ::Addressable::URI::InvalidURIError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def bookmarkable_id
|
32
|
+
if self.my_host?
|
33
|
+
path = ::Addressable::URI.parse(self).path.split("/").reverse
|
34
|
+
unless path[1] == "manifestations"
|
35
|
+
nil
|
36
|
+
else
|
37
|
+
path[0]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class String
|
44
|
+
include BookmarkUrl
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CalculateStat
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.class_eval do
|
7
|
+
validates_presence_of :start_date, :end_date
|
8
|
+
validate :check_date
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def calculate_stat
|
14
|
+
self.not_calculated.each do |stat|
|
15
|
+
stat.calculate!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module InstanceMethods
|
21
|
+
def check_date
|
22
|
+
if self.start_date and self.end_date
|
23
|
+
if self.start_date >= self.end_date
|
24
|
+
errors.add(:start_date)
|
25
|
+
errors.add(:end_date)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/enju_core/engine.rb
CHANGED
data/lib/enju_core/version.rb
CHANGED
data/lib/enju_core.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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-06-
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -155,6 +155,38 @@ dependencies:
|
|
155
155
|
- - ~>
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: 2.0.0.pre.120417
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: resque
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: configatron
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
158
190
|
- !ruby/object:Gem::Dependency
|
159
191
|
name: sqlite3
|
160
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,6 +243,8 @@ extensions: []
|
|
211
243
|
extra_rdoc_files: []
|
212
244
|
files:
|
213
245
|
- config/routes.rb
|
246
|
+
- lib/enju_core/bookmark_url.rb
|
247
|
+
- lib/enju_core/calculate_stat.rb
|
214
248
|
- lib/enju_core/engine.rb
|
215
249
|
- lib/enju_core/expire_editable_fragment.rb
|
216
250
|
- lib/enju_core/expire_fragment_cache.rb
|