Project

ncupdater

0.0
No commit activity in last 3 years
No release in over 3 years
A small handy upgrade tool for ruby scripts. just provide a version file, and a url for latest version, and the script will handle the rest
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ncupdater

Gem Version

NCUpdater provides you with an easy way to update your ruby scripts. You specify a link to a small text file with latest version number, and the path of a .semver file in your project. It will then check for updates every time your project starts. You can run update with a list of commands you would like to run.

Install

gem install ncupdater

Example

Basic usage

Example 1

This example will run the update when the script starts

require 'ncupdater'

# Define commands to run the update
commands = {
    :'Gem update' => 'gem update my-command',
    :'Some other command' => 'ls -la'
}

# Init the NCUpdater class
# .semver is path to the location of a file with the local version in the semver format (http://semver.org/)
# The url is to a link with a text file with the latest version in semver format.
ncupdater = NCUpdater::new('.semver', 'http://LINK-TO-A-TEXT-FILE-WITH-NEW-VERSION', commands)

if ncupdater::new_version?
    ncupdater::update
end

Example 2

This example will run the update if you provide "update" as first argument of your script. It also shows a message when the script starts that there are a newer version

require 'ncupdater'

# Define commands to run the update
commands = {
    :'Gem update' => 'gem update my-command',
    :'Some other command' => 'ls -la'
}

# Init the NCUpdater class
# .semver is path to the location of a file with the local version in the semver format (http://semver.org/)
# The url is to a link with a text file with the latest version in semver format.
ncupdater = NCUpdater::new('.semver', 'http://LINK-TO-A-TEXT-FILE-WITH-NEW-VERSION', commands)

if ncupdater::new_version?
    puts 'A new version is available. Please run the command as: ruby <my-script>.rb update to get the latest awesomeness'
end

if ARGV[0] == 'update'
    ncupdater::update
end

Todo

  • Write some tests
  • Write doc blocks
  • Better error handling