lib/dscript.rb in andhapp-decoct-1.3.0 vs lib/dscript.rb in andhapp-decoct-1.4.0
- old
+ new
@@ -1,16 +1,19 @@
-require 'ftools'
-require File.dirname(__FILE__) + '/../lib/dconstants'
+require File.dirname(__FILE__) + '/../lib/dmeta'
module Decoct
-
- include Decoct::Dconstants
- # move the creation into a module and just include that module
class Dscript
+ include Decoct::Dmeta
+
attr_accessor :app_name
+
+ create_dir :lib
+ create_dir :spec
+ create_dir :views
+ create_dir :public
def initialize(app_name)
fail "app name cannot be nil or empty!!!" if app_name.eql?(nil) || app_name.empty?
@app_name = app_name
end
@@ -21,57 +24,30 @@
create_spec
create_views
create_public
copy_autotest_file
copy_rspec_files
- create_app_file
+ copy_app_file
end
- def create_lib
- create_dir(Dconstants::LIB)
+ def create_app_dir
+ Dir.mkdir("#{app_name}") if !test(?d, "#{app_name}")
end
- def create_spec
- create_dir(Dconstants::SPEC)
- end
-
- def create_views
- create_dir(Dconstants::VIEWS)
- end
-
- def create_public
- create_dir(Dconstants::PUBLIC)
- end
-
def copy_autotest_file
copy_file(".autotest", "#{app_name}/.autotest")
end
def copy_rspec_files
copy_file("spec/spec.opts", "#{app_name}/spec/spec.opts")
copy_file("spec/rcov.opts", "#{app_name}/spec/rcov.opts")
copy_file("spec/spec_helper.rb", "#{app_name}/spec/spec_helper.rb")
+ copy_file("spec/app_spec.rb", "#{app_name}/spec/#{app_name}_spec.rb")
end
- def create_app_file
+ def copy_app_file
copy_file("generic_app.rb", "#{app_name}/#{app_name}.rb")
end
- def create_app_dir
- create_dir
- end
-
- private
-
- def create_dir(value = '')
- path = "#{app_name}/#{value}"
- Dir.mkdir(path) if !test(?d, path)
- end
-
- def copy_file(from, to)
- File.copy(Dconstants::TEMPLATES + from, to)
- end
-
end
end
-