gocart 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/assets/Gemfile +24 -0
- data/assets/Guardfile +37 -0
- data/assets/Rakefile +5 -0
- data/assets/config.rb +24 -0
- data/assets/spec/javascripts/support/jasmine.yml +86 -0
- data/assets/spec/javascripts/support/jasmine_config.rb +23 -0
- data/assets/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/assets/src/server/http_handler.go +136 -0
- data/assets/src/server/main.go +31 -0
- data/assets/src/server/templates.go +42 -0
- data/assets/src/www/app/coffee/adapters/dummy_data.js.coffee +6 -0
- data/assets/src/www/app/coffee/adapters/reddit.js.coffee +294 -0
- data/assets/src/www/app/coffee/application.js.coffee +23 -0
- data/assets/src/www/app/coffee/controllers/app.js.coffee +69 -0
- data/assets/src/www/app/coffee/controllers/nav.js.coffee +55 -0
- data/assets/src/www/app/coffee/controllers/subreddit_posts.js.coffee +57 -0
- data/assets/src/www/app/coffee/helpers/event_manager.js.coffee +3 -0
- data/assets/src/www/app/coffee/helpers/properties.js.coffee +19 -0
- data/assets/src/www/app/coffee/helpers/storage.js.coffee +14 -0
- data/assets/src/www/app/coffee/libs/3rdparty.js.coffee +7 -0
- data/assets/src/www/app/coffee/libs/deferred.js.coffee +92 -0
- data/assets/src/www/app/coffee/libs/logger.js.coffee +40 -0
- data/assets/src/www/app/coffee/libs/mod_loader.js.coffee +44 -0
- data/assets/src/www/app/coffee/main.js.coffee +42 -0
- data/assets/src/www/app/coffee/models/comment.js.coffee +26 -0
- data/assets/src/www/app/coffee/models/post.js.coffee +27 -0
- data/assets/src/www/app/coffee/models/sub_reddit.js.coffee +18 -0
- data/assets/src/www/app/coffee/widgets/post_detail.js.coffee +2 -0
- data/assets/src/www/app/coffee/widgets/posts.js.coffee +45 -0
- data/assets/src/www/app/coffee/widgets/subreddit_detail.js.coffee +2 -0
- data/assets/src/www/app/coffee/widgets/subreddits.js.coffee +44 -0
- data/assets/src/www/app/images/test.png +0 -0
- data/assets/src/www/app/partials/index.html +92 -0
- data/assets/src/www/app/sass/application.css.scss +136 -0
- data/assets/src/www/app/templates/application.gotmpl +2 -0
- data/assets/src/www/app/templates/base.gotmpl.erb +27 -0
- data/assets/src/www/app/templates/home.gotmpl +9 -0
- data/assets/src/www/spec/coffee/deferred-spec.coffee +202 -0
- data/assets/src/www/spec/coffee/mocks.coffee +137 -0
- data/assets/src/www/spec/coffee/mod_loader-spec.coffee +45 -0
- data/assets/src/www/spec/coffee/properties-spec.coffee +21 -0
- data/assets/src/www/spec/coffee/reddit_adapter-spec.coffee +143 -0
- data/assets/src/www/vendor/css/jq.ui.css +630 -0
- data/assets/src/www/vendor/images/ajax-loader.png +0 -0
- data/assets/src/www/vendor/images/icons-18-black.png +0 -0
- data/assets/src/www/vendor/images/icons-18-white.png +0 -0
- data/assets/src/www/vendor/images/icons-36-black.png +0 -0
- data/assets/src/www/vendor/images/icons-36-white.png +0 -0
- data/assets/src/www/vendor/js/ICanHaz.min.js +10 -0
- data/assets/src/www/vendor/js/jq.mobi.min.js +20 -0
- data/assets/src/www/vendor/js/jq.ui.min.js +90 -0
- data/assets/src/www/vendor/js/jq.web.min.js +58 -0
- data/assets/src/www/vendor/js/phonegap-1.1.0.js +4577 -0
- data/assets/src/www/vendor/js/touch.js +103 -0
- data/assets/tasks/app.rake +34 -0
- data/assets/tasks/jasmine.rake +8 -0
- data/assets/tasks/server.rake +58 -0
- data/assets/tasks/www.rake +163 -0
- data/bin/gocart +25 -0
- data/lib/gocart.rb +5 -6
- data/lib/gocart/base.rb +28 -0
- data/lib/gocart/environment.rb +18 -0
- data/lib/gocart/version.rb +1 -1
- metadata +113 -41
- data/.gitignore +0 -4
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/gocarg.go +0 -29
- data/gocart.gemspec +0 -38
@@ -0,0 +1,103 @@
|
|
1
|
+
redirectMouseToTouch = function(type, originalEvent)
|
2
|
+
{
|
3
|
+
|
4
|
+
//stop propagation, and remove default behavior for everything but INPUT, TEXTAREA & SELECT fields
|
5
|
+
// originalEvent.stopPropagation();
|
6
|
+
if (originalEvent.target.tagName.toUpperCase().indexOf("SELECT") == -1 &&
|
7
|
+
originalEvent.target.tagName.toUpperCase().indexOf("TEXTAREA") == -1 &&
|
8
|
+
originalEvent.target.tagName.toUpperCase().indexOf("INPUT") == -1) //SELECT, TEXTAREA & INPUT
|
9
|
+
{
|
10
|
+
//if(type != 'touchstart')
|
11
|
+
//originalEvent.stopPropagation();//originalEvent.preventDefault();
|
12
|
+
//else
|
13
|
+
//originalEvent.preventDefault();
|
14
|
+
originalEvent.stopPropagation();
|
15
|
+
}
|
16
|
+
|
17
|
+
var touchevt = document.createEvent("Event");
|
18
|
+
touchevt.initEvent(type, true, true);
|
19
|
+
touchevt.touches = new Array();
|
20
|
+
touchevt.touches[0] = new Object();
|
21
|
+
touchevt.touches[0].pageX = originalEvent.clientX;
|
22
|
+
touchevt.touches[0].pageY = originalEvent.clientY;
|
23
|
+
touchevt.touches[0].target = originalEvent.target;
|
24
|
+
touchevt.changedTouches = touchevt.touches; //for jqtouch
|
25
|
+
touchevt.targetTouches = touchevt.touches; //for jqtouch
|
26
|
+
touchevt.touches[0].clientX = touchevt.touches[0].pageX; //compatibility code
|
27
|
+
touchevt.touches[0].clientY = touchevt.touches[0].pageY; //compatibility code
|
28
|
+
touchevt.target = originalEvent.target;
|
29
|
+
originalEvent.target.dispatchEvent(touchevt);
|
30
|
+
return touchevt;
|
31
|
+
}
|
32
|
+
|
33
|
+
emulateTouchEvents = function()
|
34
|
+
{
|
35
|
+
//return;
|
36
|
+
//if(emulatorReady)
|
37
|
+
//frm.contentWindow.AppMobi.setReady();
|
38
|
+
// var ee=window.querySelectorAll("*");
|
39
|
+
var ee = document;
|
40
|
+
// for(var x=0;x<ee.length;x++)
|
41
|
+
//{
|
42
|
+
//ee[x].mouseMoving=false;
|
43
|
+
document.mouseMoving = false;
|
44
|
+
|
45
|
+
|
46
|
+
document.addEventListener("mousedown", function(e)
|
47
|
+
{
|
48
|
+
try
|
49
|
+
{
|
50
|
+
// if (e.target != e.currentTarget)
|
51
|
+
// return;
|
52
|
+
this.mouseMoving = true;
|
53
|
+
//fire off a touchstart event
|
54
|
+
var touchevt = redirectMouseToTouch("touchstart", e);
|
55
|
+
if (document.ontouchstart)
|
56
|
+
document.ontouchstart(touchevt);
|
57
|
+
if(originalEvent.target.ontouchstart)
|
58
|
+
originalEvent.target.ontouchstart(touchevt);
|
59
|
+
|
60
|
+
} catch (e) {
|
61
|
+
}
|
62
|
+
});
|
63
|
+
|
64
|
+
//ee[x].onmouseup=function(e)
|
65
|
+
document.addEventListener("mouseup", function(e)
|
66
|
+
{
|
67
|
+
try
|
68
|
+
{
|
69
|
+
// if (e.target != e.currentTarget)
|
70
|
+
// return;
|
71
|
+
this.mouseMoving = false;
|
72
|
+
//fire off a touchstart event
|
73
|
+
var touchevt = redirectMouseToTouch("touchend", e);
|
74
|
+
if (document.ontouchend)
|
75
|
+
document.ontouchend(touchevt);
|
76
|
+
if(originalEvent.target.ontouchend)
|
77
|
+
originalEvent.target.ontouchend(touchevt);
|
78
|
+
}
|
79
|
+
catch (e) {
|
80
|
+
}
|
81
|
+
});
|
82
|
+
//ee[x].onmousemove=function(e)
|
83
|
+
document.addEventListener("mousemove", function(e)
|
84
|
+
{
|
85
|
+
try
|
86
|
+
{
|
87
|
+
// if (e.target != e.currentTarget)
|
88
|
+
// return;
|
89
|
+
if (!this.mouseMoving)
|
90
|
+
return;
|
91
|
+
//fire off a touchstart event
|
92
|
+
var touchevt = redirectMouseToTouch("touchmove", e);
|
93
|
+
if (document.ontouchmove)
|
94
|
+
document.ontouchmove(touchevt);
|
95
|
+
if(originalEvent.target.ontouchmove)
|
96
|
+
originalEvent.target.ontouchmove(touchevt);
|
97
|
+
}
|
98
|
+
catch (e) {
|
99
|
+
}
|
100
|
+
});
|
101
|
+
// }
|
102
|
+
}
|
103
|
+
emulateTouchEvents();
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
namespace :app do
|
3
|
+
desc 'Default action to perform, builds the app then runs it'
|
4
|
+
task :default => [:start]
|
5
|
+
|
6
|
+
desc 'Builds build app source files'
|
7
|
+
task :build => ['www:build', 'server:build']
|
8
|
+
|
9
|
+
desc 'Cleans the build paths for build parts of the app'
|
10
|
+
task :clean => [:stop, 'www:clean', 'server:clean']
|
11
|
+
|
12
|
+
desc 'Cleans the build paths then builds are source files'
|
13
|
+
task :rebuild => [:clean, :build]
|
14
|
+
|
15
|
+
desc 'Runs the test units for build source files'
|
16
|
+
task :test => ['www:test', 'server:test']
|
17
|
+
|
18
|
+
desc 'Stops and restarts the server'
|
19
|
+
task :restart => [:stop, :start]
|
20
|
+
|
21
|
+
desc 'Builds the app if needed, and starts it'
|
22
|
+
task :start => [:build, 'server:start']
|
23
|
+
|
24
|
+
desc 'Builds the app if wth debug, and starts it'
|
25
|
+
task :startdebug => [:build, 'server:startdebug']
|
26
|
+
|
27
|
+
desc 'Stops the server if it was running'
|
28
|
+
task :stop => ['server:stop']
|
29
|
+
|
30
|
+
desc 'Runs the guard command within bundler'
|
31
|
+
task :guard => [:rebuild] do
|
32
|
+
`bundle exec guard`
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
namespace :app do
|
4
|
+
namespace :server do
|
5
|
+
task :init do
|
6
|
+
dirs = []
|
7
|
+
dirs << GO_BUILD_PATH
|
8
|
+
|
9
|
+
dirs.each do |path|
|
10
|
+
begin
|
11
|
+
FileUtils::mkdir_p(path) if (!FileTest::directory?(path))
|
12
|
+
rescue
|
13
|
+
puts "Failed to create directory #{path}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Builds the existing source'
|
19
|
+
task :build => [:init] do
|
20
|
+
`GOPATH="#{ROOT}" go install #{GO_APP_NAME} 1>&2`
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Cleans the build path'
|
24
|
+
task :clean do
|
25
|
+
paths = []
|
26
|
+
paths << File.join(GO_BUILD_PATH, 'server')
|
27
|
+
|
28
|
+
paths.each do |path|
|
29
|
+
begin
|
30
|
+
FileUtils::rm_rf path
|
31
|
+
rescue
|
32
|
+
puts "Failed to clean server's #{path}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Runs the test units for the source files'
|
38
|
+
task :test => [:build] do
|
39
|
+
`GOAPTH="#{ROOT}" go test #{GO_APP_NAME} 1>&2`
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Runs the server, killing old instance if there was one.'
|
43
|
+
task :start, [:port, :static] => [:stop] do |t, args|
|
44
|
+
args.with_defaults(:port => 8080, :static => :true)
|
45
|
+
`./bin/#{GO_APP_NAME} -port=#{args[:port]} -static=#{args[:static]} -tmpl="#{TMPL_BUILD_PATH}" -www="#{MIN_WWW_PATH}"`
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Runs the server, killing old instance if there was one.'
|
49
|
+
task :startdebug, [:port] => [:stop] do |t, args|
|
50
|
+
args.with_defaults(:port => 8080, :static => :true)
|
51
|
+
`./bin/#{GO_APP_NAME} -port=#{args[:port]} -debug=true -static=true -tmpl="#{TMPL_BUILD_PATH}" -www="#{DEBUG_WWW_PATH}"`
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Stops the server if it was running'
|
55
|
+
task :stop do
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'coffee_script'
|
3
|
+
require 'sass'
|
4
|
+
require 'yui/compressor'
|
5
|
+
require 'uglifier'
|
6
|
+
require 'sprockets'
|
7
|
+
|
8
|
+
sprockets = (Sprockets::Environment.new(ROOT) { |env| env.logger = Logger.new(STDOUT) })
|
9
|
+
sprockets.append_path WWW_SRC_VENDOR_PATH.join('css').to_s
|
10
|
+
sprockets.append_path WWW_SRC_APP_PATH.join('sass').to_s
|
11
|
+
sprockets.append_path WWW_SRC_VENDOR_PATH.join('js').to_s
|
12
|
+
sprockets.append_path WWW_SRC_APP_PATH.join('coffee').to_s
|
13
|
+
sprockets.append_path WWW_SRC_APP_PATH.join('templates').to_s
|
14
|
+
# Note: Requires JVM for YUI
|
15
|
+
sprockets.css_compressor = YUI::CssCompressor.new
|
16
|
+
sprockets.js_compressor = Uglifier.new(mangle: true)
|
17
|
+
|
18
|
+
# Add the go template mime type/extension so we can specify the directive processors in them
|
19
|
+
sprockets.register_mime_type('text/gotmpl', '.gotmpl')
|
20
|
+
sprockets.register_processor('text/gotmpl', Sprockets::DirectiveProcessor)
|
21
|
+
|
22
|
+
|
23
|
+
desc 'Iterates over the input directory building a list of coffee files to compile'
|
24
|
+
def coffee(inDir, outDir)
|
25
|
+
Dir.glob("#{inDir}/**/*.coffee").each do |file|
|
26
|
+
outFile = file.partition(inDir)[2]
|
27
|
+
next if (outFile.empty?)
|
28
|
+
outFile.sub!(/coffee$/, 'js')
|
29
|
+
coffee_compile(file, outDir+outFile)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Compiles the coffee script file and writes it to the out'
|
34
|
+
def coffee_compile(inFile, outFile)
|
35
|
+
begin
|
36
|
+
File.delete(outFile) if (FileTest::file?(outFile))
|
37
|
+
FileUtils::mkdir_p(File.dirname(outFile)) if (!FileTest::directory?(File.dirname(outFile)))
|
38
|
+
|
39
|
+
f = File.new(outFile, "w")
|
40
|
+
f.write(CoffeeScript.compile(File.read(inFile)))
|
41
|
+
f.close()
|
42
|
+
rescue
|
43
|
+
puts "Failed to compile #{inFile} to #{outFile}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :app do
|
48
|
+
namespace :www do
|
49
|
+
task :init do
|
50
|
+
paths = []
|
51
|
+
paths << File.join(MIN_WWW_PATH, 'js')
|
52
|
+
paths << File.join(MIN_WWW_PATH, 'css')
|
53
|
+
paths << File.join(MIN_WWW_PATH, 'images')
|
54
|
+
paths << File.join(MIN_WWW_PATH, 'partials')
|
55
|
+
paths << File.join(DEBUG_WWW_PATH, 'js')
|
56
|
+
paths << File.join(DEBUG_WWW_PATH, 'css')
|
57
|
+
paths << File.join(DEBUG_WWW_PATH, 'images')
|
58
|
+
paths << File.join(DEBUG_WWW_PATH, 'partials')
|
59
|
+
paths << TMPL_BUILD_PATH
|
60
|
+
|
61
|
+
paths.each do |path|
|
62
|
+
begin
|
63
|
+
FileUtils::mkdir_p(path) if (!FileTest::directory?(path))
|
64
|
+
rescue
|
65
|
+
puts "Failed to create directory #{path}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
task :spec_coffee do
|
71
|
+
coffee "#{WWW_SRC_SPEC_PATH}/coffee", WWW_SPEC_PATH.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
task :images do
|
75
|
+
from = File.join(WWW_SRC_APP_PATH, 'images')
|
76
|
+
to = DEBUG_WWW_PATH
|
77
|
+
begin
|
78
|
+
FileUtils::cp_r from, to
|
79
|
+
rescue
|
80
|
+
puts "Failed to copy directory #{from} to #{to}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
task :partials do
|
85
|
+
from = File.join(WWW_SRC_APP_PATH, 'partials')
|
86
|
+
to = DEBUG_WWW_PATH
|
87
|
+
begin
|
88
|
+
FileUtils::cp_r from, to
|
89
|
+
rescue
|
90
|
+
puts "Failed to copy directory #{from} to #{to}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
task :vendor do
|
95
|
+
from = "#{WWW_SRC_VENDOR_PATH}/images"
|
96
|
+
to = File.join(DEBUG_WWW_PATH, 'vendor', 'images')
|
97
|
+
begin
|
98
|
+
FileUtils::cp_r from, to
|
99
|
+
rescue
|
100
|
+
puts "Failed to copy directory #{from} to #{to}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
desc 'Compiles the asset files into those usable by the browser'
|
105
|
+
task :compile do
|
106
|
+
ASSET_BUNDLES.each do |bundle|
|
107
|
+
assets = sprockets.find_asset(bundle)
|
108
|
+
|
109
|
+
# drop all extentions except the first
|
110
|
+
realname = assets.pathname.basename.to_s.split(".")[0..1].join(".")
|
111
|
+
prefix = File.extname(realname).split('.').last
|
112
|
+
outfile = MIN_WWW_PATH.join(prefix, realname)
|
113
|
+
|
114
|
+
assets.write_to(outfile)
|
115
|
+
assets.write_to("#{outfile}.gz")
|
116
|
+
|
117
|
+
# For each asset in the bundle write them to the debug output
|
118
|
+
assets.to_a.each do |asset|
|
119
|
+
# strip filename.css.foo.bar.css multiple extensions, but maintain the base directory of the file
|
120
|
+
realname = asset.pathname.basename.to_s.split(".")[0..1].join(".")
|
121
|
+
outPath = DEBUG_WWW_PATH.join(prefix, File.dirname(asset.logical_path))
|
122
|
+
FileUtils::mkdir_p(outPath) if (!FileTest::directory?(outPath))
|
123
|
+
asset.write_to(outPath.join(realname))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
desc 'Compiles the go template files and concats them'
|
129
|
+
task :compile_templates do
|
130
|
+
assets = sprockets.find_asset("application.gotmpl")
|
131
|
+
|
132
|
+
# drop all extentions except the first
|
133
|
+
realname = assets.pathname.basename.to_s.split(".")[0..1].join(".")
|
134
|
+
# prefix = File.extname(realname).split('.').last
|
135
|
+
outfile = TMPL_BUILD_PATH.join(realname)
|
136
|
+
|
137
|
+
assets.write_to(outfile)
|
138
|
+
end
|
139
|
+
|
140
|
+
desc 'Builds the existing source'
|
141
|
+
task :build => [:init,:compile,:compile_templates,:spec_coffee,:images,:partials]
|
142
|
+
|
143
|
+
desc 'Cleans the build path'
|
144
|
+
task :clean do
|
145
|
+
paths = []
|
146
|
+
paths << ASSETS_PATH
|
147
|
+
paths << TMPL_BUILD_PATH
|
148
|
+
paths << Dir.glob("#{WWW_SPEC_PATH}/*.js")
|
149
|
+
|
150
|
+
paths.each do |path|
|
151
|
+
begin
|
152
|
+
FileUtils::rm_rf path
|
153
|
+
rescue
|
154
|
+
puts "Failed to clean www's #{path}"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
desc 'Runs the test units for the source files'
|
160
|
+
task :test => [:build, 'jasmine:ci']
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
data/bin/gocart
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'gocart'
|
4
|
+
require 'pathname'
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
|
8
|
+
root = Pathname(File.dirname(__FILE__)).join('../')
|
9
|
+
app_name = ARGV[0]
|
10
|
+
gocart = Gocart::Environment.new(root, app_name)
|
11
|
+
|
12
|
+
unless gocart.app_name_valid?
|
13
|
+
exit(-1)
|
14
|
+
end
|
15
|
+
|
16
|
+
gocart.build_app_dir
|
17
|
+
|
18
|
+
Dir.chdir(app_name)
|
19
|
+
|
20
|
+
Open3.popen3('bundle install') do | i, o, e |
|
21
|
+
while (out = o.gets || err = e.gets)
|
22
|
+
$stdout.puts out unless out.nil?
|
23
|
+
$stderr.puts err unless err.nil?
|
24
|
+
end
|
25
|
+
end
|
data/lib/gocart.rb
CHANGED
data/lib/gocart/base.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Gocart
|
4
|
+
attr_reader :app_name, :app_parent_path, :app_base_path, :assets_path
|
5
|
+
attr_accessor :logger
|
6
|
+
|
7
|
+
class Base
|
8
|
+
def app_name_valid?
|
9
|
+
unless File.stat(@app_parent_path).readable?
|
10
|
+
@logger.fatal("App parent directory is not readable")
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
unless File.stat(@app_parent_path).writable?
|
14
|
+
@logger.fatal("App parent directory is not writable")
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
if Dir.exist?(@app_base_path)
|
18
|
+
@logger.fatal("App #{@app_name} directory already exists")
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_app_dir
|
25
|
+
FileUtils::cp_r @assets_path, @app_base_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'gocart/base'
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
module Gocart
|
7
|
+
class Environment < Base
|
8
|
+
def initialize(root, app_name)
|
9
|
+
@logger = Logger.new($stderr)
|
10
|
+
@logger.level = Logger::FATAL
|
11
|
+
|
12
|
+
@app_parent_path = Pathname(Dir.pwd.to_s)
|
13
|
+
@app_base_path = @app_parent_path.join(app_name)
|
14
|
+
@app_name = app_name
|
15
|
+
@assets_path = Pathname(root).join('assets')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|