Top Level Namespace
Defined Under Namespace
Modules: RubySocialClub
Instance Method Summary collapse
- #generate_file_lists(src) ⇒ Object
- #generate_task_basedfile_list(file_list, new_ext) ⇒ Object
-
#ruby_source(src) ⇒ Object
CLEAN.include(‘*.o’) CLOBBER.include(‘hello’).
Instance Method Details
#generate_file_lists(src) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/RubySocialClub/rake_tasks.rb', line 60 def generate_file_lists(src) src_files = FileList[File.join(src, '*.rb')] tex_files = src_files.ext('tex') irb_tex_files = src_files.ext('xmp.tex') output_files = src_files.ext('out') CLEAN.include(File.join(src, '*.tex')) CLEAN.include(File.join(src, '*.xmp')) CLEAN.include(File.join(src, '*.out')) generate_task_basedfile_list(src_files, 'xmp') do |t, src| tmp = RubySocialClub::Convertor.prepare_irb_session src File.open(t.name, 'w:ISO-8859-15') { |f| f << tmp } end generate_task_basedfile_list(src_files, 'out') do |t, src| sh "bundle exec ruby #{src} > #{t.name} 2>&1 ; true" end generate_task_basedfile_list(src_files, 'tex') do |t, src| puts "#{src} -> #{t.name}" c = RubySocialClub::Convertor.new(src) latex = c.to_latex File.open(t.name, 'w:ISO-8859-15') { |f| f << latex } end generate_task_basedfile_list(src_files.ext('xmp'), 'xmp.tex') do |t, src| puts "#{src} -> #{t.name}" c = RubySocialClub::Convertor.new(src, true) latex = c.to_latex File.open(t.name, 'w:ISO-8859-15') { |f| f << latex } end { :src => src_files, :tex => tex_files, :irb => irb_tex_files, :output => output_files } end |
#generate_task_basedfile_list(file_list, new_ext) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/RubySocialClub/rake_tasks.rb', line 97 def generate_task_basedfile_list(file_list, new_ext) file_list.each do |src_file| dst_file = src_file.clone src_ext_len = File.extname(src_file).length() -1 dst_file[-src_ext_len..-1] = new_ext #puts "Generating rule #{src_file} -> #{dst_file}" file dst_file => src_file do |t| yield [t, t.prerequisites[0]] end end end |
#ruby_source(src) ⇒ Object
CLEAN.include(‘*.o’) CLOBBER.include(‘hello’)
task :default => [“hello”]
SRC = FileList OBJ = SRC.ext(‘o’)
rule ‘.o’ => ‘.c’ do |t|
sh "cc -c -o #{t.name} #{t.source}"
end
file “hello” => OBJ do
sh "cc -o hello #{OBJ}"
end
File dependencies go here … file ‘main.o’ => [‘main.c’, ‘greet.h’] file ‘greet.o’ => [‘greet.c’]
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/RubySocialClub/rake_tasks.rb', line 28 def ruby_source(src) files = generate_file_lists(src) src_files = files[:src] tex_files = files[:tex] irb_tex_files = files[:irb] output_files = files[:output] desc "Generates all the source examples" task :sources => tex_files desc "Generates all the IRB source examples" task :irb_sources => irb_tex_files desc "Executes all the source examples" task :output => output_files desc "Generates snippets" task :snippets do snippet_src = RubySocialClub::Snippet.snippettize_dir(src) puts "snippets in #{snippet_src}" snippet_files = generate_file_lists(snippet_src) task :snp_all => snippet_files[:tex] task :snp_all => snippet_files[:irb] task :snp_all => snippet_files[:output] Rake::Task[:snp_all].invoke end CLEAN.include(File.join(src, 'snippets', '*.rb')) end |