Skip to content

Commit

Permalink
complete refactor for new name
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflint committed Jun 15, 2015
1 parent e5afadb commit e616f3c
Show file tree
Hide file tree
Showing 50 changed files with 157 additions and 164 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in hooky.gemspec
# Specify your gem's dependencies in hookit.gemspec
gemspec
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Hooky
# Hookit

Hooky is the framework to provide hooky scripts with re-usable components and resources via an elegant dsl
Hookit is the framework to provide hookit scripts with re-usable components and resources via an elegant dsl
13 changes: 3 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
require "bundler/gem_tasks"

desc "Create tag v#{Hooky::VERSION}"
desc "Create tag v#{Hookit::VERSION}"
task :tag do

puts "tagging version v#{Hooky::VERSION}"
`git tag -a v#{Hooky::VERSION} -m "Version #{Hooky::VERSION}"`
puts "tagging version v#{Hookit::VERSION}"
`git tag -a v#{Hookit::VERSION} -m "Version #{Hookit::VERSION}"`
`git push origin --tags`

end

desc "Create tag v#{Hooky::VERSION} and build and push hooky-#{Hooky::VERSION}.gem to Gemfury"
task :fury => [:tag, :build] do

puts `fury push pkg/hooky-#{Hooky::VERSION}.gem`

end
8 changes: 4 additions & 4 deletions bin/hooky → bin/hookit
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby

MODULE_DIR = ENV['MODULE_DIR'] || "/opt/local/hooky/mod"
MODULE_DIR = ENV['MODULE_DIR'] || "/opt/local/hookit/mod"
LOG_LEVEL = ENV['LOG_LEVEL'] || :error
LOGFILE = ENV['LOGFILE'] || '/var/log/hooky/hooky.log'
LOGFILE = ENV['LOGFILE'] || '/var/log/hookit/hookit.log'

hook = ARGV.shift

Expand All @@ -15,10 +15,10 @@ end
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'hooky'
require 'hookit'
require 'json'

include Hooky::Hook # payload helpers / resource dsl
include Hookit::Hook # payload helpers / resource dsl

set :log_level, LOG_LEVEL
set :logfile, LOGFILE
Expand Down
10 changes: 5 additions & 5 deletions hooky.gemspec → hookit.gemspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hooky/version'
require 'hookit/version'

Gem::Specification.new do |spec|
spec.name = "hooky"
spec.version = Hooky::VERSION
spec.name = "hookit"
spec.version = Hookit::VERSION
spec.authors = ["Tyler Flint", "Greg Linton"]
spec.email = ["[email protected]"]
spec.summary = %q{Hooky is a framework to provide hooky scripts with re-usable components and resources via an elegant dsl.}
spec.description = %q{The core framework to provide hooky scripts with re-usable components.}
spec.summary = %q{Hookit is a framework to provide hookit scripts with re-usable components and resources via an elegant dsl.}
spec.description = %q{The core framework to provide hookit scripts with re-usable components.}
spec.homepage = ""
spec.license = "MIT"

Expand Down
27 changes: 27 additions & 0 deletions lib/hookit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'hookit/converginator'
require 'hookit/db'
require 'hookit/error'
require 'hookit/exit'
require 'hookit/helper'
require 'hookit/hook'
require 'hookit/logger'
require 'hookit/logvac'
require 'hookit/platform'
require 'hookit/registry'
require 'hookit/resource'
require "hookit/version"

module Hookit
extend self

def resources
@resources ||= Hookit::Registry.new
end

def platforms
@platforms ||= Hookit::Registry.new
end
end

require 'hookit/resources'
require 'hookit/platforms'
2 changes: 1 addition & 1 deletion lib/hooky/converginator.rb → lib/hookit/converginator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
class Converginator

def initialize(map, list)
Expand Down
4 changes: 2 additions & 2 deletions lib/hooky/db.rb → lib/hookit/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require 'multi_json'
require 'fileutils'

module Hooky
module Hookit
class DB

DEFAULT_PATH = '/var/db/hooky/db.json'
DEFAULT_PATH = '/var/db/hookit/db.json'

def initialize(path=nil)
@path = path || DEFAULT_PATH
Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/error.rb → lib/hookit/error.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Error
class UnexpectedExit < StandardError; end
class UnknownAction < StandardError; end
Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/exit.rb → lib/hookit/exit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Exit
SUCCESS = 0
ERROR = 1
Expand Down
9 changes: 9 additions & 0 deletions lib/hookit/helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'hookit/helper/nfs'
require 'hookit/helper/shell'
require 'hookit/helper/xml'
require 'hookit/helper/cron'

module Hookit
module Helper
end
end
2 changes: 1 addition & 1 deletion lib/hooky/helper/cron.rb → lib/hookit/helper/cron.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Helper
module Cron

Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/helper/nfs.rb → lib/hookit/helper/nfs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Helper
module NFS

Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/helper/shell.rb → lib/hookit/helper/shell.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Helper
module Shell

Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/helper/xml.rb → lib/hookit/helper/xml.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Helper
module XML

Expand Down
12 changes: 6 additions & 6 deletions lib/hooky/hook.rb → lib/hookit/hook.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'oj'
require 'multi_json'

