Module: WeexBuilder::Project
- Defined in:
- lib/project.rb
Constant Summary collapse
- PACKAGE_JSON_PATH =
File.join(Dir.pwd, 'package.json')
Class Method Summary collapse
- .add_platform(platform) ⇒ Object
- .create(name) ⇒ Object
- .exist? ⇒ Boolean
- .platform_exist?(platform) ⇒ Boolean
- .project_name ⇒ Object
- .remove_platform(platform) ⇒ Object
Class Method Details
.add_platform(platform) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# 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) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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? ⇒ Boolean
52 53 54 |
# File 'lib/project.rb', line 52 def exist? File.exist?(PACKAGE_JSON_PATH) end |
.platform_exist?(platform) ⇒ Boolean
56 57 58 |
# File 'lib/project.rb', line 56 def platform_exist?(platform) Dir.glob("Platforms/#{platform}").length > 0 end |
.project_name ⇒ Object
46 47 48 49 50 |
# 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) ⇒ Object
41 42 43 |
# File 'lib/project.rb', line 41 def remove_platform(platform) end |