[
  {
    "path": ".gems",
    "content": "rubyzip\r\nPOpen4\r\n"
  },
  {
    "path": ".gitignore",
    "content": "*.exe\r\n*.rbc\r\n*.swp\r\n*~\r\n.idea/\r\narchives/\r\npkg/\r\nstage/\r\n"
  },
  {
    "path": "CHANGELOG.txt",
    "content": "3.2.0 - Ruby 2.2.4 \r\n\r\n3.1.1 - Ruby 2.1.8, Rails 4.2.5, activerecord-sqlserver-adapter 4.2.6,\r\n        coffee-rails 4.1.1, jquery-rails 4.1.0, sass-rails 5.0.4, Git 2.7.0,\r\n\r\n3.1.0 - Ruby 2.1.5\r\n\r\n3.0.0 - Ruby 2.0.0-p598, Rails 4.1.8, activerecord-sqlserver-adapter 4.1.0,\r\n        coffee-rails 4.1.0, jquery-rails 3.1.2, sass-rails 4.0.5, sqlite 3.8.7.2,\r\n        mysql-5.6.21.\r\n\r\n2.2.4 - Rails 3.2.19, git 1.9.4, sqlite 3.8.6, mysql-5.6.20\r\n\r\n2.2.3 - Ruby 1.9.3-p545, Rails 3.2.18, git 1.9.2, postgresql-9.3.4-3, sqlite 3.8.4.3, mysql-5.6.17\r\n\r\n2.2.2 - Ruby 1.9.3-p484, Rails 3.2.16, git 1.8.4, postgresql-9.3.2-1, sqlite 3.8.2, mysql-5.6.15\r\n\r\n2.2.0 - Updated main components to the latest version (Ruby 1.9.3-p362,\r\n        Rails 3.2.11, git 1.8.0).\r\n        Users can now exclude Git from the setup process (maybe it is already installed).\r\n\r\n2.0.0 - Ruby 1.9.2-p290, Rails 3.1, Active Record SQLServer Adapter, TinyTDS,\r\n        git 1.7.6, bundler 1.0.18.\r\n\r\n1.1.0 - Automatic help for user git configuration on console start.\r\n        Automatic ssh key configuration on console start.\r\n        Configuration summary output on console start.\r\n        git-bash shortcut is now added to the RailsInstaller start menu group.\r\n\r\n1.0.5 - Ruby Updating to 1.8.7-p334 for released Security Updates.\r\n\r\n1.0.4 - Moved Sites location back to %HOMEDRIVE%\\Sites\r\n\r\n1.0.3 - Installer now throws an error on rake package if Inno Setup 5 not found\r\n        Added Ruby gem bin directory to the path in setup_environment.bat\r\n        Added creation of Sites directory in the users home instead of root\r\n\r\n1.0.2 - Include both sqlite3 and older sqlite3-ruby (which rails 3.0.3 likes best to date)\r\n\r\n1.0.1 - Added rb-readline and a few other bundled gems.\r\n\r\n1.0.0 - Initial Release, same features as 0.0.3\r\n\r\n0.0.3 - Many bugfixes and minor tweaks.\r\n        DevKit Integration Fix.\r\n        RailsInstaller Wizard Images.\r\n\r\n0.0.2 - Wizard Screen and functionality tweaks.\r\n        Added sample Rails3 application in a directory for application projects.\r\n        Tweaked git config to always convert CRLF to LF.\r\n\r\n0.0.1 - Initial build and package tasks functional, includes Ruby 1.8.7, Git\r\n        DevKit and Sqlite3.\r\n\r\n0.0.0 - Initial repository created with configuration and directory outline.\r\n        No functionality at this point.\r\n"
  },
  {
    "path": "CONTRIBUTORS.txt",
    "content": "# CONTRIBUTORS\r\n#\r\n# This file tries to detail all the developers, users and 3rd parties\r\n# that contributed to materialize this project\r\n#\r\n# Please feel free to add yourself or details, but keep the file in\r\n# as YAML formatted document. Thank you.\r\n\r\n---\r\n- Wayne E. Seguin\r\n  :email: wayneeseguin+railsinstaller@gmail.com\r\n  :website: http://rvm.beginrescueend.com/\r\n\r\n- Luis Lavena\r\n  :email: luislavena+railsinstaller@gmail.com\r\n  :website: http://blog.mmediasys.com/\r\n\r\n- Ruby Installer Team and Contributors\r\n  :website: http://rubyinstaller.org/about/contributors\r\n\r\n- Gerlando Piro\r\n  :email: gpiro@engineyard.com\r\n  :contribution: Graphics work for the install wizard.\r\n"
  },
  {
    "path": "LICENCE.txt",
    "content": "Copyright (c) 2010-2017 RailsInstaller Team.\r\nAll rights reserved. See CONTRIBUTORS.txt for complete list.\r\n\r\nPermission is hereby granted, free of charge, to any person\r\nobtaining a copy of this software and associated documentation\r\nfiles (the \"Software\"), to deal in the Software without\r\nrestriction, including without limitation the rights to use,\r\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the\r\nSoftware is furnished to do so, subject to the following\r\nconditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\nOTHER DEALINGS IN THE SOFTWARE.\r\n"
  },
  {
    "path": "README.md",
    "content": "# RailsInstaller\r\n\r\nRails development environment installer for Windows. This is attempt to get the installer to work agian. 4.0.0-alpha Pre-release now available\r\ncheck out Install Ruby On Rails on Windows or [Releases](https://github.com/railsinstaller/railsinstaller-windows/releases) to downlaod.\r\n\r\n## Overview\r\n\r\nThe goal of this project is to generate an installer that when run installs all\r\nof the most common components for a Rails development environment with no\r\nrequired prerequisites on a Windows system.\r\n\r\n## Install Ruby On Rails on Windows\r\nCurrently RailsInstaller does not include everything to get rails to work on Windows. Slowly each part will get added back in, but for \r\nnow you will need to follow instructions below to get rails installed.\r\n\r\n1. Download and install \r\n[Git](https://github.com/git-for-windows/git/releases/download/v2.38.0.windows.1/Git-2.38.0-64-bit.exe).\r\n\r\n2. Download and install \r\n[Nodejs](https://nodejs.org/dist/v16.17.1/node-v16.17.1-x64.msi).\r\n\r\n3. Download and install\r\n[Yarn](https://classic.yarnpkg.com/latest.msi).\r\n\r\n4. Download and install \r\n[RailsInstaller](https://github.com/railsinstaller/railsinstaller-windows/releases/download/v4.0.0-alpha/railsinstaller-4.0.0.exe).\r\n\r\n# Need Help, Bugs or Questions\r\nPlease come over to the Discord server [Click Here for invite](https://discord.gg/QeRYNGXHuu) \r\n\r\n# RailsInstaller Components\r\n\r\nThe next few sections detail the core components that make up RailsInstaller.\r\n\r\n### Ruby 3.1.2 on Windows\r\n\r\nRubyInstaller is a self contained package installer which installs Ruby and RubyGems on a windows system, head over to [http://rubyinstaller.org/](http://rubyinstaller.org/) for more information.\r\n\r\n### Development Kit (DevKit)\r\n\r\nA MSYS/MinGW based toolkit that enables RailsInstaller to build native C/C++ packages, both for Ruby and gems. DevKit is built and maintained by the wonderful folks over at the RubyInstaller project.\r\n\r\n### Packaging/Installer\r\n\r\nWe are using [Inno Setup](http://www.jrsoftware.org/isinfo.php \"Inno Setup\"), a free installer for Windows programs.\r\n\r\n## How to Contribute\r\n\r\nThe information below is out of date and will be updated soon.\r\n\r\nRailsInstaller project code repository is located on GitHub and is bootstrapped,\r\nbuilt and packaged via rake tasks.\r\n\r\n1. Download and install the latest\r\n   [RailsInstaller](http://railsinstaller.org/).\r\n\r\n1. Download and install latest\r\n   [Inno Setup Quick Start Pack](http://www.jrsoftware.org/isdl.php#qsp),\r\n   add iscc.exe in your PATH\r\n    ```\r\n    C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe \r\n    ```\r\n1. [Fork](https://help.github.com/articles/fork-a-repo)\r\n   the [RailsInstaller project on github](https://github.com/railsinstaller/railsinstaller-windows.git)\r\n   into your own GitHub account.\r\n\r\n1. Open the the command prompt from the start menu and change directory to where you like to keep your projects.\r\n\r\n1. Clone your fork of the project.\r\n\r\n    ```bash\r\n    git clone https://github.com/{{your GitHub user name}}/railsinstaller-windows.git\r\n    cd railsinstaller-windows\r\n    ```\r\n\r\n1. Update from origin master branch and checkout a new topic branch for your feature/bugfix.\r\n\r\n    ```bash\r\n    git checkout master\r\n    git pull origin master\r\n    git checkout -b mybranchname\r\n    ```\r\n\r\n1. Bootstrap the project. From the project root run:\r\n\r\n    ```bash\r\n    rake bootstrap\r\n    ```\r\n\r\n1. Implement your new feature and/or fix your bug in your newly forked Railsinstaller project code.\r\n\r\n  * The configuration file for specifying required packages can be found at config/railsinstaller.yml.\r\n\r\n  * Building of the installer into the stage path for packaging is implemented by Ruby code in the lib/ directory, starting with the file lib/railsinstaller/actions.rb.\r\n\r\n  * Methods called by the actions.rb file are implemented by lib/railsinstaller/methods.rb.\r\n\r\n1. Next build all components onto the stage (into the stage/ directory)\r\n\r\n    ```bash\r\n    rake build\r\n    ```\r\n\r\n1. Use Inno Setup to package the installer into an executable (.exe) for testing/distribution.\r\n\r\n    Add iscc.exe in your PATH\r\n    ```\r\n    C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe \r\n    rake package\r\n    ```\r\n\r\n  * This creates the executable (.exe) package file in the pkg/ directory from the files staged during the build process in the stage/ directory.\r\n\r\n  * NOTE - You can run the package task with --trace for debugging output if the package fails to build or if you simply want to see what is being done as it is done).\r\n\r\n1. Once you have verified your new feature/bug-fix, push your branch up to GitHub.\r\n\r\n    ```bash\r\n    git commit -a -m \"Implemented featureX/bugfixX which <description>...\"\r\n    git push origin mybranchname\r\n    ```\r\n\r\n1. Now issue a [pull request](https://help.github.com/articles/using-pull-requests) on GitHub.\r\n"
  },
  {
    "path": "TEAM.txt",
    "content": "Luis Lavena (luislavena+railsinstaller@gmail.com)\r\nWayne E. Seguin (wayneeseguin+railsinstaller@gmail.com)\r\n"
  },
  {
    "path": "VERSION.txt",
    "content": "4.0.1\n"
  },
  {
    "path": "config/railsinstaller.yml",
    "content": "---\n:gems:\n  :name: Gems\n  :title: Ruby Gems\n  :category: gems\n  :list:\n    -\n      :name: rails\n      :version: \"7.1.2\"\n\n:ruby322:\n  :category: component\n  :title: Ruby 3.2.2\n  :name: Ruby322\n  :regex: '^.*$'\n  :url: \"https://github.com/robertmabbs/railsinstaller-rubydevkit/releases/download/rubyinstaller-devkit-3.2.2-1-x64/rubyinstaller-devkit-3.2.2-1-x64.7z\"\n  :rename: Ruby3.2.2\n  \n:bsdtar:\n  :name: BSDTar\n  :title: Basic BSDTar\n  :category: utility\n  :target: bin\n  :binary: \"basic-bsdtar.exe\"\n  :regex: '^basic-bsdtar.exe$'\n  :url: \"http://downloads.sourceforge.net/mingw/basic-bsdtar-2.8.3-1-mingw32-bin.zip\"\n\n:sevenzip:\n  :name: SevenZip\n  :title: 7Zip\n  :category: utility\n  :target: bin\n  :binary: \"7za.exe\"\n  :regex: '^7za\\.exe$'\n  :url: \"http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.20/7za920.zip\"\n  \n:git:\n  :category: component\n  :title: Git 2.38.1\n  :name: Git\n  :url: \"https://github.com/robertmabbs/railsinstaller-git/releases/download/2.38.1/PortableGit.zip\"\n  :target: \"Git\"\n  :regex: '^.*$'\n"
  },
  {
    "path": "docs/notes.txt",
    "content": "MSYS is \"Minimal System\", is some sort of Cygwin set of libraries (but\r\nis not cygwin) that only exist to provide support for native\r\ncompilation of libraries and tools under MinGW (GCC)\r\n\r\nFor example, it provides perl and other components that make it easy\r\nto compile things like OpenSSL. Also provides a native bash that\r\ntranslates Windows paths (C:\\Foo\\Bar) into /c/Foo/Bar, making them\r\ncompatible with cygwin-like make, used to compile stuff.\r\n\r\nMSYS is the complement of MinGW. Both together form DevKit.\r\n\r\nInside DevKit you will notice a bin folder, and inside will find\r\nbash, sh and other scripts, then at the same level of 'bin' will find\r\na 'mingw' folder that contains GCC and the Windows headers, used to\r\ncompile.\r\n\r\nBoth bin and mingw/bin folders needs to be added to the PATH so things\r\nlike this can work:\r\n\r\nsh -c \"autoconf\"\r\nmkdir build\r\ncd build\r\nsh ../configure ...\r\nmake\r\n\r\nWe use DevKit build recipes and provide them to the\r\nusers as SFX (work on installer has been put on hold for now)\r\n\r\nYou can read more about the steps to install it here:\r\n\r\nhttps://github.com/oneclick/rubyinstaller/wiki/Development-Kit\r\n\r\n================================================================================\r\n\r\n\r\nOn Wed, Dec 29, 2010 at 6:14 PM, Wayne E. Seguin <wayneeseguin@gmail.com> wrote:\r\n> Would you be able to walk me through an overview of how RubyInstaller works\r\n> from the developers perspective?\r\n>\r\n> Meaning things like:\r\n> * The workflow (Install Ruby and DevKit, then run 'rake ...' )\r\n\r\nTo hack on RubyInstaller you only need a previous version of Ruby\r\ninstalled, nothing else.\r\n\r\nDevKit is downloaded by \"rake devkit\" and is part of the dependency\r\nchange of building \"rake ruby18\" or \"rake rub19\"\r\n\r\n> * The code flow (Starts with the rake call, runs ....)\r\n\r\ngit clone ...\r\ncd rubyinstaller\r\nrake ruby18 #=> results in all the libraries compiled and Ruby 1.8.7\r\nbuild in sandbox/ruby18_mingw\r\nrake ruby19 #=> only builds libraries that 1.9.2 depends on and put\r\nthe compiled output at sandbox/ruby19_mingw\r\n\r\nThen, you need:\r\n\r\ngem install rdoc -v \"~> 2.5.11\"\r\ngem install rdoc_chm\r\n\r\nAlso, install (in your computer) InnoSetup QuickStart Pack, unicode:\r\n\r\nhttp://www.jrsoftware.org/isdl.php#qsp\r\n\r\nWhen installed, ensure ISPP (pre-processor) is checked for installation.\r\n\r\nOnce you're done with that, you can:\r\n\r\nrake ruby18:package\r\n\r\nWhich will generate the rdoc (CHM) and will package the InnoSetup script.\r\n\r\nsame for ruby19:package\r\n\r\nThese tasks don't get added until you don't compile Ruby ;-)\r\n\r\n> I have some code ready to start playing with however I am unsure how you\r\n> would do the packaging and running, etc on windows.\r\n\r\nI think I covered all the steps above, for sure rake tasks can be\r\ncleaned to make it more clear the dependencies :-)\r\n\r\nHope that helps,\r\n"
  },
  {
    "path": "lib/extensions/stdlib.rb",
    "content": "class String\r\n  # Converts a lower case and underscored string to UpperCamelCase.\r\n  #\r\n  # Examples:\r\n  #   \"ruby_build_path\".camelcase   # => \"RubyBuildPath\"\r\n  def camelcase\r\n    self.gsub(/(?:\\A|_)(.)/) { $1.upcase }\r\n  end\r\nend\r\n"
  },
  {
    "path": "lib/railsinstaller/actions.rb",
    "content": "module RailsInstaller\n\n  def self.build!\n  \n  components = [\n    BSDTar, SevenZip, Git, Ruby322\n    ]\n\n    components.each do |package|\n      section  package.title\n      download package.url\n      extract  package\n    end\n    \n    # this needs to be done as temp fix to bypass the tzdata error when installing rails\n    #stage_gem_update\n    \n    # stage_sqlite\n\n    # link_devkit_with_ruby\n\n   # stage_git\n\n    # stage_postgresql\n\n    # stage_todo_application\n\n    stage_gems\n\n    # fix_batch_files\n\n    # stage_setup_scripts\n\n    # stage_msvc_runtime\n  end\n\n  #\n  # package()\n  #\n  # Packages a binary installer release version together as a\n  # self contained installer using Inno Setup scripting.\n  #\n  def self.package!\n\n    unless %x{iscc}.scan(\"Inno Setup 6\")\n      printf \"ERROR: Inno Setup is required in order to package RailsInstaller.\\n\"\n      printf \"  http://www.jrsoftware.org/isdl.php#qsp\\n\"\n      printf \"Please see README.md for full RailsInstaller instructions.\\n\"\n      exit 1\n    end\n\n    railsinstaller_version = File.read(File.join(RailsInstaller::Root, \"VERSION.txt\")).chomp\n\n    printf \"\\nPackaging... this *will* take a while...\\n\"\n\n    # iscc \"\\\"#{File.join(RailsInstaller::Root, \"resources\", \"railsinstaller\", \"railsinstaller.iss\")}\\\"\",\n    #       \"/dInstallerVersion=#{railsinstaller_version}\",\n    #       \"/dStagePath=\\\"#{RailsInstaller::Stage}\\\"\",\n    #       \"/dRubyPath=\\\"#{RailsInstaller::Ruby233.rename}\\\"\",\n    #       \"/dResourcesPath=\\\"#{File.join(RailsInstaller::Root, \"resources\")}\\\"\",\n    #       \"/o\\\"#{RailsInstaller::PackageDir}\\\"\",\n    #       \"/frailsinstaller-#{railsinstaller_version}\"\n    \n      iscc \" \\\"#{File.join(RailsInstaller::Root, \"resources\", \"railsinstaller\", \"railsinstaller.iss\")}\\\"\",\n        \"/DInstallerVersion=\\\"#{railsinstaller_version}\\\"\",\n        \"/DStagePath=\\\"#{RailsInstaller::Stage}\\\"\",\n        \"/DRubyPath=\\\"#{RailsInstaller::Ruby322.rename}\\\"\",\n        \"/DResourcesPath=\\\"#{File.join(RailsInstaller::Root, \"resources\")}\\\"\",\n        \"/O\\\"#{RailsInstaller::PackageDir}\\\"\",\n        \"/Frailsinstaller-#{railsinstaller_version}\"\n\n  end\n\nend\n"
  },
  {
    "path": "lib/railsinstaller/components.rb",
    "content": "module RailsInstaller\r\n  #\r\n  # Load initial objects (OpenStruct) from railsinstaller.yml\r\n  #\r\n  @@config = YAML.load(\r\n    ERB.new(\r\n      File.read(\r\n        File.join(Root, \"config\", \"railsinstaller.yml\")\r\n      )\r\n    ).result(binding)\r\n  )\r\n\r\n  @@config.each_pair do |key, value|\r\n    const_set(value[:name], OpenStruct.new(value))\r\n  end\r\nend\r\n"
  },
  {
    "path": "lib/railsinstaller/downloads.rb",
    "content": "module RailsInstaller\r\n\r\n  require \"net/https\"\r\n  require \"tempfile\"\r\n\r\n  # Original download() code taken from Rubinius and then butchered ;)\r\n  # https://github.com/evanphx/rubinius/blob/master/configure#L307-350\r\n  def self.download(url, filename = nil, count = 3)\r\n   filename ||= File.basename(url)\r\n\r\n   return if File.exists?(File.join(RailsInstaller::Archives, filename))\r\n\r\n   begin\r\n\r\n      if ENV[\"http_proxy\"]\r\n        protocol, userinfo, host, port = URI::split(ENV[\"http_proxy\"])\r\n        proxy_user, proxy_pass = userinfo.split(/:/) if userinfo\r\n        http = Net::HTTP::Proxy(host, port, proxy_user, proxy_pass)\r\n      else\r\n        http = Net::HTTP\r\n      end\r\n\r\n      uri = URI.parse(url)\r\n\r\n      print \"Downloading from #{url} to #{RailsInstaller::Archives}/#{filename}\\n\" if $Flags[:verbose]\r\n      http.get_response(uri) do |response|\r\n\r\n        case response\r\n          when Net::HTTPNotFound\r\n\r\n            raise NET::HTTPNotFound, \"Looking for #{url} and received a 404!\"\r\n            return false\r\n\r\n          when Net::HTTPClientError\r\n            print \"ERROR: Client Error : #{response.inspect}\\n\"\r\n            return false\r\n\r\n          when Net::HTTPRedirection\r\n            raise \"Too many redirections for the original url, halting.\" if count <= 0\r\n            print \"Redirected to #{response[\"Location\"]}\\n\" if $Flags[:verbose]\r\n            url = response[\"location\"]\r\n            return download(url, filename, count - 1)\r\n\r\n          when Net::HTTPOK\r\n            temp_file = Tempfile.new(\"download-#{filename}\")\r\n            temp_file.binmode\r\n\r\n            size  = 0\r\n            total = response.header[\"Content-Length\"].to_i\r\n\r\n            # Ensure that the destination directory exists.\r\n            unless File.directory?(RailsInstaller::Archives)\r\n              FileUtils.mkdir_p(RailsInstaller::Archives)\r\n            end\r\n\r\n            if File.exist?(File.join(RailsInstaller::Archives, filename))\r\n              FileUtils.rm_f(File.join(RailsInstaller::Archives, filename))\r\n            end\r\n\r\n            Dir.chdir(RailsInstaller::Archives) do\r\n              # See https://github.com/oneclick/rubyinstaller/blob/master/rake/contrib/uri_ext.rb#L234-276\r\n              # for another alternative to this.\r\n              response.read_body do |chunk|\r\n                temp_file << chunk\r\n                size += chunk.size\r\n                print \"\\r  => %d%% (%d of %d) \" % [(size * 100) / total, size, total]\r\n              end\r\n\r\n              temp_file.close\r\n              FileUtils.mv(\r\n                temp_file.path,\r\n                File.join(RailsInstaller::Archives, filename),\r\n                :force => true\r\n              )\r\n\r\n              print \"\\n\\n\"\r\n            end\r\n          else\r\n            raise RuntimeError, \"Failed to download #{url}: #{response.message}\"\r\n        end\r\n      end\r\n\r\n   rescue Exception => exception\r\n      if File.exists?(File.join(RailsInstaller::Archives, filename))\r\n        File.unlink(File.join(RailsInstaller::Archives, filename))\r\n      end\r\n      printf \"ERROR: #{exception.message}\\n\"\r\n      return false\r\n    end\r\n    return true\r\n  end\r\nend\r\n"
  },
  {
    "path": "lib/railsinstaller/methods.rb",
    "content": "module RailsInstaller\n\n  #\n  # unzip:\n  # Requires: rubyzip (gem install rubyzip) # require \"zip/zip\"\n  #\n  def self.unzip(package)\n    filename  = File.basename(package.url)\n    base_path = File.dirname(filename)\n\n    if package.target.nil?\n      target_path = base_path\n    else\n      target_path = File.join(base_path, package.target)\n    end\n    regex = Regexp.new(package.regex) unless package.regex.nil?\n    files = []\n\n    printf \" => Extracting #{filename}\\n\"\n\n    Dir.chdir(RailsInstaller::Archives) do\n      archive = File.join(RailsInstaller::Archives, filename)\n\n      Zip::File.open(archive) do |zipfile|\n        printf \"zipfile: #{zipfile.inspect}\\n\" if $Flags[:verbose]\n\n        if regex\n          entries = zipfile.entries.select do |entry|\n            entry.name.match(regex)\n          end\n        else\n          entries = zipfile.entries\n        end\n\n        FileUtils.mkdir_p(File.join(RailsInstaller::Stage, \"bin\"))\n\n        entries.each do |entry|\n          printf \"DEBUG: Extracting #{entry.name}\\n\" if $Flags[:verbose]\n          files << entry.name\n          if File.exists?(entry.name)\n            FileUtils.rm_f(entry.name)\n          end\n          zipfile.extract(entry, entry.name)\n\n          if File.exist?(File.join(RailsInstaller::Archives, entry.name))\n            FileUtils.mv(\n              File.join(RailsInstaller::Archives, entry.name),\n              File.join(RailsInstaller::Stage, \"bin\", entry.name),\n              :force => true\n            )\n          end\n        end\n      end\n    end\n    files\n  end\n\n  #\n  # extract\n  #\n  # Used to extract a non-zip file using BSDTar\n  #\n  def self.extract(package)\n    Dir.chdir(RailsInstaller::Archives) do\n      filename = File.basename(package.url)\n\n      unless File.exists?(filename)\n        raise \"ERROR: #{filename} does not exist, did the download step fail?\"\n      end\n\n      if package.target.nil?\n        target_path = RailsInstaller::Stage\n      else\n        target_path = File.join(RailsInstaller::Stage, package.target)\n      end\n      bsdtar   = File.join(RailsInstaller::Stage, \"bin\", RailsInstaller::BSDTar.binary)\n      sevenzip = File.join(RailsInstaller::Stage, \"bin\", RailsInstaller::SevenZip.binary)\n\n      if package.category == \"utility\" &&\n        File.exist?(File.join(RailsInstaller::Stage, \"bin\", package.binary))\n        printf \"#{package.name} already on stage.\\n\"\n        return\n      end\n\n      printf \" => Extracting #{filename} to the stage.\\n\" if $Flags[:verbose]\n\n      FileUtils.mkdir_p(RailsInstaller::Stage) unless File.directory?(RailsInstaller::Stage)\n\n      case package.category\n        when \"utility\" # Remove target file, if exists.\n          target = File.join(RailsInstaller::Stage, \"bin\", package.binary)\n          if File.exists?(target)\n            printf \"#{target} on stage.\\n\"\n            return\n          end\n          FileUtils.rm_f(target) if File.exist?(target)\n        when \"component\" # Remove target dir if it exists and is different than the stage\n          if (File.directory?(target_path) && target_path != RailsInstaller::Stage)\n            FileUtils.rm_rf(target_path)\n          end\n        else\n        raise \"Unknown package category\"#{package.category}\".\\npackage category should be one of {\"utility\",\"component\"}?\"\n      end\n\n      archive = File.join(RailsInstaller::Archives, filename)\n\n      Dir.chdir(RailsInstaller::Stage) do\n          case filename\n            when /(^.+\\.tar)\\.z$/, /(^.+\\.tar)\\.gz$/, /(^.+\\.tar)\\.bz2$/, /(^.+\\.tar)\\.lzma$/, /(^.+)\\.tgz$/\n              line = %Q(\"#{bsdtar}\" -xf \"#{archive}\")\n            when /^.+\\.7z$/\n              line = %Q(\"#{sevenzip}\" x -y -t7z -o#{target_path} \"#{archive}\")\n            when /^.+sfx\\.exe$/\n              line = %Q(\"#{sevenzip}\" x -y -t7z -sfx -o#{target_path} #{archive})\n            when /(^.+\\.zip$)/\n              if File.exist?(sevenzip) # Use bsdtar once we already have it\n              line = %Q(\"#{sevenzip}\" x -y -o#{target_path} #{archive})\n            else\n              return unzip(package) # For the unzip case we can return a list of extracted files.\n            end\n          else\n            raise \"\\nERROR:\\n  Cannot extract #{archive}, unhandled file extension!\\n\"\n        end\n\n        sh(line)\n\n        if package.rename\n          case package.category\n            when \"component\"\n              Dir.chdir(RailsInstaller::Stage) do\n                if File.exist?(package.rename)\n                  FileUtils.rm_rf(package.rename)\n                end\n\n                source = File.basename(package.url, File.extname(package.url))\n                printf \"DEBUG: source: %s\\ntarget: %s\\n\", source, package.rename if $Flags[:verbose]\n                FileUtils.mv(\n                  File.basename(package.url, File.extname(package.url)),\n                  package.rename\n                )\n              end\n          end\n        end\n      end\n    end\n  end\n\n  #\n  # install_utility()\n  #\n  # Requires: open-uri\n  #\n  def self.install_utility\n\n    # TODO: Merge this into download, simply check if object has a .binary attribute.\n    if File.exists?(File.join(RailsInstaller::Stage, \"bin\", binary))\n      printf \"#{File.join(RailsInstaller::Stage, \"bin\", binary)} exists.\\nSkipping download, extract and install.\\n\"\n    else\n      printf \" => Downloading and extracting #{binary} from #{utility.url}\\n\"\n\n      FileUtils.mkdir_p(RailsInstaller::Stage) unless File.directory?(RailsInstaller::Stage)\n\n      Dir.chdir(RailsInstaller::Stage) do\n        filename = File.basename(utility.url)\n        FileUtils.rm_f(filename) if File.exist?(filename)\n        # Utilities are small executables, thus using open-uri to download them is fine.\n        open(utility.url) do |temporary_file|\n          File.open(filename, \"wb\") do |file|\n            file.write(temporary_file.read)\n          end\n        end\n\n        extract(binary)\n\n        printf \" => Installing #{binary} to #{File.join(RailsInstaller::Stage, \"bin\")}\\n\"\n\n        FileUtils.mkdir_p(RailsInstaller::Stage, \"bin\") unless File.directory?(RailsInstaller::Stage, \"bin\")\n\n        FileUtils.mv(\n          File.join(RailsInstaller::Stage, binary),\n          File.join(RailsInstaller::Stage, \"bin\", binary),\n          :force => true\n        )\n      end\n    end\n  end\n\n  #\n  # Copy required Sqlite3 files on to the stage\n  #\n  def self.stage_sqlite\n    Sqlite3.files.each do |file|\n      if File.exist?(File.join(Stage, file))\n        FileUtils.mv(\n          File.join(Stage, file),\n          File.join(Stage, Ruby233.rename, \"bin\", file)\n        )\n      end\n    end\n  end\n\n  #\n  # Copy required Postgresql files on to the stage\n  #\n  def self.stage_postgresql\n    PostgresServer.files.each do |file|\n      if File.exist?(File.join(Stage, file))\n        FileUtils.cp(\n          File.join(Stage, PostgresServer.target, \"bin\", file),\n          File.join(Stage, Ruby233.rename, \"bin\", file)\n        )\n      end\n    end\n  end\n\n  #\n  # Add functionality to DevKit object that was loaded during configure.\n  #\n  def self.link_devkit_with_ruby\n    devkit_path = File.join(Stage, DevKit.target)\n    ruby_path = File.join(Stage, Ruby233.rename)\n    FileUtils.mkdir_p(devkit_path) unless File.directory?(devkit_path)\n    Dir.chdir(devkit_path) do\n      File.open(\"config.yml\", \"w\") do |file|\n        file.write(%Q(---\\n- #{ruby_path}))\n      end\n      sh %Q{#{File.join(ruby_path, \"bin\", \"ruby\")} dk.rb install}\n    end\n  end\n\n  def self.stage_git\n    # TODO: adjust git config for CRLF => LF autoadjust.\n    gitconfig = File.join(Stage, Git.target, \"etc\", \"gitconfig\")\n    config = File.read(gitconfig)\n    File.open(gitconfig, \"w\") do |config_file|\n      config_file.write(config.gsub(/autocrlf = true/, \"autocrlf = false\"))\n    end\n  end\n  \n  def self.stage_gem_update  \n  ruby_path = File.join(Stage, Ruby322.rename)\n  \n  line = %Q(#{File.join(ruby_path, \"bin\", \"gem\")} update )\n  sh line\n  end\n\n  def self.stage_gems\n    section Gems\n    build_gems(File.join(Stage, Ruby322.rename), Gems.list)\n  end\n\n  def self.fix_batch_files\n    ruby_path = File.join(Stage, Ruby233.rename)\n    bin_path = File.join(ruby_path, \"bin/\")\n\t  filenames = Dir.glob(\"#{bin_path}*.bat\")\n\t  filenames.each do |filename|\n\t\t  text = File.read(filename)\n\t\t  fixed = text.gsub(/#{bin_path}/, '')\n\t\t  other_bin_path = bin_path.gsub(/\\//, '\\\\\\\\\\\\\\\\')\n\t\t  fixed = fixed.gsub(/#{other_bin_path}/, '')\n\t\t  File.open(filename, \"w\") { |file|\n\t\t\t  file.write fixed\n\t\t  }\n\t  end\n  end\n\n  def self.stage_todo_application\n    section RailsTodo\n    todo_path = File.join(Stage, \"Sites\", \"todo\")\n    FileUtils.rm_rf(todo_path) if File.exist?(todo_path)\n\n    git_binary = File.join(Stage, Git.target, \"bin\", \"git\")\n\n    line = %Q(#{git_binary} clone -b railsinstaller https://github.com/engineyard/todo todo)\n\n    applications_path = File.join(RailsInstaller::Stage, \"Sites\")\n    FileUtils.mkdir_p applications_path unless File.exist?(applications_path)\n    Dir.chdir(applications_path) { sh line }\n    # now bootstrap gems...\n\n    if File.exist?(File.join(todo_path, \".git\"))\n      FileUtils.rm_rf(File.join(todo_path, \".git\"))\n    end\n\n    gem_install File.join(Stage, Ruby233.rename), \"bundler\", :version => \"1.15.3\"\n\n    ruby_binary(\"bundle\", \"install\", \"\", File.join(Stage, Ruby233.rename), File.join(applications_path, \"todo\"))\n  end\n\n  def self.stage_rails_sample_application\n    # Generate sample rails application in the Rails application directory on\n    # stage.\n    section Rails\n    sample = File.join(Stage, \"Sites\", \"sample\")\n    FileUtils.rm_rf(sample) if File.exist?(sample)\n    ruby_binary(\"rails\", \"new\", \"sample\", File.join(Stage, Ruby233.rename))\n  end\n\n  # Renders setup scripts to be used post-installation\n  # They have installation-sensitive information (installation path)\n  def self.stage_setup_scripts\n    section Scripts\n    scripts_path = File.join(RailsInstaller::Stage, \"scripts\")\n    FileUtils.mkdir_p(scripts_path) unless File.exist?(scripts_path)\n\n    %w( config_check.rb ).each do |file|\n      FileUtils.cp(\n        File.join(RailsInstaller::Scripts, file),\n        File.join(scripts_path, file)\n      )\n    end\n\n    %w( publickey.bat ).each do |file|\n      FileUtils.cp(\n        File.join(RailsInstaller::Scripts, file),\n        File.join(Stage, Ruby233.rename, \"bin\", file)\n      )\n    end\n  end\n\n  # MSVC Runtime 2008 is Required for Postgresql Server\n  def self.stage_msvc_runtime\n    download(MsvcRuntime.url)\n    pkg_path = File.join(RailsInstaller::Stage, \"pkg\")\n\n    FileUtils.mkdir_p(pkg_path) unless File.exist?(pkg_path)\n\n    FileUtils.cp(\n      File.join(RailsInstaller::Archives, File.basename(MsvcRuntime.url)),\n      File.join(pkg_path, File.basename(MsvcRuntime.url))\n    )\n  end\n\n  #\n  # build_gems\n  #\n  # loops over each gemname and triggers it to be built.\n  def self.build_gems(ruby_path, gems)\n    if gems.is_a?(Array)\n      gems.each do |name|\n        build_gem(ruby_path, name)\n      end\n    elsif gems.is_a?(Hash)\n      gems.each_pair do |name, version |\n        build_gem(ruby_path, name, version)\n      end\n    else\n      build_gem(ruby_path, gems)\n    end\n  end\n\n  def self.build_gem(ruby_path, gem, options = {})\n    if gem.is_a?(Hash)\n      options[:version] = gem[:version]\n      gem_install(ruby_path,gem[:name], options)\n    else\n      gem_install(ruby_path,gem, options)\n    end\n  end\n\n  def self.gem_install(ruby_path, gem,options = {})\n    printf \" => Staging gem #{gem}\\n\" if $Flags[:verbose]\n    %w(GEM_HOME GEM_PATH).each { |variable| ENV.delete(variable)}\n    line = %Q(#{File.join(ruby_path, \"bin\", \"gem\")} install #{gem} )\n    line << %Q( -v \"#{options[:version]}\" ) if options[:version]\n    #line << %Q( --env-shebang --no-rdoc --no-ri --source http://rubygems.org )\n    line << options[:args] if options[:args]\n    sh line\n  end\n\n  def self.ruby_binary(name, line, action, ruby_path, directory_path, options = {})\n    printf \" => rails #{line} #{action}\\n\" if $Flags[:verbose]\n    %w(GEM_HOME GEM_PATH).each { |variable| ENV.delete(variable)}\n    line = %Q(#{File.join(ruby_path, \"bin\", \"ruby\")} -S #{name} #{line} #{action})\n    line += options[:args] if options[:args]\n    Dir.chdir(directory_path) { sh line }\n  end\n\n  def self.iscc(*params)\n    executable = nil\n\n    # look for Inno Setup compiler in the PATH\n    found = ENV[\"PATH\"].split(File::PATH_SEPARATOR).find do |path|\n      File.exist?(File.join(path, \"ISCC.exe\")) && File.executable?(File.join(path, \"ISCC.exe\"))\n    end\n\n    # not found?\n    if found\n      executable = \"ISCC.exe\"\n    else\n      path = File.join(ENV[\"ProgramFiles\"], \"Inno Setup 6\")\n      if File.exist?(File.join(path, \"ISCC.exe\")) && File.executable?(File.join(path, \"ISCC.exe\"))\n        path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR)\n        ENV[\"PATH\"] = \"#{path}#{File::PATH_SEPARATOR}#{ENV[\"PATH\"]}\" unless ENV[\"PATH\"].include?(path)\n        executable = \"ISCC.exe\"\n      end\n    end\n    cmd = [executable]\n    cmd.concat(params)\n    sh cmd.join(\" \")\n  end\n\n  #\n  # sh\n  #\n  # Runs Shell lines, single point of shell contact.\n  #\n  def self.sh(line, options = {})\n    stage_bin_path = File.join(RailsInstaller::Stage, \"bin\")\n    ENV[\"PATH\"] = \"#{stage_bin_path};#{ENV[\"PATH\"]}\" unless ENV[\"PATH\"].include?(stage_bin_path)\n\n    printf \"\\nDEBUG: > %s\\n\\n\", line if $Flags[:verbose]\n\n    output, status = Open3.capture2e(line)\n    puts output.read unless output.empty?  if $Flags[:versbose]\n  end\n\n  def self.log(text)\n    printf %Q[#{text}\\n]\n  end\n\n  def self.section(text)\n    printf %Q{\\n== #{text}\\n\\n}\n  end\nend\n"
  },
  {
    "path": "lib/railsinstaller.rb",
    "content": "module RailsInstaller # Ensure that the RailsInstaller project root is defined.\r\n  Root       = File.expand_path(File.join(File.dirname(__FILE__), \"..\"))\r\n  Stage      = File.expand_path(File.join(Root, \"stage\"))\r\n  Archives   = File.expand_path(File.join(Root, \"archives\"))\r\n  Scripts    = File.expand_path(File.join(Root, \"resources/scripts\"))\r\n  PackageDir = File.expand_path(File.join(Root, \"pkg\"))\r\nend\r\n\r\n%w[ rubygems fileutils ostruct yaml erb uri open-uri open3 zip ].each do |name|\r\n  printf \"Loading #{name}...\\n\" if $Flags[:verbose]\r\n  require name\r\nend\r\n\r\ngem \"rubyzip\"\r\n\r\n%w[ globals ].each do |name|\r\n  printf \"Loading #{name}...\\n\" if $Flags[:verbose]\r\n  require File.expand_path(File.join(RailsInstaller::Root, \"lib\", \"setup\", name + '.rb'))\r\nend\r\n\r\n%w[ stdlib ].each do |name|\r\n  printf \"Loading #{name}...\\n\" if $Flags[:verbose]\r\n  require File.expand_path(File.join(RailsInstaller::Root, \"lib\", \"extensions\", name + '.rb'))\r\nend\r\n\r\n%w[ components methods downloads actions ].each do |name|\r\n  printf \"Loading #{name}...\\n\" if $Flags[:verbose]\r\n  require File.expand_path(File.join(RailsInstaller::Root, \"lib\", \"railsinstaller\", name + '.rb'))\r\nend\r\n"
  },
  {
    "path": "lib/setup/globals.rb",
    "content": "$Flags ||= { :verbose => false }\r\n"
  },
  {
    "path": "rake/railsinstaller.rake",
    "content": "task :default do\r\n  printf \"\\nRailsInstaller Rake Tasks:\r\n\r\n  {bootstrap, build, package}\r\n\r\nSee README.md for more details.\\n\\n\"\r\nend\r\n\r\ntask :require_railsinstaller do\r\n\r\n  require \"railsinstaller\"\r\n\r\nend\r\n\r\ndesc \"Bootstrap RailsInstaller development environment (gems)\"\r\ntask :bootstrap do\r\n\r\n  require \"rubygems/dependency_installer\"\r\n\r\n  gems = File.read(File.join(ProjectRoot, \".gems\")).gsub(\" -v\", ' ').split(\"\\n\")\r\n\r\n  gems.each do |gem|\r\n\r\n    printf \"Ensuring #{gem} is installed...\\n\"\r\n\r\n    name, version, options = gem.split(/\\s+/)\r\n\r\n    installer = Gem::DependencyInstaller.new(\r\n      { :generate_rdoc => false, :generate_ri => false }\r\n    )\r\n\r\n    version ? installer.install(name, version) : installer.install(name)\r\n\r\n  end\r\n\r\n  printf \"Bootstrapped.\\nDo not forget to download and install Inno Setup, see README.md for more information.\\n\"\r\n\r\nend\r\n\r\ndesc \"Download and build all components and dependencies into stage/.\"\r\ntask :build => [ :require_railsinstaller ] do\r\n\r\n  RailsInstaller.build!\r\n\r\nend\r\n\r\ndesc \"Package all components into a single executable installer into pkg/.\"\r\ntask :package => [ :require_railsinstaller ] do\r\n\r\n  RailsInstaller.package!\r\n\r\nend\r\n"
  },
  {
    "path": "rakefile.rb",
    "content": "#!/usr/bin/env ruby\r\n\r\nrequire \"rubygems\"\r\nrequire \"rake\"\r\n\r\n# Ensure project root is in the LOAD_PATH\r\n$LOAD_PATH.unshift(File.join(File.expand_path(File.dirname(__FILE__)), \"lib\"))\r\n\r\nProjectRoot = File.dirname(File.expand_path(__FILE__))\r\n\r\n# Set Flags\r\n$Flags = {} if $Flags.nil?\r\nif Rake.application.options.trace\r\n  $Flags[:verbose] = true\r\nend\r\n\r\n# Load all Rake Task definitions\r\nDir[\"#{ProjectRoot}/rake/*.rake\"].each do |file|\r\n  puts \"Loading #{File.basename(file)}\" if Rake.application.options.trace\r\n  load file\r\nend\r\n"
  },
  {
    "path": "resources/chm/README",
    "content": "=RailsInstaller\r\n\r\nThe goal of the RailsInstaller project is to provide developers working on Windows\r\nsystems with an easy way to quickly get started using Ruby on Rails by providing\r\na Windows installer containing a fully functioning baseline MRI (Matz' Ruby\r\nImplementation) Ruby environment tuned for Windows systems with libraries for\r\ndoing Ruby on Rails development.\r\n"
  },
  {
    "path": "resources/chm/contents.hhc.rhtml",
    "content": "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\r\n<HTML>\r\n<HEAD>\r\n<meta name=\"GENERATOR\" content=\"Microsoft&reg; HTML Help Workshop 4.1\">\r\n<!-- Sitemap 1.0 -->\r\n</HEAD>\r\n  <BODY>\r\n    <OBJECT type=\"text/site properties\">\r\n      <param name=\"ImageType\" value=\"Folder\">\r\n    </OBJECT><% rdocs.each do |rdoc| %>\r\n    <UL>\r\n      <LI><OBJECT type=\"text/sitemap\">\r\n            <param name=\"Name\" value=\"<%= rdoc[:title] %>\"><% if rdoc[:file] =~ /\\.chm$/ %>\r\n            <param name=\"Local\" value=\"<%= rdoc[:file] %>::/index.html\">\r\n          </OBJECT>\r\n          <OBJECT type=\"text/sitemap\">\r\n            <param name=\"Name\" value=\"<%= rdoc[:file] %>::/contents.hhc\">\r\n            <param name=\"Merge\" value=\"<%= rdoc[:file] %>::/contents.hhc\">\r\n          </OBJECT><% else %>\r\n            <param name=\"Local\" value=\"<%= rdoc[:file] %>\">\r\n          </OBJECT><% end %>\r\n    </UL><% end %>\r\n  </BODY>\r\n</HTML>\r\n"
  },
  {
    "path": "resources/chm/index.hhk.rhtml",
    "content": "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\r\n<HTML>\r\n<HEAD>\r\n<meta name=\"GENERATOR\" content=\"Microsoft&reg; HTML Help Workshop 4.1\">\r\n<!-- Sitemap 1.0 -->\r\n</HEAD><BODY>\r\n<UL>\r\n    <LI> <OBJECT type=\"text/sitemap\">\r\n        <param name=\"Name\" value=\"readme\">\r\n        <param name=\"Local\" value=\"readme\\files\\README.html\">\r\n        </OBJECT>\r\n</UL>\r\n</BODY></HTML>\r\n"
  },
  {
    "path": "resources/chm/project.hhp.rhtml",
    "content": "[OPTIONS]\r\nAuto Index=Yes\r\nCompatibility=1.1 or later\r\nCompiled file=<%= File.basename(meta_chm.file) %>\r\nContents file=contents.hhc\r\nDisplay compile progress=No\r\nDefault topic=index.html\r\nLanguage=0x409 English (United States)\r\nTitle=<%= meta_chm.title %>\r\nFull-text search=Yes\r\nIndex file=index.hhk\r\n\r\n[FILES] <% meta_chm.files.each do |file| %>\r\n<%= file %>\r\n<% end %>\r\n\r\n[MERGE FILES] <% meta_chm.merge_files.each do |merge_file| %>\r\n<%= merge_file %>\r\n\r\n<% end %>\r\n\r\n[INFOTYPES]\r\n\r\n"
  },
  {
    "path": "resources/railsinstaller/LICENSE.txt",
    "content": "Copyright (c) 2010-2022 RailsInstaller Team.\r\n\r\nExcept:\r\n\r\n  * Ruby is copyrighted free software by Yukihiro Matsumoto.\r\n    http://www.ruby-lang.org/en/LICENSE.txt\r\n\r\n  * DevKit is licensed via the RubyInstaller project:\r\n    http://rubyinstaller.org/\r\n\r\n  * 3rd party libraries (OpenSSL, ZLib, etc.)\r\n\r\n\r\nThis software is distributed under the terms of MIT license.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n"
  },
  {
    "path": "resources/railsinstaller/railsinstaller.iss",
    "content": "; RailsInstaller - Inno Setup Script\r\n; Adaptation from RubyInstaller installer script\r\n;\r\n\r\n; PRE-CHECK\r\n; Verify that RubyPath is defined by ISCC using\r\n; /d command line arguments.\r\n;\r\n; Usage:\r\n;  iscc rubyinstaller.iss /dInstallerVersion=0.1.0\r\n;                         /dStagePath=stage\r\n;                         /dRubyPath=Ruby/1.9.2\r\n;                         [/dInstVersion=26-OCT-2009]\r\n\r\n; Full example:\r\n; iscc resouces\\railsinstaller\\railsinstaller.iss \\\r\n;       /dInstallerVersion=2.1.0 \\\r\n;       /dStagePath=stage \\\r\n;       /dRubyPath=Ruby1.9.2 \\\r\n;       /opkg\r\n;       /frailsinstaller-2.1.0.exe\r\n\r\n#if Defined(InstallerVersion) == 0\r\n  #error Please provide a InstallerVersion definition using a /d parameter.\r\n#endif\r\n\r\n#if Defined(StagePath) == 0\r\n  #error Please provide a StagePath value to the Ruby files using a /d parameter.\r\n#endif\r\n\r\n; Once a ruby version has been downloaded then I can test this at the moment commet out so I could upgrade the INNO to version 6\r\n#if Defined(RubyPath) == 0\r\n  #error Please provide a RubyPath value to the Ruby files using a /d parameter.\r\n#else\r\n  #if FileExists(StagePath + '/' + RubyPath + '\\bin\\ruby.exe') == 0\r\n    #error No Ruby installation (bin\\ruby.exe) found inside defined RubyPath. Please verify.\r\n          #error \"Setup failed to run the script.\"\r\n  #endif\r\n#endif\r\n\r\n#if Defined(InstVersion) == 0\r\n  #define InstVersion GetDateTimeString('dd-mmm-yy\"T\"hhnn', '', '')\r\n#endif\r\n\r\n; Build Installer details using above values\r\n#define InstallerName \"RailsInstaller\"\r\n#define InstallerNameWithVersion InstallerName + \" \" + InstallerVersion\r\n#define InstallerPublisher \"RailsInstaller Team\"\r\n#define InstallerHomepage \"http://www.railsinstaller.org/\"\r\n\r\n#define CurrentYear GetDateTimeString('yyyy', '', '')\r\n\r\n[Setup]\r\n; NOTE: The value of AppId uniquely identifies this application.\r\n; Do not use the same AppId value in installers for other applications!\r\nAppId={{613C3EA5-1248-4E35-B61A-6D0B31BBC0DB}\r\nAppName={#InstallerName}\r\nAppVerName={#InstallerNameWithVersion}\r\nAppPublisher={#InstallerPublisher}\r\nAppPublisherURL={#InstallerHomepage}\r\nAppVersion={#InstallerVersion}\r\nDefaultGroupName={#InstallerName}\r\nDefaultDirName={sd}\\RailsInstaller\r\nDisableProgramGroupPage=true\r\nLicenseFile=LICENSE.txt\r\nCompression=lzma2/ultra64\r\nSolidCompression=true\r\nAlwaysShowComponentsList=false\r\nDisableReadyPage=true\r\nInternalCompressLevel=ultra64\r\nVersionInfoCompany={#InstallerPublisher}\r\nVersionInfoCopyright=(c) {#CurrentYear} {#InstallerPublisher}\r\nVersionInfoDescription=Rails development environment installer for Windows\r\nVersionInfoTextVersion={#InstallerVersion}\r\nVersionInfoVersion={#InstallerVersion}\r\nUninstallDisplayIcon={app}\\bin\\ruby.exe\r\nWizardImageFile={#ResourcesPath}\\images\\RailsInstallerWizardImage.bmp\r\nWizardSmallImageFile={#ResourcesPath}\\images\\RailsInstallerWizardImageSmall.bmp\r\nPrivilegesRequired=lowest\r\nChangesAssociations=yes\r\nChangesEnvironment=yes\r\nUsePreviousAppDir=no\r\n\r\n#if Defined(SignPackage) == 1\r\nSignTool=risigntool sign /a /d $q{#InstallerNameWithVersion}$q /du $q{#InstallerHomepage}$q /t $qhttp://timestamp.comodoca.com/authenticode$q $f\r\n#endif\r\n\r\n[Languages]\r\nName: en; MessagesFile: compiler:Default.isl\r\n\r\n[Messages]\r\nen.InstallingLabel=Installing [name], this will take a few minutes...\r\nen.WelcomeLabel1=Welcome to [name]!\r\nen.WelcomeLabel2=This will install [name/ver] on your computer.  Please close any console applications before continuing.\r\nen.WizardLicense={#InstallerName} License Agreement\r\nen.LicenseLabel=\r\nen.LicenseLabel3=Please read the following License Agreements and accept the terms before continuing the installation.\r\nen.LicenseAccepted=I &accept all of the Licenses\r\nen.LicenseNotAccepted=I &decline any of the Licenses\r\nen.WizardSelectDir=Installation Destination and Optional Tasks\r\nen.SelectDirDesc=This is the location that Ruby, DevKit, Rails and Sqlite will be installed to.\r\nen.SelectDirLabel3=[name] will be installed into the following folder. Click Install to continue or click Browse to use a different one.\r\nen.SelectDirBrowseLabel=Please avoid any folder name that contains spaces (e.g. Program Files).\r\nen.DiskSpaceMBLabel=Required free disk space: ~[mb] MB\r\n\r\n[Files]\r\n; NOTE: Don't use \"Flags: ignoreversion\" on any shared system files\r\nSource: {#StagePath}\\{#RubyPath}\\*; DestDir: {app}\\{#RubyPath}; Flags: recursesubdirs createallsubdirs\r\nSource: {#StagePath}\\Git\\*; DestDir: {app}\\Git; Flags: recursesubdirs createallsubdirs\r\n;Source: {#StagePath}\\Git\\*; DestDir: {app}\\Git; Check: InstallGit; Flags: recursesubdirs createallsubdirs\r\n;Source: {#StagePath}\\DevKit\\*; DestDir: {app}\\DevKit; Excludes: \"config.yml\"; Flags: recursesubdirs createallsubdirs\r\n;Source: {#StagePath}\\DevKit\\config.yml; DestDir: {app}\\DevKit; AfterInstall: UpdateDevKitConfig('{app}\\{#RubyPath}', '{app}\\DevKit\\config.yml')\r\n;Source: {#StagePath}\\Sites\\*; DestDir: {sd}\\Sites; Flags: recursesubdirs createallsubdirs\r\n;Source: {#StagePath}\\scripts\\*; DestDir: {app}\\scripts; Flags: recursesubdirs createallsubdirs\r\n; TODO: Instead of running the full vcredist, simply extract and bundle the dll\r\n;       files with an associated manifest.\r\n; Source: {#StagePath}\\pkg\\vcredist_x86.exe; DestDir: {tmp}; Flags: deleteafterinstall\r\n;Source: setup_environment.bat; DestDir: {app}\\{#RubyPath}\r\n\r\n[Registry]\r\n; FIXME: Proper registry keys for RailsInstaller (admin)\r\n;Root: HKLM; Subkey: Software\\RailsInstaller; ValueType: string; ValueName: ; ValueData: ; Flags: uninsdeletevalue uninsdeletekeyifempty; Check: IsAdmin\r\n\r\n; FIXME: Proper registry key for RailsInstaller (user)\r\n;Root: HKCU; Subkey: Software\\RailsInstaller; ValueType: string; ValueName: ; ValueData: ; Flags: uninsdeletevalue uninsdeletekeyifempty; Check: IsNotAdmin\r\n\r\n[Icons]\r\nName: {group}\\Interactive Ruby; Filename: {app}\\{#RubyPath}\\bin\\irb.bat; WorkingDir: {app}\\{#RubyPath} ; IconFilename: {app}\\{#RubyPath}\\bin\\ruby.exe; Flags: createonlyiffileexists\r\nName: {group}\\RubyGems Documentation Server; Filename: {app}\\{#RubyPath}\\bin\\gem.bat; Parameters: server; IconFilename: {app}\\{#RubyPath}\\bin\\ruby.exe; Flags: createonlyiffileexists runminimized\r\nName: {group}\\Command Prompt with Ruby and Rails; Filename: {sys}\\cmd.exe; Parameters: /E:ON /K {app}\\{#RubyPath}\\setup_environment.bat {app}; WorkingDir: {sd}\\Sites; IconFilename: {sys}\\cmd.exe; Flags: createonlyiffileexists\r\n;Name: {group}\\Git Bash; Filename: {sys}\\cmd.exe; Parameters: \"/c \"\"\"\"{app}\\Git\\bin\\sh.exe\"\" --login -i\"\"\"; WorkingDir: {sd}\\Sites; IconFilename: {app}\\Git\\etc\\git.ico; Check: InstallGit; Flags: createonlyiffileexists\r\n; {%HOMEPATH%}\r\nName: {group}\\{cm:UninstallProgram,{#InstallerName}}; Filename: {uninstallexe}\r\n\r\n[Run]\r\n;Filename: \"{app}\\{#RubyPath}\\bin\\ruby.exe\"; Parameters: \"dk.rb install --force\"; WorkingDir: \"{app}\\DevKit\"; Flags: runhidden\r\n;Filename: \"{app}\\{#RubyPath}\\bin\\gem.bat\"; Parameters: \"pristine --all --only-executables\"; WorkingDir: \"{app}\\{#RubyPath}\\bin\"; Flags: runhidden\r\n;Filename: {sys}\\cmd.exe; Parameters: /E:ON /K {app}\\{#RubyPath}\\setup_environment.bat {app}; WorkingDir: {sd}\\Sites; Description: \"Configure git and ssh when installation has completed.\"; Check: InstallGit; Flags: postinstall nowait skipifsilent\r\n\r\n; TODO: Instead of running the full vcredist, simply extract and bundle the dll\r\n;       files with an associated manifest.\r\n; Filename: \"{tmp}\\vcredist_x86.exe\"; StatusMsg: \"Installing Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)...\" ; Parameters: \"/q\"; WorkingDir: \"{tmp}\"; Flags: runhidden\r\n\r\n[Code]\r\n#include \"util.iss\"\r\n#include \"railsinstaller_gui.iss\"\r\n\r\nfunction GetInstallDate(Param: String): String;\r\nbegin\r\n  Result := GetDateTimeString('yyyymmdd', #0 , #0);\r\nend;\r\n\r\nprocedure CurStepChanged(const CurStep: TSetupStep);\r\nbegin\r\n\r\n  // TODO move into ssPostInstall just after install completes?\r\n  if CurStep = ssInstall then\r\n  begin\r\n    if UsingWinNT then\r\n    begin\r\n      Log(Format('Selected Tasks - Path: %d', [PathChkBox.State]));\r\n\r\n      if IsModifyPath then\r\n        ModifyPath([ExpandConstant('{app}') + '\\{#RubyPath}\\bin']);\r\n        ModifyPath([ExpandConstant('{app}') + '\\Git\\bin']);\r\n\r\n    end else\r\n      MsgBox('Looks like you''ve got on older, unsupported Windows version.' #13 +\r\n             'Proceeding with a reduced feature set installation.',\r\n             mbInformation, MB_OK);\r\n  end;\r\nend;\r\n\r\nprocedure RegisterPreviousData(PreviousDataKey: Integer);\r\nbegin\r\n  {* store install choices so we can use during uninstall *}\r\n  if IsModifyPath then\r\n    SetPreviousData(PreviousDataKey, 'PathModified', 'yes');\r\n\r\n  SetPreviousData(PreviousDataKey, 'RailsInstallerId', '{#InstallerVersion}');\r\nend;\r\n\r\nprocedure CurUninstallStepChanged(const CurUninstallStep: TUninstallStep);\r\nbegin\r\n  if CurUninstallStep = usUninstall then\r\n  begin\r\n    if UsingWinNT then\r\n    begin\r\n      if GetPreviousData('PathModified', 'no') = 'yes' then\r\n\t    begin\r\n        ModifyPath([ExpandConstant('{app}') + '\\{#RubyPath}\\bin']);\r\n        ModifyPath([ExpandConstant('{app}') + '\\Git\\bin']);\r\n\t\tend\r\n    end;\r\n  end;\r\nend;\r\n\r\nprocedure UpdateDevKitConfig(RubyPath: string; FileName: string);\r\nvar\r\n  S: String;\r\nbegin\r\n  // Make YAML happy :-)\r\n  S := ExpandConstant(RubyPath);\r\n  StringChangeEx(S, '\\', '/', True);\r\n\r\n  // Update DevKit config.yml with the installation path\r\n  SaveStringToFile(ExpandConstant(FileName), '- ' + S, False);\r\nend;\r\n"
  },
  {
    "path": "resources/railsinstaller/railsinstaller_gui.iss",
    "content": "// RubyInstaller Inno Setup GUI Customizations\r\n//\r\n// Copyright (c) 2009 Jon Maken\r\n// Revision: 11/23/2009 3:35:36 PM\r\n// License: MIT\r\n\r\nvar\r\n  PathChkBox, PathExtChkBox: TCheckBox;\r\n\r\nfunction IsAssociated(): Boolean;\r\nbegin\r\n  Result := PathExtChkBox.Checked;\r\nend;\r\n\r\nfunction IsModifyPath(): Boolean;\r\nbegin\r\n  Result := PathChkBox.Checked;\r\nend;\r\n\r\nprocedure ParseSilentTasks();\r\nvar\r\n  I, N: Integer;\r\n  Param: String;\r\n  Tasks: TStringList;\r\nbegin\r\n  {* parse command line args for silent install tasks *}\r\n  for I := 0 to ParamCount do\r\n  begin\r\n    Param := AnsiUppercase(ParamStr(I));\r\n    if Pos('/TASKS', Param) <> 0 then\r\n    begin\r\n      Param := Trim(Copy(Param, Pos('=', Param) + 1, Length(Param)));\r\n      try\r\n        // TODO check for too many tasks to prevent overflow??\r\n        Tasks := StrToList(Param, ',');\r\n        for N := 0 to Tasks.Count - 1 do\r\n          case Trim(Tasks.Strings[N]) of\r\n            'MODPATH': PathChkBox.State := cbChecked;\r\n          end;\r\n      finally\r\n        Tasks.Free;\r\n      end;\r\n    end;\r\n  end;\r\nend;\r\n\r\nprocedure URLText_OnClick(Sender: TObject);\r\nvar\r\n  ErrorCode: Integer;\r\nbegin\r\n  if Sender is TNewStaticText then\r\n    ShellExec('open', TNewStaticText(Sender).Caption, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);\r\nend;\r\n\r\nprocedure InitializeWizard;\r\nvar\r\n  Page: TWizardPage;\r\n  HostPage: TNewNotebookPage;\r\n  URLText, TmpLabel: TNewStaticText;\r\nbegin\r\n\r\n  {* Path and file association task check boxes *}\r\n\r\n  Page := PageFromID(wpSelectDir);\r\n  \r\n  PathChkBox := TCheckBox.Create(Page);\r\n  PathChkBox.Parent := Page.Surface;\r\n  PathChkBox.State := cbChecked;\r\n  PathChkBox.Caption := 'Add executables for Ruby and DevKit to the PATH ';\r\n  PathChkBox.Alignment := taRightJustify;\r\n  PathChkBox.Top := ScaleY(125);\r\n  PathChkBox.Left := ScaleX(18);\r\n  PathChkBox.Width := Page.SurfaceWidth;\r\n  PathChkBox.Height := ScaleY(17);\r\n\r\n  ParseSilentTasks;\r\n\r\n  HostPage := WizardForm.FinishedPage;\r\n\r\n  TmpLabel := TNewStaticText.Create(HostPage);\r\n  TmpLabel.Parent := HostPage;\r\n  TmpLabel.Top := ScaleY(180);\r\n  TmpLabel.Left := ScaleX(176);\r\n  TmpLabel.AutoSize := True;\r\n  TmpLabel.Caption := 'Web Site:';\r\n\r\n  URLText := TNewStaticText.Create(HostPage);\r\n  URLText.Parent := HostPage;\r\n  URLText.Top := TmpLabel.Top;\r\n  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);\r\n  URLText.AutoSize := True;\r\n  URLText.Caption := 'http://railsinstaller.org/';\r\n  URLText.Cursor := crHand;\r\n  URLText.Font.Color := clBlue;\r\n  URLText.OnClick := @URLText_OnClick;\r\n\r\n  TmpLabel := TNewStaticText.Create(HostPage);\r\n  TmpLabel.Parent := HostPage;\r\n  TmpLabel.Top := ScaleY(196);\r\n  TmpLabel.Left := ScaleX(176);\r\n  TmpLabel.AutoSize := True;\r\n  TmpLabel.Caption := 'Mailing List:';\r\n\r\n  URLText := TNewStaticText.Create(HostPage);\r\n  URLText.Parent := HostPage;\r\n  URLText.Top := TmpLabel.Top;\r\n  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);\r\n  URLText.AutoSize := True;\r\n  URLText.Caption := 'http://groups.google.com/group/railsinstaller';\r\n  URLText.Cursor := crHand;\r\n  URLText.Font.Color := clBlue;\r\n  URLText.OnClick := @URLText_OnClick;\r\n\r\n  TmpLabel := TNewStaticText.Create(HostPage);\r\n  TmpLabel.Parent := HostPage;\r\n  TmpLabel.Top := ScaleY(212);\r\n  TmpLabel.Left := ScaleX(176);\r\n  TmpLabel.AutoSize := True;\r\n  TmpLabel.Caption := 'IRC:';\r\n\r\n  URLText := TNewStaticText.Create(HostPage);\r\n  URLText.Parent := HostPage;\r\n  URLText.Top := TmpLabel.Top;\r\n  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);\r\n  URLText.AutoSize := True;\r\n  URLText.Caption := 'http://wiki.github.com/wayneeseguin/railsinstaller';\r\n  URLText.Cursor := crHand;\r\n  URLText.Font.Color := clBlue;\r\n  URLText.OnClick := @URLText_OnClick;\r\n\r\n  URLText := TNewStaticText.Create(HostPage);\r\n  URLText.Parent := HostPage;\r\n  URLText.Top := TmpLabel.Top;\r\n  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);\r\n  URLText.AutoSize := True;\r\n  URLText.Caption := 'http://webchat.freenode.net/?channels=railsinstaller';\r\n  URLText.Cursor := crHand;\r\n  URLText.Font.Color := clBlue;\r\n  URLText.OnClick := @URLText_OnClick;\r\n\r\nend;\r\n\r\nprocedure CurPageChanged(CurPageID: Integer);\r\nbegin\r\n  if CurPageID = wpSelectDir then\r\n    WizardForm.NextButton.Caption := '&Install';\r\nend;\r\n\r\n"
  },
  {
    "path": "resources/railsinstaller/setup_environment.bat",
    "content": "@ECHO OFF\r\n\r\nREM\r\nREM Environment setup file for RailsInstaller.\r\nREM\r\n\r\nREM\r\nREM First we determine where is RUBY_DIR (which is where this script is)\r\nREM\r\nPUSHD %~dp0.\r\nSET RUBY_DIR=%CD%\r\nPOPD\r\n\r\nREM\r\nREM Now determine the RailsInstaller root directory (parent directory of Ruby)\r\nREM\r\nPUSHD %RUBY_DIR%\\..\r\nSET ROOT_DIR=%CD%\r\nPOPD\r\n\r\nREM\r\nREM Add RUBY_DIR\\bin to the PATH, DevKit\\bin and then Git\\cmd\r\nREM RUBY_DIR\\bin takes higher priority to avoid other tools conflict\r\nREM\r\nSET PATH=%RUBY_DIR%\\bin;%RUBY_DIR%\\lib\\ruby\\gems\\1.9.1\\bin;%ROOT_DIR%\\DevKit\\bin;%PATH%\r\nIF EXIST %ROOT_DIR%\\Git\\cmd SET PATH=%ROOT_DIR%\\Git\\cmd;%PATH%\r\nSET RUBY_DIR=\r\nSET ROOT_DIR=\r\n\r\nREM\r\nREM Create the %HOMEDRIVE%\\Sites directory.\r\nREM\r\nIF NOT EXIST %HOMEDRIVE%\\Sites MD %HOMEDRIVE%\\Sites\r\n\r\nREM\r\nREM Set the HOME environment variables for Ruby & Gems to use with ENV[\"HOME\"]\r\nREM\r\nSET HOME=%HOMEDRIVE%%HOMEPATH%\r\n\r\nSET RailsInstallerPath=%1\r\nREM Check configurations for Git and SSH\r\nIF EXIST %RailsInstallerPath% (\r\n  ruby %RailsInstallerPath%\\scripts\\config_check.rb\r\n) ELSE (\r\n  ruby.exe \"require 'rbconfig' ; file=%%\\#{RbConfig::}\"\r\n)\r\n\r\nREM NOTE that we start out in the Sites directory as the current working dir\r\nIF EXIST %HOMEDRIVE%\\Sites CD %HOMEDRIVE%\\Sites\r\n"
  },
  {
    "path": "resources/railsinstaller/util.iss",
    "content": "// Inno Setup utilities\r\n//\r\n// Copyright (c) 2009 Jon Maken\r\n// Revision: 11/03/2009 8:04:17 PM\r\n// License: MIT\r\n\r\n// forward declarations\r\nfunction MungePathish(const SrcList: TStringList; NewData: Array of String; RegValue: String; IsUninstalling: Boolean): Boolean; forward;\r\nprocedure ModifyPathish(NewData: Array of String; RegValue, Delim: String); forward;\r\nfunction StrToList(const SrcString: String; Delim: String): TStringList; forward;\r\nfunction ListToStr(const SrcList: TStringList; Delim: String): String; forward;\r\n\r\nfunction IsAdmin(): Boolean;\r\nbegin\r\n  Result := IsAdminLoggedOn or IsPowerUserLoggedOn;\r\nend;\r\n\r\nfunction IsNotAdmin(): Boolean;\r\nbegin\r\n  Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn);\r\nend;\r\n\r\nfunction GetUserHive(): Integer;\r\nbegin\r\n  if IsAdminLoggedOn or IsPowerUserLoggedOn then\r\n    Result :=  HKLM\r\n  else\r\n    Result := HKCU;\r\nend;\r\n\r\nfunction GetEnvironmentKey(): String;\r\nbegin\r\n  if IsAdmin then\r\n    Result := 'SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment'\r\n  else\r\n    Result := 'Environment';\r\nend;\r\n\r\nprocedure ModifyFileExts(Exts: Array of String);\r\nbegin\r\n  ModifyPathish(Exts, 'PATHEXT', ';');\r\nend;\r\n\r\nprocedure ModifyPath(Exts: Array of String);\r\nbegin\r\n  ModifyPathish(Exts, 'PATH', ';');\r\nend;\r\n\r\n// Modifies path-like registry keys such as PATH, PATHEXT\r\nprocedure ModifyPathish(NewData: Array of String; RegValue, Delim: String);\r\nvar\r\n  NeedRegChange: Boolean;\r\n  RootKey: Integer;\r\n  SubKey, OrigData, NewPathish, Tmp, TmpExpandable: String;\r\n  PathishList: TStringList;\r\nbegin\r\n  RootKey := GetUserHive;\r\n  SubKey := GetEnvironmentKey;\r\n\r\n  try\r\n    RegQueryStringValue(RootKey, SubKey, RegValue, OrigData);\r\n    Log('Original ' + AnsiUppercase(RegValue) + ': ' + OrigData);\r\n\r\n    // ensure originally empty users PATHEXT also contains system values\r\n    if (RootKey = HKCU) and (AnsiUppercase(RegValue) = 'PATHEXT') and (OrigData = '') then\r\n    begin\r\n      Log('Empty HKCU ' + AnsiUppercase(RegValue) + ', prepending %PATHEXT% to new value');\r\n      OrigData := ('%' + RegValue + '%');\r\n    end;\r\n\r\n    PathishList := StrToList(OrigData, Delim);\r\n\r\n    NeedRegChange := MungePathish(PathishList, NewData, RegValue, IsUninstaller);\r\n\r\n    if NeedRegChange then\r\n    begin\r\n      NewPathish := ListToStr(PathishList, ';');\r\n\r\n      case AnsiUppercase(RegValue) of\r\n        'PATH': RegWriteExpandStringValue(RootKey, SubKey, 'Path', NewPathish);\r\n        'PATHEXT': RegWriteExpandStringValue(RootKey, SubKey, 'PATHEXT', NewPathish);\r\n      end;\r\n      Log(AnsiUppercase(RegValue) + ' updated to: ' + NewPathish);\r\n\r\n      // remove values if empty after uninstaller reverts its mods\r\n      if IsUninstaller then\r\n      begin\r\n        if RegQueryStringValue(RootKey, SubKey, RegValue, Tmp) then\r\n        begin\r\n          // If the key is empty or expandable version (%RegValue%), remove it.\r\n          TmpExpandable := '%' + RegValue + '%';\r\n          if (Tmp = '') or (Tmp = TmpExpandable) then\r\n          begin\r\n            RegDeleteValue(RootKey, SubKey, RegValue);\r\n            Log('uninstaller deleted empty ' + AnsiUppercase(RegValue) +\r\n                ' to match original config');\r\n          end;\r\n        end;\r\n      end;\r\n    end else  // no reg change needed\r\n      Log('no changes need for ' + AnsiUppercase(RegValue));\r\n  finally\r\n    PathishList.Free;\r\n  end;\r\nend;\r\n\r\nfunction StrToList(const SrcString: String; Delim: String): TStringList;\r\nvar\r\n  PathList: TStringList;\r\n  TmpPath: String;\r\nbegin\r\n  PathList := TStringList.Create;\r\n\r\n  // empty PATH\r\n  if Length(SrcString) = 0 then Result := PathList;\r\n\r\n  if (Length(SrcString) > 0) then\r\n  begin\r\n    // single entry with no trailing ';'\r\n    if Pos(Delim, SrcString) = 0 then\r\n    begin\r\n      PathList.Append(SrcString);\r\n\r\n      Result := PathList;\r\n    // single entry with trailing ';'\r\n    // TODO address pathological case of multiple trailing ';' chars?\r\n    end else if Pos(Delim, SrcString) = Length(SrcString) then\r\n    begin\r\n      TmpPath := SrcString;\r\n      StringChangeEx(TmpPath, Delim, '', True);\r\n      PathList.Append(TmpPath);\r\n\r\n      Result := PathList;\r\n    end else\r\n    // multiple entries\r\n    begin\r\n      TmpPath := SrcString;\r\n      // clean up a leading ';' pathological case if it exists\r\n      if Pos(Delim, TmpPath) = 1 then TmpPath := Copy(TmpPath, 2, Length(TmpPath));\r\n      while (Pos(Delim, TmpPath) > 0) do\r\n      begin\r\n        PathList.Append(Copy(TmpPath, 1, Pos(Delim, TmpPath) - 1));\r\n        TmpPath := Copy(TmpPath, Pos(Delim, TmpPath) + 1, Length(TmpPath));\r\n      end;\r\n      // add final remaining dir if not empty due to trailing ';'\r\n      if Length(TmpPath) > 0 then PathList.Append(TmpPath);\r\n\r\n      Result := PathList;\r\n    end;\r\n  end;\r\nend;\r\n\r\nfunction ListToStr(const SrcList: TStringList; Delim: String): String;\r\nvar\r\n  Path: String;\r\n  I: Integer;\r\nbegin\r\n  for I := 0 to SrcList.Count - 1 do begin\r\n    if Length(Path) = 0 then\r\n    begin\r\n      Path := SrcList[I];\r\n      Continue;\r\n    end;\r\n    Path := Path + Delim + SrcList[I];\r\n  end;\r\n\r\n  Result := Path;\r\nend;\r\n\r\nfunction MungePathish(const SrcList: TStringList; NewData: Array of String;\r\n                      RegValue: String; IsUninstalling: Boolean): Boolean;\r\nvar\r\n  RootKey, I, N: Integer;\r\n  Item: String;\r\n  RegChangeFlag: Boolean;\r\nbegin\r\n  RegChangeFlag := False;\r\n  RootKey := GetUserHive;\r\n\r\n  for N := 0 to GetArrayLength(NewData) - 1 do\r\n  begin\r\n    Item := NewData[N];\r\n    if not IsUninstalling then  // installing...\r\n    begin\r\n      // update PathishList ONLY if new item isn't already in the list\r\n      // DO NOT ASSUME that the installer should duplicate entry or change order!\r\n      if SrcList.IndexOf(Item) = -1 then\r\n      begin\r\n        case AnsiUppercase(RegValue) of\r\n          'PATH': SrcList.Insert(0, Item);\r\n          'PATHEXT': SrcList.Add(AnsiUppercase(Item));\r\n        end;\r\n        RegChangeFlag := True;\r\n      end else  // already in existing config, no need for update; log it\r\n        Log(Item + ' already on ' + AnsiUppercase(RegValue) +\r\n          ' in original config; not modifying ' + AnsiUppercase(RegValue));\r\n    end else  // uninstalling...\r\n    begin\r\n      I := SrcList.IndexOf(Item);\r\n      if I <> -1 then  // found on PathishList, delete it\r\n      begin\r\n        SrcList.Delete(I);\r\n        RegChangeFlag := True;\r\n      end;  // not found on PathishList, no need for registry mod\r\n    end;\r\n  end;\r\n\r\n  Result := RegChangeFlag;\r\nend;\r\n"
  },
  {
    "path": "resources/scripts/config_check.rb",
    "content": "#!/usr/bin/env ruby\r\n\r\nrequire \"fileutils\"\r\n\r\nConfig =\r\n  {\r\n    :banner => \"\\n# Rails Environment Configuration.\\n\",\r\n    :git_config_incomplete => \"\\nYour git configuration is incomplete.\\nuser.name and user.email are required for properly using git and services such\\nas GitHub (https://github.com/).\\n\",\r\n    :git_name_prompt => \"\\n Please enter your name, for example mine is: Wayne E. Seguin\\nname > \",\r\n    :git_email_prompt => \"\\n Please enter your email address, for example mine is: wayneeseguin@gmail.com\\nemail > \",\r\n    :railsinstaller_path => File.dirname(File.dirname($0)),\r\n    :home        => File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"]),\r\n    :ssh_path    => File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"], \".ssh\"),\r\n    :ssh_key     => File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"], \".ssh\", \"id_rsa\"),\r\n    :ssh_pub_key => File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"], \".ssh\", \"id_rsa.pub\"),\r\n    :ssh_keygen  => File.join(File.dirname(File.dirname($0)), \"Git\", \"bin\", \"ssh-keygen.exe\"),\r\n    :git         => File.join(File.dirname(File.dirname($0)), \"Git\", \"bin\", \"git.exe\"),\r\n    :cat         => File.join(File.dirname(File.dirname($0)), \"Git\", \"bin\", \"cat.exe\")\r\n  }\r\n\r\n@notes = []\r\n\r\n#\r\n# Methods\r\n#\r\ndef run(command)\r\n  $stderr.puts \"Running #{command}\" if Config[:debug]\r\n  %x{#{command}}.chomp\r\nend\r\n\r\ndef generate_ssh_key\r\n  run %Q{#{Config[:ssh_keygen]} -f \"#{Config[:ssh_key]}\" -t rsa -b 2048 -N \"\" -C \"#{git_config(\"user.name\")} <#{git_config(\"user.email\")}>\"}\r\n\r\n  run %Q{clip < \"#{Config[:ssh_pub_key]}\"}\r\n\r\n  @notes << \"Your public ssh key (id_rsa.pub) has been automatically generated and copied to your clipboard.\"\r\nend\r\n\r\ndef git_config(key)\r\n  run %Q{#{Config[:git]} config --global #{key}}\r\nend\r\n\r\n#\r\n# Configuration\r\n#\r\nputs Config[:banner]\r\n\r\n[\"name\", \"email\"].each do |key|\r\n  while git_config(\"user.#{key}\").empty?\r\n    if Config[:git_config_incomplete]\r\n      puts Config[:git_config_incomplete]\r\n        Config[:git_config_incomplete] = nil\r\n      end\r\n\r\n    printf \"%s\", Config[\"git_#{key}_prompt\".to_sym]\r\n\r\n    value = gets.chomp\r\n    next if value.empty?\r\n    puts \"Setting user.#{key} to #{value}\"\r\n    run %Q{#{Config[:git]} config --global user.#{key} \"#{value}\"}\r\n  end\r\nend\r\n\r\nFileUtils.mkdir_p(Config[:ssh_path]) unless File.exist? Config[:ssh_path]\r\ngenerate_ssh_key                     unless File.exist? Config[:ssh_key]\r\n\r\n#\r\n# Emit Summary\r\n#\r\nputs \"\r\n---\r\ngit:\r\n  user.name:  #{git_config(\"user.name\")}\r\n  user.email: #{git_config(\"user.email\")}\r\n  version:    #{run \"git --version\"}\r\n\r\nruby:\r\n  bin:        #{File.join(Config[:railsinstaller_path], \"Ruby2.3.3\", \"bin\", \"ruby.exe\")}\r\n  version:    #{run \"ruby -v\"}\r\n\r\nrails:\r\n  bin:        #{File.join(Config[:railsinstaller_path], \"Ruby2.3.3\", \"bin\", \"rails.bat\")}\r\n  version:    #{run \"rails -v\"}\r\n\r\nssh:\r\n  public_key_location: #{Config[:ssh_pub_key]}\r\n  public_key_contents: #{File.open(Config[:ssh_pub_key], \"r\") { |file| file.read }}\r\n\r\n#{@notes.empty? ? \"\" : \"NOTES:\\n\\n  #{@notes.join(\"\\n  \")}\"}\r\n\r\n\"\r\n\r\nexit 0\r\n"
  },
  {
    "path": "resources/scripts/publickey.bat",
    "content": "@echo off\r\nif exist \"%HOMEDRIVE%%HOMEPATH%\\.ssh\\id_rsa.pub\" (\r\n  clip < \"%HOMEDRIVE%%HOMEPATH%\\.ssh\\id_rsa.pub\"\r\n  echo Your public ssh key has been copied to your clipboard.\r\n)\r\n@echo on\r\n"
  },
  {
    "path": "resources/scripts/setup_ssh.bat",
    "content": "@echo off\r\nif not exist \"%homedrive%%homepath%\\.ssh\" mkdir \"%homedrive%%homepath%\\.ssh\"\r\nif not exist \"%homedrive%%homepath%\\.ssh\\id_rsa.pub\" c:\\RailsInstaller\\Git\\bin\\ssh-keygen.exe -f \"%homedrive%%homepath%\\.ssh\\id_rsa\" -t rsa -N \"\"\r\n@echo on\r\n"
  },
  {
    "path": "resources/scripts/sshkey",
    "content": "#!/usr/bin/env ruby\r\n\r\npub_key_file = File.join(ENV[\"HOMEDRIVE\"], ENV[\"HOMEPATH\"], \".ssh\", \"id_rsa\", \"pub\")\r\n\r\nssh_pub_key = File.open(pub_key_file, 'r') { |file| file.read }\r\n\r\n%x{echo #{ssh_pub_key} | clip}\r\n"
  },
  {
    "path": "resources/scripts/sshkey.bat",
    "content": "@ECHO OFF\r\nIF NOT \"%~f0\" == \"~f0\" GOTO :WinNT\r\n@\"ruby.exe\" \"C:/Projects/railsinstaller/stage/Ruby2.0.0/bin/sshkey\" %1 %2 %3 %4 %5 %6 %7 %8 %9\r\nGOTO :EOF\r\n:WinNT\r\n@\"ruby.exe\" \"%~dpn0\" %*\r\n"
  }
]