build - Combine many ruby source files into a single file -


i'm working on project in ruby, , have many source files each declaring few classes , methods in module. i've been looking around , may missing something, can't seem find way merge of source files single file. want single file because end product here meant command line tool, , users won't want install 20 files in order run single command.

is there way take many ruby source files , process of require statements ahead of time create single file can run stand-alone program?

a few things may useful (or harmful?):

  • the file code not within function main file. therefore, main file have code run after file parsed.
  • i require needed files @ start of each file (after initial comment), require statements @ top of file, , dependancies listed @ start of each file
  • i call require on files required each file, regardless of weather or not may have been included already.

example (a few files project):

<filename> --> <include1>                <include2>                 ...  build.rb [the main file] --> buildsystem.rb                              utilities.rb buildsystem.rb           --> project.rb                              yamlfile.rb                              xmlfile.rb                              utilities.rb project.rb               --> yamlfile.rb                              xmlfile.rb                              utilities.rb 

what i'm looking allow me combine 5 of these files single build file can installed putting in right place. great, thanks!

the file code not within function main file. therefore, main file have code run after file parsed.

because of this, may able run following shell (assuming os x / *nix system):

touch main.rb cat utilities.rb >> main.rb cat xmlfile.rb >> main.rb cat yamlfile.rb >> main.rb cat project.rb >> main.rb cat buildsystem.rb >> main.rb cat build.rb >> main.rb #  must appended last 

you can put shell script "build" output file each time make change.

using method, have require statements scattered throughout output main.rb file, since idempotent won't have negative effects.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -