Cucumber-chef with rbenv

Info on rbenv
http://dan.carley.co/blog/2012/02/07/rbenv-and-bundler/


install: –no-rdoc –no-ri
update: –no-rdoc –no-ri

view raw

.gemrc

hosted with ❤ by GitHub


# deinstall rvm (if installed)
$ rvm implode
# remove ruby packages
apt-get update
apt-cache search libruby
# example remove ruby
sudo apt-get –purge remove libruby1.8 libruby1.9.1 ruby ruby1.8 ruby1.8-dev ruby1.9.1
# needed packages (further on)
sudo apt-get install build-essential \
libreadline-dev \
libssl-dev \
zlib1g-dev \
libxslt-dev \
libxml2-dev
# install rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# set PATH
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# load PATH
source ~/.bashrc
# open new shell
exec $SHELL -l
# plugins: https://github.com/sstephenson/rbenv/wiki/Plugins
# remove plugin "carsomyr/rbenv-bundler" if previous installed.
rm -rf ~/.rbenv/plugins/bundler
# install plugin: rbenv-update plugin
git clone https://github.com/rkh/rbenv-update.git ~/.rbenv/plugins/rbenv-update
rbenv update
# install plugin: ruby-build
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# install plugin: rbenv-gem-rehash
git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
# list all available versions:
$ rbenv install -l
# install ruby version
$ rbenv install 1.9.3-p448
$ rbenv rehash
$ rbenv shell 1.9.3-p448
$ rbenv global 1.9.3-p448
$ rbenv rehash
# show rbenv versions
$ rbenv versions
$ ruby -v
# do NOT use sudo for gem install
# update RubyGems system
$ gem update –system
# list gems installed
$ gem query –local
# update existing gems (if you are upgrading)
$ gem update
$ rbenv rehash
# bundler
$ gem install bundler
# install binstubs plugin
$ git clone https://github.com/ianheggie/rbenv-binstubs.git ~/.rbenv/plugins/rbenv-binstubs
# binstubs usage; (not needed in this tutorial).
$ cd application-directory
$ bundle install –binstubs .bundle/bin
# berkshelf
$ gem install berkshelf
# foodcritic
$ gem install foodcritic
# chef
$ gem install chef
# pry
$ gem install pry
# if fails with doc error
#gem install pry –no-rdoc –no-ri
# cucumber-chef
$ gem install cucumber-chef

view raw

fast-rbenv.sh

hosted with ❤ by GitHub

Code Review – ideas

What this post is about (and what not):

is not Develoment Guide, ill create an other document about Continuous integration, Testing, version control (which you already have, else you dont have anything to review, or you wont have), etc.

is not a Coding Standard, because there are already good tools which can format your code according to definable standards, this document does not apply the usual Coding Standard.

In that case it should actually called Code Design Standard, while this is not a standard
ill keep it under Code Review, because most ideas come from code review.

Code Design

Which concepts are important in code design:

  • Consistency
  • Maintainability
  • Readability
  • Re-usability
  • Security

These concepts are closely connected:
without consistency and readability, it should be hard to design your code to be maintainable.


lets start with some of the ideas;


Names

  • Only a developer who understands the system as a whole can create a name that “fits” within this system.
  • If the name is appropriate everything fits together naturally, relationships are clear, meaning is derivable, and reasoning from common human expectations works as expected.

Variable names

  • Names should be concise, but also descriptive.  (typeless is not the same as meaningless).
  • PHP has typeless variables, hungarian notation is not quite usefull.
  • Avoid reassigning a variable with an other meaning (unless the name describes this beforehand)

Method / Function Names

  • Usually a method / function performs an action, so the name should describe this: CheckForErrors() instead of ErrorCheck(),
  • Do not do real work in constructors: only initialize variables only and/or do actions that can’t fail.

PHP 5.3 snapshot installed on Ubuntu/Debian

describing installation of PHP 5.3 on a test/development machine (AMD64) at home.


[updated]17-06-2010: removed –with-curl-wrappers from the configuration
[updated]18-12-2011: added –enable-pcntl to the configuration


