Skip to content

Instantly share code, notes, and snippets.

View denisdefreyne's full-sized avatar

Denis Defreyne denisdefreyne

View GitHub Profile
tahontaenrat …opment/nanoc/repos/nanoc ▸ ack meow
test/base/test_code_snippet.rb
7: $complete_insane_parrot = 'meow'
19: @foo = 'meow'
26: assert_equal('meow', @foo)
test/base/test_item_rep.rb
504: File.open('content/meow.dat', 'w') { |io| io.write('asdf') }
506: "content/meow.dat", {}, '/',
532: File.open('content/meow.dat', 'w') { |io| io.write('asdf') }
module Nanoc
class ContentPiece
def initialize(content, attributes, identifier)
# Content
if content.nil?
raise ArgumentError, "attempted to create a #{self.class} with no content/filename (identifier #{@identifier})"
elsif content.is_a?(Nanoc::TextualContent)
@content = content
# nanoc 3.x
compile '/assets/style/*' do
filter :sass, :syntax => :scss, :style => :compressed
filter :relativize_paths, :type => :css
end
route '/assets/*' do
version_part = item[:version] ? '-v' + item[:version].to_s : ''
item.identifier[0..-2] + version_part + '.' + item[:extension]
PING zeusgw.ugent.be (157.193.55.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
36 bytes from rtr-arc-gw138.ugent.be (157.193.138.4): Communication prohibited by filter
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 5400 c4e9 0 0000 36 01 27ec 192.168.2.105 157.193.55.1
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
def write(path, params={})
rep.write(path, params={})
end
▸ nanoc
Loading site data… done
Compiling site…
Captain! We’ve been hit!
Message:
RuntimeError: Cannot create a link to #<Nanoc::ItemProxy:0x007ffc980f6990 @item=<Nanoc::Item identifier=<Nanoc::Identifier "/index.erb">>, @item_rep_store=#<Nanoc::ItemRepStore:0x007ffc93c3a018 @reps=[<Nanoc::ItemRep name="raw" raw_paths={:last=><Nanoc::Identifier "/404.txt">} paths_without_snapshot=["/404.txt"] item.identifier="/404.erb">, <Nanoc::ItemRep name="default" raw_paths={:last=>"/error/404.php"} paths_without_snapshot=["/error/404.php"] item.identifier="/404.erb">, <Nanoc::ItemRep name="raw" raw_paths={:last=><Nanoc::Identifier "/about.txt">} paths_without_snapshot=["/about.txt"] item.identifier="/about.erb">, <Nanoc::ItemRep name="default" raw_paths={:last=><Nanoc::Identifier "/about/index.html">} paths_without_snapshot=["/about/index.html"] item.identifier="/about.erb">, <Nanoc::ItemRep name="raw" raw_paths={} paths_without_snapshot=[] item.identifier="/assets/images/banners/adsf.png">, <Nanoc::ItemRep name="defa
@denisdefreyne
denisdefreyne / nanoc-subprojects.md
Last active February 3, 2016 12:56
Splitting nanoc

nanoc subprojects

Notes

  • The filesystem data source will still be part of core. Ideally, it could be moved out, but a lot of tests in core depend on the filesystem data source, and cleaning that up is a lot of (unecessary) work.
#!/usr/bin/env ruby
### Preprocessing rules ######################################################
preprocess do
def hide_assets
items.each do |item|
if item.identifier =~ /^\/assets/
item[:is_hidden] = true
% gem list -l nanoc
*** LOCAL GEMS ***
nanoc-core (4.0.0a1)
% gem install nanoc-asciidoc-1.0.0.gem --prerelease
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: nanoc-asciidoc requires nanoc-core (~> 4.0)
@denisdefreyne
denisdefreyne / invalid-utf-8.rb
Created September 4, 2013 21:11
UTF-8 case that crashes in MRI and does not crash in Rubinius
# encoding: utf-8
File.write('foo.txt', 'Hëllö'.encode('ISO-8859-1'))
data = File.binread('foo.txt')
data.force_encoding('utf-8')
data.encode!('utf-8')
data.gsub!("\xEF\xBB\xBF", '')
# Crashes in Ruby 1.9.3p392: