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.
@@ -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
@@ -6,6 +6,9 @@ require 'attribute_normalizer'
6
6
  require 'friendly_id'
7
7
  require 'addressable/uri'
8
8
  require 'sunspot_rails'
9
+ require 'will_paginate/array'
10
+ require 'resque'
11
+ require 'configatron'
9
12
 
10
13
  module EnjuCore
11
14
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module EnjuCore
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/enju_core.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "enju_core/engine"
2
+ require "enju_core/bookmark_url"
3
+ require "enju_core/calculate_stat"
2
4
  require "enju_core/expire_editable_fragment"
3
5
  require "enju_core/expire_fragment_cache"
4
6
  require "enju_core/import_file"
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.1
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-19 00:00:00.000000000 Z
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