module Hooky
module Hookit
module Hook

def payload
Expand Down Expand Up @@ -29,7 +29,7 @@ def registry(key, value=nil)
end

def db
@db ||= Hooky::DB.new
@db ||= Hookit::DB.new
end

def dict
Expand All @@ -49,11 +49,11 @@ def log(level, message)
end

def logger
@logger ||= Hooky::Logger.new(get(:logfile), get(:log_level))
@logger ||= Hookit::Logger.new(get(:logfile), get(:log_level))
end

def logvac
@logvac ||= Hooky::Logvac.new({
@logvac ||= Hookit::Logvac.new({
app: payload[:app][:id],
token: payload[:app][:logvac_token],
deploy: payload[:deploy][:id]
Expand All @@ -65,7 +65,7 @@ def platform
end

def detect_platform
Hooky.platforms.each do |key, value|
Hookit.platforms.each do |key, value|
platform = value.new
if platform.detect?
return platform
Expand All @@ -76,7 +76,7 @@ def detect_platform

# awesome resource-backed dsl
def method_missing(method_symbol, *args, &block)
resource_klass = Hooky.resources.get(method_symbol)
resource_klass = Hookit.resources.get(method_symbol)
if resource_klass
resource = resource_klass.new(*args)
resource.dict = dict
Expand Down
4 changes: 2 additions & 2 deletions lib/hooky/logger.rb → lib/hookit/logger.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Hooky
module Hookit
class Logger

attr_reader :log_file, :log_level

def initialize(file, level)
@log_file = file || '/var/log/hooky/hooky.log'
@log_file = file || '/var/log/hookit/hookit.log'
@log_level = level || :error
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/logvac.rb → lib/hookit/logvac.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'faraday'

module Hooky
module Hookit
class Logvac

def initialize(opts)
Expand Down
9 changes: 9 additions & 0 deletions lib/hookit/platform.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'hookit/platform/base'
require 'hookit/platform/smartos'
require 'hookit/platform/ubuntu'

module Hookit
module Platform

end
end
2 changes: 1 addition & 1 deletion lib/hooky/platform/base.rb → lib/hookit/platform/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Platform
class Base

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Platform
class Smartos < Base

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Platform
class Ubuntu < Base

Expand Down
2 changes: 2 additions & 0 deletions lib/hookit/platforms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hookit.platforms.register(:smartos) { Hookit::Platform::Smartos }
Hookit.platforms.register(:ubuntu) { Hookit::Platform::Ubuntu }
2 changes: 1 addition & 1 deletion lib/hooky/registry.rb → lib/hookit/registry.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
# Register components in a single location that can be queried.
#
# This allows certain components (such as guest systems, configuration
Expand Down
21 changes: 21 additions & 0 deletions lib/hookit/resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'hookit/resource/base'
require 'hookit/resource/directory'
require 'hookit/resource/execute'
require 'hookit/resource/file'
require 'hookit/resource/hook_file'
require 'hookit/resource/link'
require 'hookit/resource/logrotate'
require 'hookit/resource/mount'
require 'hookit/resource/package'
require 'hookit/resource/rsync'
require 'hookit/resource/socket'
require 'hookit/resource/scp'
require 'hookit/resource/service'
require 'hookit/resource/template'
require 'hookit/resource/zfs'

module Hookit
module Resource

end
end
6 changes: 3 additions & 3 deletions lib/hooky/resource/base.rb → lib/hookit/resource/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Resource
class Base

Expand Down Expand Up @@ -61,7 +61,7 @@ def action(*actions)
if actions.any?
actions.each do |action|
if not self.class.actions.include? action
raise Hooky::Error::UnknownAction, "unknown action '#{action}'"
raise Hookit::Error::UnknownAction, "unknown action '#{action}'"
end
end
@actions = *actions
Expand Down Expand Up @@ -96,7 +96,7 @@ def run_command!(cmd, expect_code=0)
`#{cmd}`
code = $?.exitstatus
if code != expect_code
raise Hooky::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/resource/cron.rb → lib/hookit/resource/cron.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Resource
class Cron < Execute

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Resource
class Directory < Base

Expand Down Expand Up @@ -35,7 +35,7 @@ def create!
`#{cmd}`
code = $?.exitstatus
if code != 0
raise Hooky::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
end
end

Expand All @@ -45,7 +45,7 @@ def delete!
`#{cmd}`
code = $?.exitstatus
if code != 0
raise Hooky::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'"
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'timeout'

module Hooky
module Hookit
module Resource
class Execute < Base

Expand Down Expand Up @@ -140,7 +140,7 @@ def env_string(key, val)
end

def unexpected_exit(res)
raise Hooky::Error::UnexpectedExit, "'#{name}' exited with #{res}, expected #{returns}" unless ignore_exit
raise Hookit::Error::UnexpectedExit, "'#{name}' exited with #{res}, expected #{returns}" unless ignore_exit
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/hooky/resource/file.rb → lib/hookit/resource/file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Resource
class File < Base

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Hooky
module Hookit
module Resource
class HookFile < Base

Expand Down
Loading

0 comments on commit e616f3c

Please sign in to comment.