(12 June 2010): used http://ishare.nu/wiki/index.php/Php5.3_on_ubuntuas a lead. (but had to change some tasks to get through).

  • First removed all previous PHP implementations. (this was necessay in my case, because of 3 or 4 previous installations).
  • added several needed libraries by apt-get (check the commands below), i call apt several times for smaller statements (for debugging).
  • downloaded a snapshot from http://snaps.php.net/:

install several packages/libraries.

[shell]
apt-get update
apt-get upgrade
apt-get install checkinstall build-essential
apt-get install t1lib-bin
apt-get install libcurl4-openssl-dev
apt-get install libcurl4-gnutls-dev
apt-get install apache2 apache2-prefork-dev apache2-mpm-prefork apache2-utils aspell curl libaspell-dev libbz2-dev libc-client-dev libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libmcrypt4 libmcrypt-dev libmhash2 libmhash-dev libming-dev libmysqlclient15-dev libncurses-dev libpng3 libpng12-dev libpspell-dev libreadline-dev libsasl2-dev libsnmp-dev libt1-5 libt1-dev libtidy-dev libxml2 libxml2-dev libxml2-utils libxpm4 libxpm-dev libxslt1-dev make mysql-client-5.0 mysql-server-5.0
[/shell]

get snapshot and extract the files.

[shell]
# goto local dir.
cd /usr/local/

# get a php-5.3 snapshot
wget http://www.php.net/get/php-5.3.0.tar.gz/from/this/mirror

# unpack snapshot (eXtract gZip from File)
tar -xzf php-5.3.0.tar.gz

# enter the archive
cd php-5.3.0/
[/shell]

configure php5.3

[shell]
./configure
–with-apxs2=/usr/bin/apxs2
–with-config-file-path=/etc/php5/
–with-config-file-scan-dir=/etc/php5/conf.d
–with-pear=/usr/share/php
–with-freetype-dir=/usr/lib
–with-openssl
–with-jpeg-dir=/usr/lib
–with-png-dir=/usr/lib
–with-xpm-dir=/usr/lib
–with-zlib
–with-bz2=/bin/bzip2
–enable-bcmath
–enable-calendar
–with-curl
–enable-exif
–enable-ftp
–with-gd
–with-t1lib
–enable-gd-native-ttf
–enable-gd-jis-conv
–with-gettext
–with-imap
–with-imap-ssl
–with-ldap
–with-ldap-sasl
–enable-mbstring
–with-mcrypt
–with-mhash
–with-mysql=mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql
–with-pspell
–with-readline
–with-snmp
–enable-soap
–enable-sockets
–without-sqlite
–enable-sqlite-utf8
–with-tidy
–enable-wddx
–with-xmlrpc
–with-xsl
–enable-zip
–with-kerberos
–enable-pcntl
[/shell]

to use the axps-extension, we need updated httpd.conf

[shell]
cd /etc/apache2/
cp -pr apache2.conf httpd.conf

#
cp -pr httpd.conf backup-20100612__httpd.conf

# prepare httpd.conf (not used by my apache2 installation)
echo ‘# LoadModule placeholder for apxs-extension in php5.3’ > /etc/apache2/httpd.conf;
echo ‘LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so’ >> /etc/apache2/httpd.conf;

[/shell]

make build

[shell]
#build php5.3
cd /usr/local/php-5.3.0
make
[/shell]

install build

[shell]
# install php5.3
make install

[/shell]

install libtool

[shell]

# completes the installation of libtool files.
libtool –finish /usr/local/php-5.3.0/libs

# create php5.conf
echo ‘
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
‘ > /etc/apache2/mods-available/php5.conf

# create php5.load
echo ‘LoadModule php5_module /usr/lib/apache2/modules/libphp5.so’ > /etc/apache2/mods-available/php5.load

# copy the backup over the invalid httpd.conf & move the backup file to a known backup location.
echo ‘# empty user config apache2’ > /etc/apache2/httpd.conf

[/shell]