Class: Pod::VemarsProject
- Inherits:
-
Object
- Object
- Pod::VemarsProject
- Defined in:
- lib/cocoapods-vemars/command/project.rb
Instance Attribute Summary collapse
-
#basicInfo ⇒ Object
readonly
Returns the value of attribute basicInfo.
-
#components_details ⇒ Object
Returns the value of attribute components_details.
-
#git_url ⇒ Object
readonly
Returns the value of attribute git_url.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#selected_components ⇒ Object
readonly
Returns the value of attribute selected_components.
-
#service_url ⇒ Object
readonly
Returns the value of attribute service_url.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #clone_template_project ⇒ Object
- #collect_components ⇒ Object
- #construct_plist ⇒ Object
- #construct_podfile ⇒ Object
- #generate ⇒ Object
-
#initialize(app_key, components, config_json, version = nil, bundle_id = nil, name = '', language = 'objc', git_url, service_url) ⇒ VemarsProject
constructor
A new instance of VemarsProject.
- #language_switch ⇒ Object
- #patch(podfile_dir) ⇒ Object
- #project_folder ⇒ Object
- #reinitialize_git_repo ⇒ Object
- #rename_project_files ⇒ Object
- #replace_internal_project_settings ⇒ Object
- #tailor_demos ⇒ Object
Constructor Details
#initialize(app_key, components, config_json, version = nil, bundle_id = nil, name = '', language = 'objc', git_url, service_url) ⇒ VemarsProject
Returns a new instance of VemarsProject.
24 25 26 27 28 29 30 31 32 |
# File 'lib/cocoapods-vemars/command/project.rb', line 24 def initialize(app_key, components, config_json, version=nil, bundle_id=nil, name='', language='objc', git_url, service_url) @language = language @basicInfo = BasicInfo.new(app_key, bundle_id, name, version) @git_url = git_url @config_json = config_json @selected_components = components | (language == 'swift' ? %w[OneKit SwiftOneKit] : ['OneKit']) @components_details = [] @service_url = service_url end |
Instance Attribute Details
#basicInfo ⇒ Object (readonly)
Returns the value of attribute basicInfo.
12 13 14 |
# File 'lib/cocoapods-vemars/command/project.rb', line 12 def basicInfo @basicInfo end |
#components_details ⇒ Object
Returns the value of attribute components_details.
17 18 19 |
# File 'lib/cocoapods-vemars/command/project.rb', line 17 def components_details @components_details end |
#git_url ⇒ Object (readonly)
Returns the value of attribute git_url.
14 15 16 |
# File 'lib/cocoapods-vemars/command/project.rb', line 14 def git_url @git_url end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
11 12 13 |
# File 'lib/cocoapods-vemars/command/project.rb', line 11 def language @language end |
#selected_components ⇒ Object (readonly)
Returns the value of attribute selected_components.
13 14 15 |
# File 'lib/cocoapods-vemars/command/project.rb', line 13 def selected_components @selected_components end |
#service_url ⇒ Object (readonly)
Returns the value of attribute service_url.
15 16 17 |
# File 'lib/cocoapods-vemars/command/project.rb', line 15 def service_url @service_url end |
#source ⇒ Object
Returns the value of attribute source.
18 19 20 |
# File 'lib/cocoapods-vemars/command/project.rb', line 18 def source @source end |
Instance Method Details
#clone_template_project ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/cocoapods-vemars/command/project.rb', line 63 def clone_template_project # puts 'cloning template' if File.directory?(basicInfo.name) || File.file?(basicInfo.name) system("rm -rf #{basicInfo.name}") end cmd = "git clone #{git_url} #{basicInfo.name}" system(cmd) end |
#collect_components ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cocoapods-vemars/command/project.rb', line 87 def collect_components components_api = Components_api.new(@basicInfo.version,@service_url) all_components = components_api.getComponents @source = components_api.source @selected_components.each do |com| existed_com = all_components.find { |acom| acom.name == com } @components_details.append existed_com unless existed_com.nil? end end |
#construct_plist ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/cocoapods-vemars/command/project.rb', line 107 def construct_plist json = JSON.load_file @config_json json["project_info"]["app_id"] = json["project_info"]["app_id"].to_s services = Hash.new if @selected_components.include? "BDHotfix" services["bdhotfix"] = { "dist_area" => "cn", "domain_name" => "", "debug" => true} end if @selected_components.include? "VEH5Kit" services["jsbridge_services"] = { "auth_domain" => "", "auth_enable" => false} services["gecko_services"] = { "platform_domain" => "", "pattern" => "", "gecko_channels" => [], "gecko_access_key" => ""} end json["services"] = services File.open(Dir.pwd + "/onekit-config.plist", 'w') { |file| file.puts json.to_plist } end |
#construct_podfile ⇒ Object
100 101 102 103 104 |
# File 'lib/cocoapods-vemars/command/project.rb', line 100 def construct_podfile template = PodfileTemplate.new(@basicInfo.version, @components_details, @source) File.open('Podfile', "w") { |file| file.puts template.to_dsl } end |
#generate ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cocoapods-vemars/command/project.rb', line 34 def generate puts "generate project..." clone_template_project collect_components Dir.chdir(basicInfo.name) do language_switch tailor_demos Dir.chdir("Project") do construct_podfile Dir.chdir("Template_InHouse") do construct_plist end rename_project_files # replace_internal_project_settings end reinitialize_git_repo end end |
#language_switch ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cocoapods-vemars/command/project.rb', line 73 def language_switch if language == 'swift' puts "creating swift project..." system("rm -fr objc") system("mv swift/* ./") system("rm -fr ./swift") else puts "creating objc project..." system("rm -fr ./swift") system("mv objc/* ./") system("rm -fr objc") end end |
#patch(podfile_dir) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/cocoapods-vemars/command/project.rb', line 53 def patch(podfile_dir) puts "patching project..." collect_components Dir.chdir(podfile_dir) do construct_plist patcher = Patcher.new(podfile_dir, @basicInfo.version, @components_details, @source, @git_url) patcher.execute end end |
#project_folder ⇒ Object
20 21 22 |
# File 'lib/cocoapods-vemars/command/project.rb', line 20 def project_folder File.join(Dir.pwd, "Project") end |
#reinitialize_git_repo ⇒ Object
146 147 148 149 |
# File 'lib/cocoapods-vemars/command/project.rb', line 146 def reinitialize_git_repo `rm -rf .git/` `git init` end |
#rename_project_files ⇒ Object
124 125 126 127 |
# File 'lib/cocoapods-vemars/command/project.rb', line 124 def rename_project_files renamer = ProjectRenamer.new("Template", basicInfo.name) renamer.execute end |
#replace_internal_project_settings ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/cocoapods-vemars/command/project.rb', line 134 def replace_internal_project_settings Dir.glob(Dir.pwd + "/**/**/**/**").each do |name| next if Dir.exists? name text = File.read(name) basicInfo.string_replacements.each { |find, replace| text = text.gsub(find, replace) } File.open(name, "w") { |file| file.puts text } end end |
#tailor_demos ⇒ Object
129 130 131 132 |
# File 'lib/cocoapods-vemars/command/project.rb', line 129 def tailor_demos tailor = DemoTailor.new(@components_details) tailor.execute end |