class MonkeyButler::Project
Attributes
config[RW]
database_url[RW]
name[RW]
targets[RW]
Public Class Methods
clear()
click to toggle source
# File lib/monkey_butler/project.rb, line 20 def clear @project = nil end
load(path = Dir.pwd)
click to toggle source
# File lib/monkey_butler/project.rb, line 7 def load(path = Dir.pwd) @project ||= proc do project_path = File.join(path, '.monkey_butler.yml') raise "fatal: Not a monkey_butler repository: no .monkey_butler.yml" unless File.exists?(project_path) options = YAML.load(File.read(project_path)) new(options) end.call end
new(options = {})
click to toggle source
# File lib/monkey_butler/project.rb, line 27 def initialize(options = {}) options.each { |k,v| send("#{k}=", v) } end
set(options)
click to toggle source
# File lib/monkey_butler/project.rb, line 16 def set(options) @project = new(options) end
Public Instance Methods
database()
click to toggle source
# File lib/monkey_butler/project.rb, line 35 def database database_url.scheme || 'sqlite' end
database_class()
click to toggle source
# File lib/monkey_butler/project.rb, line 78 def database_class MonkeyButler::Util.database_named(database) end
database_target_class()
click to toggle source
# File lib/monkey_butler/project.rb, line 82 def database_target_class MonkeyButler::Util.target_classes_named(database)[0] end
database_url=(database_url)
click to toggle source
# File lib/monkey_butler/project.rb, line 31 def database_url=(database_url) @database_url = database_url ? URI(database_url) : nil end
git_current_branch()
click to toggle source
# File lib/monkey_butler/project.rb, line 55 def git_current_branch `git symbolic-ref --short HEAD`.chomp end
git_latest_tag()
click to toggle source
# File lib/monkey_butler/project.rb, line 51 def git_latest_tag git_tag_for_version(nil) end
git_tag_for_version(version)
click to toggle source
# File lib/monkey_butler/project.rb, line 59 def git_tag_for_version(version) pattern = version && "#{version}*" tag = `git tag -l --sort=-v:refname #{pattern} | head -n 1`.chomp tag.empty? ? nil : tag end
git_url()
click to toggle source
# File lib/monkey_butler/project.rb, line 47 def git_url `git config remote.origin.url`.chomp end
git_user_email()
click to toggle source
# File lib/monkey_butler/project.rb, line 65 def git_user_email `git config user.email`.chomp end
git_user_name()
click to toggle source
# File lib/monkey_butler/project.rb, line 69 def git_user_name `git config user.name`.chomp end
migrations_path()
click to toggle source
# File lib/monkey_butler/project.rb, line 43 def migrations_path "migrations" end
save!(path)
click to toggle source
# File lib/monkey_butler/project.rb, line 73 def save!(path) project_path = File.join(path, '.monkey_butler.yml') File.open(project_path, 'w') { |f| f << YAML.dump(self.to_hash) } end
schema_path()
click to toggle source
# File lib/monkey_butler/project.rb, line 39 def schema_path "#{name}" + database_class.migration_ext end
to_hash()
click to toggle source
# File lib/monkey_butler/project.rb, line 86 def to_hash { "name" => name, "config" => config, "database_url" => database_url.to_s, "targets" => targets } end