Class: Pullentity::Client::Generate::Exporter
- Inherits:
-
Thor
- Object
- Thor
- Pullentity::Client::Generate::Exporter
show all
- Extended by:
- Utils
- Includes:
- Utils
- Defined in:
- lib/pullentity-client/generate/exporter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
base_location, create_directories, create_new_file, create_with_template, error, log, remove_directories, remove_files, templates, touch, underscore
Class Method Details
.assets_hash ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/pullentity-client/generate/exporter.rb', line 60
def assets_hash
images = []
Dir.foreach(location.join("build/assets/images") ).grep(/.jpg|.jpeg|.png|.gif|.ico/).each do |image|
images << image
end
fonts = []
Dir.foreach(location.join("build/assets/fonts") ).grep(/.eot|.svg|.ttf|.woff/).each do |font|
fonts << font
end
jss = []
Dir.foreach(location.join("build/assets/javascripts") ).grep(/.js$/).each do |js|
jss << js
end
styles = []
Dir.foreach(location.join("build/assets/stylesheets") ).grep(/.css/).each do |css|
styles << css
end
js = File.open(location.join("build/assets/javascripts/application.js")).readlines.join("")
css = File.open(location.join("build/assets/stylesheets/application.css")).readlines.join("")
{ :images => images , :js => jss, :css => styles , :fonts=> fonts }
end
|
.build_hash_output(name) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/pullentity-client/generate/exporter.rb', line 45
def build_hash_output(name)
@full_app_hash = {
:theme_name => name,
:themes => @theme_list,
:js => @js,
:css => @css,
:layout => @layout,
:head=> @head,
:list=> @list,
:assets => assets_hash
}
end
|
.build_shared_views ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/pullentity-client/generate/exporter.rb', line 36
def build_shared_views
@js = Nokogiri::HTML(File.open(location.join("build/views/shared/js.html")).readlines.join("")).css("script").first.content
@head = File.open(location.join("build/views/shared/head.html")).readlines.join("")
@css = Nokogiri::HTML(File.open(location.join("build/views/shared/css.html")).readlines.join("")).css("style").first.content
@layout = Nokogiri::HTML(File.open(location.join("build/views/shared/body.html")).readlines.join("")).css("script").first.content
@list = File.open(location.join("build/views/list.html")).readlines.join("")
end
|
.build_theme_list ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/pullentity-client/generate/exporter.rb', line 21
def build_theme_list
@theme_list = []
Dir.foreach(location.join("build/views/themes") ).grep(/.html/).each do |theme|
@theme_list << {
:name => theme.gsub(".html", "") ,
:content => File.open(location.join("build/views/themes/#{theme}")).readlines.join("")
}
end
end
|
.create(name) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/pullentity-client/generate/exporter.rb', line 14
def create(name)
build_theme_list
build_shared_views
build_hash_output(name)
create_with_template('pullentity_build.json', 'defaults/build.yml', { :json=> @full_app_hash })
end
|
.location ⇒ Object
88
89
90
|
# File 'lib/pullentity-client/generate/exporter.rb', line 88
def location
base_location
end
|
.name_from_yaml ⇒ Object
31
32
33
34
|
# File 'lib/pullentity-client/generate/exporter.rb', line 31
def name_from_yaml
yml = YAML.load(File.open(location.join("pullentity.yml")))
return yml["theme_name"]
end
|
.source_root ⇒ Object
93
94
95
|
# File 'lib/pullentity-client/generate/exporter.rb', line 93
def source_root
File.dirname(__FILE__)
end
|
Instance Method Details
#export ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/pullentity-client/generate/exporter.rb', line 102
def export
begin
name_for = YAML.load_file(location + "pullentity.yml")["theme_name"]
rescue => e
say "Error, make sure you are inside a pullentity project", :red
say "and pullentity.yml file is created" , :red
raise
end
name_for = YAML.load_file(location + "pullentity.yml")["theme_name"]
::Pullentity::Client::Builder::Middleman.build
::Pullentity::Client::Generate::Exporter.create(name_for)
::Pullentity::Client::Generate::Auth.start(['export', name_for])
end
|