Sha256: 83623f6f30d40b9fa40c6a1db4d0cfc9f41d5ab2c8bd71c9e292e807d9dc98f7

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

module CocoaDepot
  class MaterialCreator
    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

    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

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

    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

    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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
KCommercialPipeline-0.2.5.1 lib/KCommercialPipeline/core/resource/i18n/auto_component.rb