Skip to content

Instantly share code, notes, and snippets.

@yosiat
Last active August 29, 2015 14:13
Show Gist options
  • Save yosiat/cdb19ee29172da6b8031 to your computer and use it in GitHub Desktop.
Save yosiat/cdb19ee29172da6b8031 to your computer and use it in GitHub Desktop.
#!/bin/sh
<<DOCUMENTATION
Pack
-----
The idea for pack is to use devdocs in offline environment (without internet :( )
and in windows.
Pack steps:
1. We use the latest ruby installation available in windowws
2. Replacing yajl with json and replacing thin with webrick, because it takes too much to get it compiled on windows
3. Bundle package
DOCUMENTATION
# checkout all changes
echo "[*] Checking out gemfile and lib directory"
git checkout Gemfile
git checkout lib/
# remove vendor
echo "[*] Removing vendor directory"
rm -rf vendor/
# fetch the changes and show them
echo "[*] Fetching latest changes.."
git fetch
local_head=`git log --format="%H" -n 1`
remote_head=`git log remotes/origin/master --format="%H" -n 1`
if [ "$remote_head" = "$local_head" ]
then
echo "[*] Remote head ($remote_head) and local head ($local_head) are the same.."
else
git log $remote_head..$local_head --pretty=oneline
echo "[*] Removing backup files"
find . -name '*.bkp' | xargs rm
# Downgrade to ruby 2.1.5 (when RailsInstaller will support 2.2.0, will move
# to 2.2.0)
echo "[*] Downgrading to ruby 2.1.5"
sed -i.bkp "s/ruby '2.2.0'/ruby '2.1.5'/" Gemfile
# Remove thin, webrick is fine at our scale ;)
sed -i.bkp "s/gem 'thin'.*//" Gemfile
# yajl
echo "[*] Moving from yajl to built-in json in ruby"
sed -i.bkp "s/gem 'yajl-ruby'.*//" Gemfile
find ./lib -name '*.rb' | xargs sed -i.bkp "s/yajl\/json_gem/json/"
# bundle install and download the docs..
echo "[*] Bundle install"
bundle install
echo "[*] Removing all docs"
bundle exec thor docs:clean
echo "[*] Downloading the docs"
bundle exec thor docs:download --all
# bundle package
echo "[*] Bundle package"
bundle package
echo "[*] Finish.. now zip and copy to DOK"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment