Class: RuneBlog::View
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/global.rb,
lib/view.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Helpers
#copy, #copy!, #create_dirs, #dump, #error, #find_draft_slugs, #get_views, #interpolate, #new_dotfile, #new_sequence, #read_config, #subdirs, #try_read_config, #write_config
Constructor Details
#initialize(name) ⇒ View
Returns a new instance of View.
10
11
12
13
14
15
16
17
|
# File 'lib/view.rb', line 10
def initialize(name)
log!(enter: __method__, args: [name])
raise NoBlogAccessor if RuneBlog.blog.nil?
@blog = RuneBlog.blog
@name = name
@publisher = RuneBlog::Publishing.new(name)
@can_publish = true
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/view.rb', line 5
def name
@name
end
|
#publisher ⇒ Object
Returns the value of attribute publisher.
6
7
8
|
# File 'lib/view.rb', line 6
def publisher
@publisher
end
|
#state ⇒ Object
Returns the value of attribute state.
5
6
7
|
# File 'lib/view.rb', line 5
def state
@state
end
|
Instance Method Details
#can_publish? ⇒ Boolean
56
57
58
59
|
# File 'lib/view.rb', line 56
def can_publish?
log!(enter: __method__)
@can_publish
end
|
#dir ⇒ Object
19
20
21
22
|
# File 'lib/view.rb', line 19
def dir
log!(enter: __method__)
@blog.root + "/views/#@name/"
end
|
#index ⇒ Object
29
30
31
32
|
# File 'lib/view.rb', line 29
def index
log!(enter: __method__)
dir + "index.html"
end
|
#local_index ⇒ Object
24
25
26
27
|
# File 'lib/view.rb', line 24
def local_index
log!(enter: __method__)
dir + "/remote/index.html"
end
|
#publishable_files ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/view.rb', line 39
def publishable_files
log!(enter: __method__)
vdir = dir()
remote = local_index()
files = [remote]
others = Dir.entries(vdir + "/remote").map {|x| "#{vdir}/remote/#{x}" }
assets = Dir.entries("#{vdir}/assets") - %w[. ..]
assets.map! {|x| "#{vdir}/assets/#{x}" }
assets.reject! {|x| File.directory?(x) }
files = files + others
all = files.dup
dirty = files.reject {|f| ! recent?(f) }
[dirty, all, assets]
end
|
#recent?(file) ⇒ Boolean
61
62
63
64
65
66
|
# File 'lib/view.rb', line 61
def recent?(file)
log!(enter: __method__, args: [file])
File.mtime(file) > File.mtime("#{dir()}/last_published")
rescue
true
end
|
#to_s ⇒ Object
34
35
36
37
|
# File 'lib/view.rb', line 34
def to_s
log!(enter: __method__)
@name
end
|