Top Level Namespace
Defined Under Namespace
Modules: Grit, Sinatra
Classes: ConfigInfo, Shagit
Instance Method Summary
collapse
#authorize!, #is_authorized?, #requires_login!
Methods included from Grit
#shagit_foldername, #shagit_name, #shagit_size
Instance Method Details
#check_if_started_from_gem(current_working_directory) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/helpers/helpers.rb', line 94
def check_if_started_from_gem(current_working_directory)
config_data = ConfigInfo.instance
if current_working_directory.include?('bin')
if (config_data.working_dir == '.')
gem_installation_dir = File.dirname(__FILE__).split('bin')[0]
puts "FATAL ERROR: The directory for saving repositories cannot be used!"
puts "Please set the path in your #{gem_installation_dir}config.yml accordingly."
exit
end
set :root, current_working_directory
end
if !FileTest.writable_real?(config_data.working_dir)
puts "FATAL ERROR: The directory for saving repositories (#{config_data.working_dir}) is not writable!"
puts "Please adjust your config.yml accordingly."
exit
end
end
|
#cycle(*values) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/helpers/helpers.rb', line 15
def cycle(*values)
@cycles ||= {}
@cycles[values] ||= -1 next_value = @cycles[values] = (@cycles[values] + 1) % values.size
values[next_value]
end
|
#full_path ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/helpers/helpers.rb', line 22
def full_path
config_data = ConfigInfo.instance
hostname = request.env['SERVER_NAME']
if (config_data.working_dir == '.')
full_path = "/#{@current_repo.shagit_foldername}"
else
full_path = "#{config_data.working_dir}/#{@current_repo.shagit_foldername}"
end
"ssh://#{reformat_string(hostname)}#{reformat_string(full_path)}"
end
|
#get_config_file_dir(dir) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/helpers/helpers.rb', line 40
def get_config_file_dir(dir)
if dir[/[\w]+$/] == "helpers"
dir = Pathname.new(File.expand_path(File.dirname(__FILE__)))
dir.parent.parent
else
dir
end
end
|
#get_fullpath(path) ⇒ Object
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/helpers/helpers.rb', line 83
def get_fullpath(path)
config_data = ConfigInfo.instance
if !path.include?('.git')
path = "#{path}.git"
end
fullpath = "#{config_data.working_dir}/#{path}"
end
|
#load_config(file) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/helpers/helpers.rb', line 50
def load_config(file)
current_dir = File.expand_path(File.dirname(__FILE__))
absolute_filepath = File.join(get_config_file_dir(current_dir), file)
if File.exist?(absolute_filepath)
config_data = ConfigInfo.instance
yaml = YAML.load_file(absolute_filepath)
config_data.username = yaml['username']
config_data.password = yaml['password']
working_dir = yaml['working_dir']
unless (working_dir == nil) || (working_dir.empty?)
working_dir = working_dir.strip
if FileTest.directory?(working_dir)
config_data.working_dir = working_dir
else
set_working_dir_to_current_dir
end
else
set_working_dir_to_current_dir
end
end
end
|
36
37
38
|
# File 'lib/helpers/helpers.rb', line 36
def reformat_string(source)
source.strip
end
|
#set_working_dir_to_current_dir ⇒ Object
78
79
80
81
|
# File 'lib/helpers/helpers.rb', line 78
def set_working_dir_to_current_dir
config_data = ConfigInfo.instance
config_data.working_dir = "."
end
|
#stylesheets(*sheets) ⇒ Object
9
10
11
12
13
|
# File 'lib/helpers/helpers.rb', line 9
def stylesheets(*sheets)
sheets.each { |sheet|
haml_tag(:link, :href => "/#{sheet}.css", :type => "text/css", :rel => "stylesheet")
}
end
|