module WeexBuilder::Project

Constants

PACKAGE_JSON_PATH

Public Instance Methods

add_platform(platform) click to toggle source
# File lib/project.rb, line 29
def add_platform(platform)
  return puts 'A Weex Project does Not Found.' unless exist?

  if /ios/i =~ platform
    platform = "iOS"
  else 
    platform = "Android"
  end

  WeexBuilder::Platform.add(platform, project_name)
end
create(name) click to toggle source
# File lib/project.rb, line 12
def create(name)
  # puts PACKAGE_JSON_PATH

  if Dir.exist?(File.join(Dir.pwd, "#{name}")) || exist?
    return puts "A Weex Project Already Exist."
  end

  template_url = 'http://git.yanzijia.cn/guoyehui/weex-template.git'
  return unless system "git clone #{template_url} #{name}"
  packagejson_path = File.join(Dir.pwd, "#{name}", 'package.json')
  File.open(packagejson_path, 'r') do |output|
    buffer = output.read.gsub(/__WEEXTEMPLATE__/, "#{name}")
    File.open(packagejson_path, 'w') { |input| input.write(buffer) } 
  end
  puts "The Project #{name} Was Created Succeed."
end
exist?() click to toggle source
# File lib/project.rb, line 52
def exist? 
  File.exist?(PACKAGE_JSON_PATH)
end
platform_exist?(platform) click to toggle source
# File lib/project.rb, line 56
def platform_exist?(platform)
  Dir.glob("Platforms/#{platform}").length > 0
end
project_name() click to toggle source
# File lib/project.rb, line 46
def project_name
  return unless exist?
  json = File.read(PACKAGE_JSON_PATH)
  JSON.parse(json)["name"]
end
remove_platform(platform) click to toggle source
# File lib/project.rb, line 41
def remove_platform(platform)

end