Sha256: 5d75c29184a9d2f511d0fcc8319c6c347e23182680fb18a64cbd3cc4dc6ff940
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'yaml' LOCK_FILE = 'Bukfile.lock' class Bukin::Lockfile def initialize(*) if File.exist?(LOCK_FILE) @lockfile = YAML::load_file(LOCK_FILE) else @lockfile = { 'server' => {}, 'plugins' => {} } end end def set_server(data) self.server = { 'name' => data[:name], 'version' => data[:version], 'file' => data[:file] } end def add_plugin(data) self.plugins[data[:name]] = { 'version' => data[:version], 'files' => data[:files] || [data[:file]] } save end def add(type, data) case type when :server set_server(data) when :plugin add_plugin(data) else raise(ArgumentError, "You must specify :server or :plugin as the type when adding to a lock file") end end def remove_plugin(name) plugins.delete(name) save end def plugins @lockfile['plugins'] end def server @lockfile['server'] end def server=(value) @lockfile['server'] = value save end def save File.open(LOCK_FILE, "w") {|file| file.write @lockfile.to_yaml} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bukin-0.5.0 | lib/bukin/lockfile.rb |
bukin-0.4.0 | lib/bukin/lockfile.rb |
bukin-0.3.0 | lib/bukin/lockfile.rb |