Class: TuyaCIDSL::TriggerCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/tuya/ci/DSL/trigger_create.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ TriggerCreator

Returns a new instance of TriggerCreator.



4
5
6
# File 'lib/tuya/ci/DSL/trigger_create.rb', line 4

def initialize(name)
	@file_name = name
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



3
4
5
# File 'lib/tuya/ci/DSL/trigger_create.rb', line 3

def file_name
  @file_name
end

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tuya/ci/DSL/trigger_create.rb', line 8

def create
	puts "Create trigger file named: #{@file_name}".green

	default_file = @file_name != 'CIFile'

	@file_path = './'
	@file_path = './CIMonitors/' if default_file

	`mkdir -p #{@file_path}`

	@file = "#{@file_path}#{@file_name}"
	`touch #{@file}`


	@content = trigger_content

	puts "Trigger: #{@file} saved".green
	fh = File.new(@file, "w")
	fh.puts @content
	fh.close

end