Class: AppHill::IO

Inherits:
Object
  • Object
show all
Defined in:
lib/apphill.rb

Defined Under Namespace

Classes: BIND

Class Method Summary collapse

Class Method Details

.appname_available(appname) ⇒ Object



73
74
75
# File 'lib/apphill.rb', line 73

def self.appname_available(appname)
   return !File.directory?(appname)
end

.appname_is_valid(appname) ⇒ Object



77
78
79
# File 'lib/apphill.rb', line 77

def self.appname_is_valid(appname)
   !appname.match(/\s/)
end

.generate_file(destination, filename, data) ⇒ Object



100
101
102
103
# File 'lib/apphill.rb', line 100

def self.generate_file(destination, filename, data)
    content = self.template_bind filename, data
       File.open(destination, 'w') {|f| f.write(content) }
end

.init_app(appname) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/apphill.rb', line 63

def self.init_app (appname)
      license =  self.license(:copyright_year => AppHill::Config.copyright_year, 
				  :copyright_name => AppHill::Config.copyright_name, 
				  :copyright_link => AppHill::Config.copyright_link)

   AppHill::IOS.new_project appname, {:app_id => "io.apphill.#{appname}", 
   									 :app_name => appname,
   									 :license => license}
end

.license(data) ⇒ Object



96
97
98
# File 'lib/apphill.rb', line 96

def self.license (data)
   self.template_bind @license_filename, data
end

.template_bind(filename, data) ⇒ Object



91
92
93
94
# File 'lib/apphill.rb', line 91

def self.template_bind(filename, data)
template = self.template_file filename
ERB.new(template).result(self::BIND.new(data).get_binding)
end

.template_file(filename) ⇒ Object



85
86
87
88
89
# File 'lib/apphill.rb', line 85

def self.template_file (filename)
   filepath = self.template_filepath filename
   file     = File.open(filepath, 'r').read
   return file
end

.template_filepath(filename) ⇒ Object



81
82
83
# File 'lib/apphill.rb', line 81

def self.template_filepath (filename)
   File.join @templates_dir, filename + ".erb"
end