Skip to content

Commit

Permalink
whitespace wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
tcurdt committed Aug 11, 2012
1 parent 78a4400 commit 7f529fe
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/awestruct/astruct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(hash=nil)
def inspect
"AStruct{...}"
end

end

end
6 changes: 3 additions & 3 deletions lib/awestruct/astruct_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class << o
end

def cascade_for_nils!
@cascade_for_nils = true
@cascade_for_nils = true
self
end

Expand All @@ -40,7 +40,7 @@ def method_missing(sym, *args, &blk)
if key?(name)
self[name]
elsif @cascade_for_nils
self[name] = AStruct.new.cascade_for_nils!
self[name] = AStruct.new.cascade_for_nils!
self[name]
else
nil
Expand Down Expand Up @@ -75,7 +75,7 @@ def transform_entry(for_key, entry)
def inspect
"AStruct{...}"
end

end

end
8 changes: 4 additions & 4 deletions lib/awestruct/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class Config
attr_accessor :stylesheets_dir

def initialize(dir = Dir.pwd)
@dir = Pathname.new( dir )
@dir = Pathname.new( dir )
@layouts_dir = Pathname.new( File.join(dir, '_layouts') )
@config_dir = Pathname.new( File.join(dir, '_config') )
@input_dir = Pathname.new( File.join(dir, '') )
@output_dir = Pathname.new( File.join(dir, '_site') )
@extension_dir = Pathname.new( File.join(dir, '_ext') )
@skin_dir = Pathname.new( File.join(dir, '_skin') )
@tmp_dir = Pathname.new( File.join(dir, '_tmp') )
@tmp_dir = Pathname.new( File.join(dir, '_tmp') )

@images_dir = Pathname.new( File.join(dir, 'images') )
@stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
@images_dir = Pathname.new( File.join(dir, 'images') )
@stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )

@ignore = File.exists?(ignore_file = File.join(dir, ".awestruct_ignore")) ? Dir[*IO.read(ignore_file).each_line.map(&:strip)] : []

Expand Down
10 changes: 5 additions & 5 deletions lib/awestruct/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class Context < Awestruct::AStruct
attr_accessor :page

def initialize(hash)
super
super
@page = hash[:page]
@site = hash[:site]
end

end

def inspect
"Awestruct::Context{:page=>#{self.page.inspect}}"
end
"Awestruct::Context{:page=>#{self.page.inspect}}"
end
end

end
16 changes: 8 additions & 8 deletions lib/awestruct/extensions/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ def asset(href)
if site.assets_url
File.join(site.assets_url, href)
else
relative(File.join("/#{site.assets_path || 'assets'}", href))
relative(File.join("/#{site.assets_path || 'assets'}", href))
end
end

class Extension

def execute(site)
site.pages.each{ |p| p.extend Extension }
def execute(site)
site.pages.each{ |p| p.extend Extension }
end

module Extension
module Extension

include Awestruct::Extensions::Relative
include Awestruct::Extensions::Relative

def assets_url
path = File.join("/#{site.assets_path || 'assets'}", File.join(File.dirname(output_path), File.basename(output_path, '.*')))
relative(path, self)
def assets_url
path = File.join("/#{site.assets_path || 'assets'}", File.join(File.dirname(output_path), File.basename(output_path, '.*')))
relative(path, self)
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions lib/awestruct/extensions/cachebuster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ module Extensions
module Cachebuster

def cache(href)
"#{href}?#{cachebuster}"
"#{href}?#{cachebuster}"
end

class Extension

def execute(site)
site.pages.each{ |p| p.extend Extension }
end
def execute(site)
site.pages.each{ |p| p.extend Extension }
end

module Extension
def cachebuster
((site.timestamp || page.input_mtime || Time.now.to_i) / 1000).to_i.to_s
end
end
module Extension
def cachebuster
((site.timestamp || page.input_mtime || Time.now.to_i) / 1000).to_i.to_s
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/awestruct/extensions/disqus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def disqus_comments_count()
}
end

private
private

def resolve_disqus_identifier()
self.disqus_identifier ? self.disqus_identifier : Digest::SHA1.hexdigest(self.date.strftime('%Y-%m-%d-') + self.slug)
Expand Down
26 changes: 13 additions & 13 deletions lib/awestruct/extensions/gsub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ class Gsub

def initialize(pattern, replacement, options = {})
@pattern = pattern
@replacement = replacement.is_a?(Proc) ? replacement : lambda { |site, page| replacement }
@gsub_required = lambdaize(options[:gsub_required])
@replacement = replacement.is_a?(Proc) ? replacement : lambda { |site, page| replacement }
@gsub_required = lambdaize(options[:gsub_required])
end

def transform(site, page, rendered)
if (@gsub_required.call(site, page))
replacement = @replacement.call(site, page).to_s
rendered = rendered.gsub(@pattern, replacement)
replacement = @replacement.call(site, page).to_s
rendered = rendered.gsub(@pattern, replacement)
end
rendered
end

private

def lambdaize(param)
if param.nil?
lambdaize([".html"])
else
if param.is_a?(Array)
lambda { |site, page| param.any?{ |ext| page.output_path.end_with?(ext) } }
else
param
end
end
if param.nil?
lambdaize([".html"])
else
if param.is_a?(Array)
lambda { |site, page| param.any?{ |ext| page.output_path.end_with?(ext) } }
else
param
end
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/awestruct/extensions/paginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def initialize(prop_name, input_path, opts={})
@window_size = opts[:window_size] || 2
@remove_input = opts.has_key?( :remove_input ) ? opts[:remove_input] : true
@output_prefix = opts[:output_prefix] || File.dirname( @input_path )
@page_name = opts[:page_name] || 'page/'
@page_name = opts[:page_name] || 'page/'
@collection = opts[:collection]
end

Expand All @@ -67,7 +67,7 @@ def execute(site)
if ( i == 1 )
page.output_path = File.join( @output_prefix, File.basename( @input_path ) + ".html" )
else
page.output_path = File.join( @output_prefix, "#{@page_name}#{i}.html" )
page.output_path = File.join( @output_prefix, "#{@page_name}#{i}.html" )
end
page.paginate_generated = true
site.pages << page
Expand Down
2 changes: 1 addition & 1 deletion lib/awestruct/extensions/relative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Extensions
module Relative

def relative(href, p = page)
Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
end

end
Expand Down

0 comments on commit 7f529fe

Please sign in to comment.