Class: CocoaDepot::MaterialCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/KCommercialPipeline/core/resource/i18n/auto_component.rb

Instance Method Summary collapse

Instance Method Details

#auto_create!(is_oc, path, custom_resource_bundle) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/KCommercialPipeline/core/resource/i18n/auto_component.rb', line 4

def auto_create!(is_oc, path, custom_resource_bundle)
  @is_auto_create = true
  @custom_resource_bundle = custom_resource_bundle || ''
  @main_language = CocoaDepot::Component::CodeLanguage::SWIFT unless is_oc
  @path = path
  clone_template_to_path
  exec_hook 'pre_create'
  render_templates
  exec_hook 'post_create'
  remove_skip_entries
  write_main_language

end

#clone_template_to_pathObject



18
19
20
21
22
23
24
# File 'lib/KCommercialPipeline/core/resource/i18n/auto_component.rb', line 18

def clone_template_to_path
  KCommercial::UI.info "Cloning `#{template_repo_url}` into `#{@name}`."
  clone_path = @name
  clone_path = "#{@path}/#{@name}" unless @path.empty?
  remove_dir_if_needed(clone_path)
  git! ['clone', template_repo_url, clone_path]
end

#collect_meta_infosObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/KCommercialPipeline/core/resource/i18n/auto_component.rb', line 31

def collect_meta_infos
  meta_infos = {
    'POD_NAME' => @name,
    'USER_NAME' => user_name,
    'USER_EMAIL' => user_email,
    'DATE' => Date.today.to_s,
    'CUSTOM_RESOURCE_BUNDLES' => @custom_resource_bundle
  }
  Dir.chdir(@sandbox_root) do
    if configure_script_root.join('meta').exist?
      custom_content = File.read(configure_script_root.join('meta'))
      custom_meta_infos = @is_auto_create ? {'deployment_target'=> '9.0'} : eval(custom_content)
      unless custom_meta_infos.is_a? Hash
        raise 'The configure return value is not an Hash. please check the template!'
      end
      meta_infos.merge! custom_meta_infos
    end
  end
  meta_infos.merge! @pass_meta_infos
  meta_infos
end

#remove_dir_if_needed(dir) ⇒ Object



26
27
28
29
# File 'lib/KCommercialPipeline/core/resource/i18n/auto_component.rb', line 26

def remove_dir_if_needed(dir)
  component_path = Pathname(dir)
  FileUtils.rm_rf(dir) if component_path.exist?
end

#sandbox_rootObject



53
54
55
56
57
# File 'lib/KCommercialPipeline/core/resource/i18n/auto_component.rb', line 53

def sandbox_root
  @sandbox_root ||= Pathname(Dir.pwd).join(@name)
  root_path = Pathname(@path) || Pathname(Dir.pwd)
  @sandbox_root = root_path.join(@name) if root_path.exist?
end