kiss 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/data/scaffold.tgz +0 -0
- data/lib/kiss/action.rb +16 -2
- data/lib/kiss/file_cache.rb +54 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.4
|
data/data/scaffold.tgz
CHANGED
Binary file
|
data/lib/kiss/action.rb
CHANGED
@@ -5,7 +5,7 @@ class Kiss
|
|
5
5
|
cattr_reader :class_unique, :template_class
|
6
6
|
|
7
7
|
class << self
|
8
|
-
_attr_reader :subdir, :part, :name, :
|
8
|
+
_attr_reader :subdir, :part, :name, :path, :parent_class, :object_options, :aliases
|
9
9
|
attr_reader :layout, :breadcrumbs, :authentication_required, :base_url
|
10
10
|
|
11
11
|
dsl_accessor :breadcrumb, :object_breadcrumb
|
@@ -17,6 +17,10 @@ class Kiss
|
|
17
17
|
@_child_classes = {}
|
18
18
|
end
|
19
19
|
|
20
|
+
def action_path
|
21
|
+
self.path
|
22
|
+
end
|
23
|
+
|
20
24
|
def get_subclass_from_path(path, request, params)
|
21
25
|
action_subdir = ''
|
22
26
|
action_path = '/'
|
@@ -190,7 +194,8 @@ class Kiss
|
|
190
194
|
@_subdir = subdir
|
191
195
|
@_part = part
|
192
196
|
@_name = name
|
193
|
-
@
|
197
|
+
@_path = "#{subdir}/#{part}"
|
198
|
+
@_file_path = path
|
194
199
|
@_parent_class = parent
|
195
200
|
@_breadcrumb = part ? part.titleize : nil
|
196
201
|
|
@@ -633,5 +638,14 @@ class Kiss
|
|
633
638
|
def invoke_action(path, params = {})
|
634
639
|
request.invoke_action(path, params).output
|
635
640
|
end
|
641
|
+
|
642
|
+
def action
|
643
|
+
self
|
644
|
+
end
|
645
|
+
|
646
|
+
def path
|
647
|
+
self.class.path
|
648
|
+
end
|
649
|
+
alias_method :action_path, :path
|
636
650
|
end
|
637
651
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Kiss
|
2
|
+
class CachedFile
|
3
|
+
_attr_accessor :path, :content, :last_modified_at, :cached_at
|
4
|
+
|
5
|
+
def new_with_path(path)
|
6
|
+
@_path = path
|
7
|
+
reload
|
8
|
+
end
|
9
|
+
|
10
|
+
def reload
|
11
|
+
now = Time.now
|
12
|
+
changed = false
|
13
|
+
|
14
|
+
if File.file?(path)
|
15
|
+
mtime = File.symlink?(path) ? File.lstat(path).mtime : File.mtime(path)
|
16
|
+
content = nil if last_modified_at && last_modified_at < mtime
|
17
|
+
if !content
|
18
|
+
content ||= ? File.read(path)
|
19
|
+
last_modified_at = mtime
|
20
|
+
changed = true
|
21
|
+
end
|
22
|
+
elsif content
|
23
|
+
content = nil
|
24
|
+
last_modified_at = nil
|
25
|
+
changed = true
|
26
|
+
end
|
27
|
+
cached_at = now
|
28
|
+
return changed
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class CachedRubyFile < CachedFile
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class FileCache
|
37
|
+
_attr_accessor :cached_files_by_path, :should_reload_files
|
38
|
+
|
39
|
+
def initialize(should_reload_files = true)
|
40
|
+
@_cached_files_by_path = {}
|
41
|
+
@_should_reload_files = should_reload_files
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_for_path(path)
|
45
|
+
file = @_cached_files_by_path[path]
|
46
|
+
if !file
|
47
|
+
file = @_cached_files_by_path[path] = CachedFile.new_with_path(path)
|
48
|
+
else
|
49
|
+
file.reload if should_reload_files
|
50
|
+
end
|
51
|
+
return file
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 1.8.
|
8
|
+
- 4
|
9
|
+
version: 1.8.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Shawn Van Ittersum
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-02-
|
17
|
+
date: 2012-02-14 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/kiss/ext/rack.rb
|
107
107
|
- lib/kiss/ext/sequel_database.rb
|
108
108
|
- lib/kiss/ext/sequel_mysql_dataset.rb
|
109
|
+
- lib/kiss/file_cache.rb
|
109
110
|
- lib/kiss/form/field.rb
|
110
111
|
- lib/kiss/form.rb
|
111
112
|
- lib/kiss/format.rb
|