Class: RvmPow::Pow

Inherits:
Object
  • Object
show all
Defined in:
lib/rvmpow.rb

Instance Method Summary collapse

Instance Method Details

#addRvmInfoToGemfileObject

add rvm ruby and gemset to Gemfile



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rvmpow.rb', line 50

def addRvmInfoToGemfile
	action = -> do
		rvm = rvmInfo
		File.open(RvmPow::GEMFILE, 'a+') do |file|
			s = file.read
			if (s.match(/ruby\s'\d(\.\d)+'/) || s.match(/ruby-gemset=/))
				puts "\truby or gemset information already present in Gemfile"
			else
				file.puts "\n# rvmpow\nruby '#{rvm[:ruby]}'\n#ruby-gemset=#{rvm[:gemset]}"
			end
		end
	end
	fileAction action
end

#createPowenvFileObject

create .poenv in current dirrectory



10
11
12
13
14
15
# File 'lib/rvmpow.rb', line 10

def createPowenvFile
	action = -> do
		File.open(RvmPow::POW_ENV_FILE, "w+") { |file| file.puts RvmPow::POWENV  }
	end
	fileAction action
end

link current app to ~/.pow directory



18
19
20
21
# File 'lib/rvmpow.rb', line 18

def createPowLink
	action = -> { File.symlink(RvmPow::RAKE_APP_DIRECTORY, RvmPow::POW_LINK) }
	fileAction action
end

#deleteAlwaysRestartFileObject

removes always_restart.txt file from ./tmp/



99
100
101
102
# File 'lib/rvmpow.rb', line 99

def deleteAlwaysRestartFile
	action = -> { FileUtils.rm_f RvmPow::ALWAYS_RESTART_FILE }
	fileAction action
end

#deletePowenvFileObject

removes .powenv



87
88
89
90
# File 'lib/rvmpow.rb', line 87

def deletePowenvFile
	action = -> { FileUtils.rm_f RvmPow::POW_ENV_FILE }
	fileAction action
end

deletes the link is ~/.pow



105
106
107
108
# File 'lib/rvmpow.rb', line 105

def deletePowLink
	action = -> { FileUtils.rm_f RvmPow::POW_LINK }
	fileAction action
end

#deleteRestartFileObject

removes restart.txt file from ./tmp/



93
94
95
96
# File 'lib/rvmpow.rb', line 93

def deleteRestartFile
	action = -> { FileUtils.rm_f RvmPow::RESTART_FILE }
	fileAction action
end

#gitignorePowenvObject

add .powenv to .gitignore



42
43
44
45
46
47
# File 'lib/rvmpow.rb', line 42

def gitignorePowenv
	action = -> do
		File.open(RvmPow::GITIGNORE_FILE, 'a') { |file| file.puts RvmPow::GITIGNORE_ENTRY }
	end
	fileAction action
end

#restoreGemfileObject

removes rvmpow entries from Gemfile



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rvmpow.rb', line 72

def restoreGemfile
	action = -> do
		File.open(RvmPow::GEMFILE, 'r') do |file|
			s = file.read
			if !(s.match(/^#\srvmpow$/))
				puts "\tNo rvmpow entry found, continuing ..."
			else
				removeFromFile(RvmPow::GEMFILE, RvmPow::GEMFILE_MATCHER)
			end
		end
	end
	fileAction action
end

#restoreGitignoreObject

removes rvmpow entries from .gitignore



66
67
68
69
# File 'lib/rvmpow.rb', line 66

def restoreGitignore
	action = -> { removeFromFile(RvmPow::GITIGNORE_FILE, RvmPow::GITIGNORE_MATCHER) }
	fileAction action
end

#touchAlwaysRestartFileObject

create tmp/always_restart.txt file



33
34
35
36
37
38
39
# File 'lib/rvmpow.rb', line 33

def touchAlwaysRestartFile
	action = -> do
		createTmpDirIfNeeded
		FileUtils.touch(RvmPow::ALWAYS_RESTART_FILE)
	end
	fileAction action
end

#touchRestartFileObject

create tmp/restart.txt file



24
25
26
27
28
29
30
# File 'lib/rvmpow.rb', line 24

def touchRestartFile
	action = -> do
		createTmpDirIfNeeded
		FileUtils.touch(RvmPow::RESTART_FILE)
	end
	fileAction action
end