Class: Woody

Inherits:
Object
  • Object
show all
Includes:
Compiler, Deployer, Generator
Defined in:
lib/woody.rb,
lib/woody/post.rb,
lib/woody/episode.rb,
lib/woody/version.rb,
lib/woody/compiler.rb,
lib/woody/deployer.rb,
lib/woody/generator.rb

Overview

Woody podcast static site generator

Defined Under Namespace

Modules: Compiler, Deployer, Generator Classes: Episode, Post

Constant Summary collapse

VERSION =

Specifies Woody gem version

"0.4.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Deployer

#deploy

Methods included from Compiler

#compile

Methods included from Generator

new_site, update_templates

Constructor Details

#initialize(directory = ".") ⇒ Woody

Load configuration and connect to S3



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/woody.rb', line 33

def initialize(directory = ".")
  @directory = directory
  @touchedfiles = []
  @s3touchedobjects = []



  begin
    @config = YAML.load_file(dir("woody-config.yml"))
  rescue Errno::ENOENT
    puts "This doesn't look like a valid Woody site directory!"
    exit!
  end

  # Strip trailing slash from urlbase, if present.
  if @config['urlbase'].end_with? "/"
    @config['urlbase'] = @config['urlbase'][0..-2]
  end

  if @config['distributiontype'] == "s3"
    prefix = @config['s3']['prefix']
    unless prefix.nil?
      @config['urlbase'] = @config['urlbase'] + "/" + prefix
    end
  end

  s3options = {
    :access_key_id     => @config['s3']['accesskey']['id'],
    :secret_access_key => @config['s3']['accesskey']['secret']
  }
  
  unless ENV['http_proxy'].nil?
    uri = URI(ENV['http_proxy'])
    p = Hash.new
    p[:host]     = uri.host
    p[:port]     = uri.port
    p[:user]     = uri.user     unless uri.user.nil?
    p[:password] = uri.password unless uri.password.nil?
    s3options[:proxy] = p
  end
  
  AWS::S3::Base.establish_connection!(s3options)
  AWS::S3::DEFAULT_HOST.replace @config['s3']['hostname']
  @bucketname = @config['s3']['bucket']
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



79
80
81
# File 'lib/woody.rb', line 79

def config
  @config
end

#directoryObject (readonly)

Returns the value of attribute directory.



80
81
82
# File 'lib/woody.rb', line 80

def directory
  @directory
end

Instance Method Details

#dir(dir = "") ⇒ Object



82
83
84
# File 'lib/woody.rb', line 82

def dir(dir="")
  File.expand_path(File.join(@directory, dir))
end

#undir(string) ⇒ Object



86
87
88
# File 'lib/woody.rb', line 86

def undir(string)
  string[dir.length+1..-1]
end

#update_templatesObject



90
91
92
# File 'lib/woody.rb', line 90

def update_templates
  Generator::update_templates(self)
end