Class: Fangorn::Output
- Inherits:
-
Object
show all
- Defined in:
- lib/fangorn/output.rb
Constant Summary
collapse
- @@dist =
false
- @@source =
'app'
- @@dest =
nil
- @@env =
'default'
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(input, output) ⇒ Output
Returns a new instance of Output.
5
6
7
8
|
# File 'lib/fangorn/output.rb', line 5
def initialize(input, output)
@input, @output = input, output
@config = YAML.load_file 'fangorn.yml'
end
|
Class Method Details
.dest ⇒ Object
45
46
47
|
# File 'lib/fangorn/output.rb', line 45
def self.dest
File.absolute_path(@@dest || (@@dist ? 'dist' : 'public'))
end
|
.dest=(dest) ⇒ Object
57
58
59
|
# File 'lib/fangorn/output.rb', line 57
def self.dest= (dest)
@@dest = dest
end
|
.dist! ⇒ Object
49
50
51
|
# File 'lib/fangorn/output.rb', line 49
def self.dist!
@@dist = true
end
|
.dist? ⇒ Boolean
33
34
35
|
# File 'lib/fangorn/output.rb', line 33
def self.dist?
@@dist
end
|
.env ⇒ Object
37
38
39
|
# File 'lib/fangorn/output.rb', line 37
def self.env
@@env
end
|
.env=(env) ⇒ Object
61
62
63
|
# File 'lib/fangorn/output.rb', line 61
def self.env= (env)
@@env = env
end
|
.make(input) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/fangorn/output.rb', line 24
def self.make(input)
type = File.extname(input)[1..-1]
begin
Fangorn.const_get(type.capitalize).new input
rescue LoadError, NameError
StaticFile.new input
end
end
|
.source ⇒ Object
41
42
43
|
# File 'lib/fangorn/output.rb', line 41
def self.source
File.absolute_path(@@source)
end
|
.source=(source) ⇒ Object
53
54
55
|
# File 'lib/fangorn/output.rb', line 53
def self.source= (source)
@@source = source
end
|
Instance Method Details
#create! ⇒ Object
9
10
11
12
|
# File 'lib/fangorn/output.rb', line 9
def create!
FileUtils.mkdir_p File.dirname(@output)
create_command
end
|
#get_config ⇒ Object
19
20
21
22
23
|
# File 'lib/fangorn/output.rb', line 19
def get_config
if @config
@config[Output::env]
end
end
|
#remove! ⇒ Object
13
14
15
|
# File 'lib/fangorn/output.rb', line 13
def remove!
FileUtils.rm_f @output
end
|
#to_s ⇒ Object
16
17
18
|
# File 'lib/fangorn/output.rb', line 16
def to_s
@output
end
|