version snippets

Ignoring columns with acts_as_versioned

Tagged acts_as_versioned, version, exclude  Languages ruby
def Model

  @@versioned_columns = [:title, :body, :rendered_body, :user_id]  
  acts_as_versioned :if_changed => @@versioned_columns

  def self.non_versioned_columns
      self.class.columns.collect(&:name) - @@versioned_columns

Reading gem version from YAML

Tagged gem, rubygem, version, jeweler  Languages ruby

From Jekyll:

module YerGem
  def self.version
    yml = YAML.load(, *%w[.. VERSION.yml])))

How to get the latest version number from a list of git tags

Tagged bash, git, version, zsh  Languages bash

This will print the latest version number that a git repository has been tagged with:

$ git tag -l 'v*' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1

Note that some versions of the sort command have a —version-sort switch, and some don’t:

sort: unrecognized option `--version-sort'
Try `sort --help' for more information.

Detecting software version with Ansible

Tagged ansible, version  Languages yaml

With Ansible, detecting the version of, for example, Redis or Racket can be done like this:

- name: Detect Redis version
  # Input: Redis server v=3.2.1 sha=00000000:0 malloc=libc bits=64 build=62a67eec83b28403
  # Output: 3.2.1
  shell: redis-server -v | awk '{print $3}' | sed -e 's/v=//'
  changed_when: False
  register: redis_installed_version

- name: Detect racket versions
  # Input: Welcome to Racket v6.6.
  # Output: 6.6
  shell: "racket -v | rev | cut -d ' ' -f1 | rev | sed 's/.$//' | sed 's/^v//'"
  register: racket_installed_version

Example: Download src only if version does not match:

- get_url:
    dest: /usr/local/src/
    sha256sum: "{{redis_sha256}}"
  register: get_redis_result
  when: redis_installed_version.stdout | version_compare(redis_version, '!=')

Which version of Ruby to use with Rails?

Tagged rails, ruby, version  Languages 

To know which version of Ruby is safe to use with Rails one option is to look at the Travis configuration, for example, Rails 5.2:

Note the allowed_failures configuration:

This works for Rubygems too: