Class: TYCiCore::TemplateConfigurator

Inherits:
Object
  • Object
show all
Defined in:
lib/tuya/ci/core/template/template_configurator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config, prefix, group) ⇒ TemplateConfigurator

Returns a new instance of TemplateConfigurator.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 12

def initialize(name, config, prefix, group)

	@pod_name = name
	@pod_spec = "#{name}.podspec"
	@podfile_path = "Example/Podfile"
	@prefix = prefix

	@group = group

	@xcodeproj_path = "#{@pod_name}/Example/PROJECT.xcodeproj"
	@platform = 'ios'
	@remove_demo_project = false

	@date = date
	@year = year
	@owner_email = user_email
	@owner_name = user_name

	@config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



10
11
12
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 10

def config
  @config
end

#dateObject

Returns the value of attribute date.



8
9
10
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 8

def date
  @date
end

#groupObject

Returns the value of attribute group.



9
10
11
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 9

def group
  @group
end

#owner_emailObject

Returns the value of attribute owner_email.



8
9
10
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 8

def owner_email
  @owner_email
end

#owner_nameObject

Returns the value of attribute owner_name.



8
9
10
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 8

def owner_name
  @owner_name
end

#platformObject

Returns the value of attribute platform.



6
7
8
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 6

def platform
  @platform
end

#pod_nameObject

Returns the value of attribute pod_name.



7
8
9
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 7

def pod_name
  @pod_name
end

#pod_specObject

Returns the value of attribute pod_spec.



7
8
9
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 7

def pod_spec
  @pod_spec
end

#podfile_pathObject

Returns the value of attribute podfile_path.



7
8
9
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 7

def podfile_path
  @podfile_path
end

#prefixObject

Returns the value of attribute prefix.



7
8
9
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 7

def prefix
  @prefix
end

#remove_demo_projectObject

Returns the value of attribute remove_demo_project.



6
7
8
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 6

def remove_demo_project
  @remove_demo_project
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 7

def type
  @type
end

#xcodeproj_pathObject

Returns the value of attribute xcodeproj_path.



6
7
8
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 6

def xcodeproj_path
  @xcodeproj_path
end

#yearObject

Returns the value of attribute year.



8
9
10
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 8

def year
  @year
end

Class Method Details

.load_config(folder) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 33

def self.load_config(folder)

	path = "#{folder}/#{TYCiCore::TEMPLATE_CONFIG}"

	raise 'Can not find config file, pls ask tuya' unless File.exist? path

	content = File.read path

	json = JSON(content)

	TemplateConfig.new json
end

Instance Method Details

#github_user_nameObject



54
55
56
57
58
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 54

def github_user_name
	github_user_name = `security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'`.strip
	is_valid = github_user_name.empty? or github_user_name.include? '@'
	return is_valid ? nil : github_user_name
end

#user_emailObject



46
47
48
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 46

def user_email
	(ENV['GIT_COMMITTER_EMAIL'] || `git config user.email`).strip
end

#user_nameObject



50
51
52
# File 'lib/tuya/ci/core/template/template_configurator.rb', line 50

def user_name
	(ENV['GIT_COMMITTER_NAME'] || github_user_name || `git config user.name` || `<GITHUB_USERNAME>` ).strip
end