Class: AsProject::PathFinder
Instance Attribute Summary collapse
#ignore_all, #replace_all
Instance Method Summary
collapse
#clean_file_name, #copy_file, #copy_files, #file_is_binary?, #project_name, #render_file, #should_render?, #write_file?
Constructor Details
#initialize(execution_dir = nil) ⇒ PathFinder
Returns a new instance of PathFinder.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/path_finder.rb', line 9
def initialize(execution_dir=nil)
super()
if(execution_dir.nil?)
@execution_dir = Dir.pwd
else
@execution_dir = execution_dir
end
@current_project = nil
@user = create_user
end
|
Instance Attribute Details
#execution_dir ⇒ Object
Returns the value of attribute execution_dir.
7
8
9
|
# File 'lib/path_finder.rb', line 7
def execution_dir
@execution_dir
end
|
Instance Method Details
#current_project ⇒ Object
Don’t store the ‘inspected’ current_project Only store it if the value was set from outside
72
73
74
75
76
77
78
|
# File 'lib/path_finder.rb', line 72
def current_project
if(@current_project.nil?)
return find_project(@execution_dir)
else
return @current_project
end
end
|
#current_project=(dir) ⇒ Object
65
66
67
|
# File 'lib/path_finder.rb', line 65
def current_project=(dir)
@current_project = dir
end
|
#flash_player_config ⇒ Object
28
29
30
|
# File 'lib/path_finder.rb', line 28
def flash_player_config
return @user.flash_player_config
end
|
#flash_player_config_content ⇒ Object
32
33
34
|
# File 'lib/path_finder.rb', line 32
def flash_player_config_content
return @user.flash_player_config_content
end
|
#flash_player_debug(version) ⇒ Object
36
37
38
|
# File 'lib/path_finder.rb', line 36
def flash_player_debug(version)
return @user.flash_player_debug(version)
end
|
#flash_player_home ⇒ Object
20
21
22
|
# File 'lib/path_finder.rb', line 20
def flash_player_home
return @user.flash_player_home
end
|
#flash_player_log ⇒ Object
24
25
26
|
# File 'lib/path_finder.rb', line 24
def flash_player_log
return @user.flash_player_log
end
|
#flash_player_trust ⇒ Object
40
41
42
|
# File 'lib/path_finder.rb', line 40
def flash_player_trust
return @user.flash_player_trust
end
|
#gem_asproject_home ⇒ Object
48
49
50
51
|
# File 'lib/path_finder.rb', line 48
def gem_asproject_home
parent = File.dirname(File.dirname(__FILE__))
return File.expand_path(parent)
end
|
#get_available_templates(type) ⇒ Object
Collect and return all available templates from: (PROJECT_PATH)/config/templates/(TYPE)/ (USER_HOME)/(ASPROJECT_HOME)/templates/ (ASPROJECT_GEM_HOME)/templates
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/path_finder.rb', line 97
def get_available_templates(type)
project_templates = get_children(get_project_template(type, ''))
user_templates = get_children(get_user_template(type, ''))
gem_templates = get_children(get_gem_template(type, ''))
result = []
project_templates.each do |template|
result << template
end
user_templates.each do |template|
if(!result.index(template))
result << template
end
end
gem_templates.each do |template|
if(!result.index(template))
result << template
end
end
return result
end
|
#get_children(dir) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/path_finder.rb', line 80
def get_children(dir)
list = []
if(dir.nil?)
return list
end
Dir.open(dir).each do |child|
if(!AsProject.ignore_file? child)
list << child
end
end
return list
end
|
#get_gem_template(type, name) ⇒ Object
160
161
162
163
164
165
166
|
# File 'lib/path_finder.rb', line 160
def get_gem_template(type, name)
template = File.expand_path(File.join(gem_asproject_home, 'templates', type, name))
if(File.exists? template)
return template
end
raise ProjectError.new('Requested template not found at ' + template)
end
|
#get_project_template(type, name) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/path_finder.rb', line 132
def get_project_template(type, name)
begin
if(@execution_dir.nil?)
dir = Dir.pwd
else
dir = @execution_dir
end
project = find_project(dir)
template = File.join(project, 'config', 'templates', type, name)
if(File.exists? template)
return template
else
return nil
end
rescue
return nil
end
end
|
#get_template(type, name) ⇒ Object
@type: ‘class’ or ‘project’ @name: ‘as3’, ‘mxml’, ‘fb2’, or user-created folder name Represents folders inside of the appropriate template type dir
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/path_finder.rb', line 121
def get_template(type, name)
template = get_project_template(type, name)
if(template.nil?)
template = get_user_template(type, name)
end
if(template.nil?)
template = get_gem_template(type, name)
end
return template
end
|
#get_user_template(type, name) ⇒ Object
151
152
153
154
155
156
157
158
|
# File 'lib/path_finder.rb', line 151
def get_user_template(type, name)
template = File.expand_path(File.join(user_asproject_home, 'templates', type, name))
if(File.exists? template)
return template
else
return nil
end
end
|
#remote_file_task(name, task) ⇒ Object
44
45
46
|
# File 'lib/path_finder.rb', line 44
def remote_file_task(name, task)
return @user.remote_file_task(name, task)
end
|
#user_asproject_home ⇒ Object
61
62
63
|
# File 'lib/path_finder.rb', line 61
def user_asproject_home
return @user.asproject_home
end
|
#user_home ⇒ Object
57
58
59
|
# File 'lib/path_finder.rb', line 57
def user_home
return @user.home
end
|
#user_library ⇒ Object
53
54
55
|
# File 'lib/path_finder.rb', line 53
def user_library
return @user.library
end
|