Class: Starter::Import
Class Method Summary
collapse
add_mount_point, add_to_base, base_file, base_file_path, base_prefix, base_version, remove_from_base, remove_mount_point
Class Method Details
.create_files_from(spec) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/starter/import.rb', line 29
def create_files_from(spec)
spec.namespaces.each_with_object([]) do |(name_of, paths), memo|
@naming = Starter::Names.new(name_of)
namespace = Starter::Importer::Namespace.new(
naming: @naming,
paths: paths,
components: spec.components
)
break if ENV['RACK_ENV'] == 'test'
FileOps.write_file(@naming.api_file_name, namespace.content)
memo << @naming.api_file_name
add_mount_point
end
end
|
.do_it!(path) ⇒ Object
11
12
13
14
|
# File 'lib/starter/import.rb', line 11
def do_it!(path)
spec = load_spec(path)
create_files_from(spec)
end
|
.load_spec(path) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/starter/import.rb', line 16
def load_spec(path)
return nil if path.blank?
spec = case File.extname(path)[1..]
when 'yaml', 'yml'
YAML.load_file(path)
when 'json'
JSON.load_file(path)
end
Importer::Specification.new(spec:)
end
|