Class: Roebe::PutAllGemsIntoThisProject
- Inherits:
-
Base
show all
- Includes:
- FileUtils::Verbose
- Defined in:
- lib/roebe/classes/put_all_gems_into_this_project.rb
Overview
Roebe::PutAllGemsIntoThisProject
Constant Summary
collapse
- RUBY_SRC =
ENV['RSRC'].to_s+'/'
- BASE_DIR =
HOME_DIRECTORY_OF_USER_X+'src/gems/'
- TEMP_DIR =
'/Depot/Temp/GemifiedProjects/'
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
46
47
48
49
50
51
52
53
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 46
def initialize(
i = nil,
run_already = true
)
reset
set_name_of_the_project(i)
run if run_already
end
|
Instance Method Details
#cpr(from, to = return_pwd) ⇒ Object
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 252
def cpr(
from, to = return_pwd
)
opne 'Next copying from `'+sdir(from)+'`.'
if File.exist? from
FileUtils.cp_r(from, to)
else from = from.chop if from.end_with? '.'
possible_matches = Dir[HOME_DIRECTORY_OF_USER_X+'src/gems/'+File.basename(from)+'*']
if possible_matches.empty?
opnewarn 'The file at `'+from+'` does not seem to exist.'
else
cpr(possible_matches.first, to)
end
end
end
|
#create_gem(i = nil) ⇒ Object
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 297
def create_gem(i = nil)
if i
if i.is_a? Hash
this_dir = i[:base_directory_to_use]
cd( this_dir )
result = `gem build *.gemspec`
name_of_the_gem = result.split[-1]
e 'Finished creating a .gem file into '+sdir(this_dir)+'.'
@location_of_the_gem = temp_dir?+name_of_the_gem
mv(this_dir+name_of_the_gem, @location_of_the_gem)
e 'The file is now at '+sfile(temp_dir?+name_of_the_gem)
end
end
end
|
#deal_with_external_project(i) ⇒ Object
#
deal_with_external_project
This method is a stub for now.
#
239
240
241
242
243
244
245
246
247
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 239
def deal_with_external_project(i)
_ = BASE_DIR+i
if File.exist? _
else
opne 'Can not find anything at '+sfile(_)
end
pp 'BYE - DEBUGGING. External projects are not handled yet.'
exit
end
|
#deal_with_internal_project(i) ⇒ Object
#
deal_with_internal_project
#
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 120
def deal_with_internal_project(i)
opne 'We have determined that '+sfancy(i)+' is internal.'
opne 'The next step is to grab a list of all dependencies.'+N+N
_ = GetDependencies.of_this_gem(i)
@array_dependencies = _.array_dependencies
opne 'These are the dependencies that we will work on:'
pp @array_dependencies
if @also_get_subdependencies
end
opne 'We will next repackage these dependencies'
opne 'into a new directory.'
mkdir(temp_dir?)
base_dir = (temp_dir?+project_name?+'/').dup
mkdir(base_dir)
cd base_dir
cpr(RUBY_SRC+project_name?+'/.')
name_of_gem_dir = 'lib/'+project_name?+'/bundled_gem_dependencies'
opne 'The name of the gem dir will be '+sfancy(name_of_gem_dir)+'.'
@file_that_will_hold_all_internal_requires = return_pwd+
name_of_gem_dir+'.rb'
opne 'The name of the gem dir will be '+
sfancy(@file_that_will_hold_all_internal_requires)+'.'
touch(@file_that_will_hold_all_internal_requires)
mkdir(name_of_gem_dir)
base_dir << '/' unless base_dir.end_with? '/'
base_dir << name_of_gem_dir
@array_dependencies.each {|entry|
cd base_dir
unless Dir.exist? entry
opne 'Creating directory '+sdir(base_dir+entry)+' next.'
mkdir(entry)
end
cd entry
cpr(RUBY_SRC+entry+'/.')
what = 'require "'+project_name?+'/bundled_gem_dependencies/'+
File.basename(entry)+'/lib/'+File.basename(entry)+'.rb"'+N
append_what_into(
what,
@file_that_will_hold_all_internal_requires)
}
create_gem(
base_directory_to_use: project_base_directory?
)
opne 'Done!'
end
|
315
316
317
318
319
320
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 315
def
cd TEMP_DIR
_ = 'gem unpack '+@location_of_the_gem.to_s
e "We are in the directory: #{return_pwd}"
esystem _
end
|
#find_out_whether_the_project_is_internal_or_external ⇒ Object
#
find_out_whether_the_project_is_internal_or_external
#
217
218
219
220
221
222
223
224
225
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 217
def find_out_whether_the_project_is_internal_or_external
if is_my_project?(project_name?)
deal_with_internal_project(project_name?)
else
deal_with_external_project(project_name?)
end
end
|
#is_my_project?(i = project_name?)
) ⇒ Boolean
#
is_my_project?
Find out whether a given dependency is my own project, or the project of someone else.
Depending on this result, we will call further routines to determine what to do next.
#
207
208
209
210
211
212
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 207
def is_my_project?(i = project_name?)
if i.include? '.rb'
i = File.basename(i, '.rb')
end
return Roebe::ARRAY_INSTALL_THESE_GEM_PROJECTS.include? i
end
|
#project_base_directory? ⇒ Boolean
#
project_base_directory?
#
186
187
188
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 186
def project_base_directory?
temp_dir?+project_name?+'/'
end
|
#project_name? ⇒ Boolean
230
231
232
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 230
def project_name?
@name_of_the_project
end
|
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 58
def reset
super()
infer_the_namespace
@also_get_subdependencies = true
@array_dependencies = [] @location_of_the_gem = nil
end
|
272
273
274
275
276
277
278
279
280
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 272
def run startup_tasks
opne 'We will next try to find out whether the project'
opne simp(project_name?)+' is internal or external.'
opne 'Is it my project?'
find_out_whether_the_project_is_internal_or_external
run_cleanup_actions
end
|
#run_cleanup_actions ⇒ Object
#
run_cleanup_actions
This will remove the directory, after creating the .gem file.
#
287
288
289
290
291
292
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 287
def run_cleanup_actions
if Dir.exist? project_base_directory?
opne 'Next removing '+sdir(project_base_directory?)
remove(project_base_directory?)
end
end
|
#set_name_of_the_project(i = '') ⇒ Object
#
set_name_of_the_project
#
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 72
def set_name_of_the_project(i = '')
i = i.first if i.is_a? Array
case i
when /^-?-?help$/i show_help
exit
end
if i.is_a? Symbol
case i
when :diamond_shell
i = HOME_DIRECTORY_OF_USER_X+'DATA/PROGRAMMING_LANGUAGES/RUBY/SRC/diamond_shell'
end
end
i = i.to_s.dup if i
if i.include? '/'
i = File.basename(i)
end
@name_of_the_project = i
@base_dir_for_the_new_project = '/Depot/Temp/'+File.basename(project_name?)
end
|
#show_help ⇒ Object
193
194
195
196
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 193
def show_help
e 'To use this project, do something such as:'
e ' putgems $RSRC/diamond_shell/'
end
|
#startup_tasks ⇒ Object
#
startup_tasks
Bundle some actions here.
#
101
102
103
104
105
106
107
108
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 101
def startup_tasks
unless Dir.exist? temp_dir?
mkdir temp_dir?
end
unless File.exist? @base_dir_for_the_new_project
mkdir(@base_dir_for_the_new_project)
end
end
|
#temp_dir? ⇒ Boolean
113
114
115
|
# File 'lib/roebe/classes/put_all_gems_into_this_project.rb', line 113
def temp_dir?
TEMP_DIR
end
|