Sha256: 24fcaa6ca01498328af925b1c4c857a7b6af429e2aca9db1d76d536a1b1162eb
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
#!/usr/bin/env ruby -W require 'json' require_relative 'platform' module WeexBuilder module Project PACKAGE_JSON_PATH = File.join(Dir.pwd, 'package.json') module_function 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 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 def remove_platform(platform) end def project_name return unless exist? json = File.read(PACKAGE_JSON_PATH) JSON.parse(json)["name"] end def exist? File.exist?(PACKAGE_JSON_PATH) end def platform_exist?(platform) Dir.glob("Platforms/#{platform}").length > 0 end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
weexbuilder-0.0.4 | lib/project.rb |
weexbuilder-0.0.3 | lib/project.rb |
weexbuilder-0.0.2 | lib/project.rb |
weexbuilder-0.0.1 | lib/project.rb |