nanoc 1.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -32,7 +32,7 @@ spec = Gem::Specification.new do |s|
32
32
  s.required_ruby_version = '>= 1.8.2'
33
33
 
34
34
  s.has_rdoc = false
35
- s.files = %w( README LICENSE Rakefile ) + Dir.glob('{bin,lib}/**/*')
35
+ s.files = %w( README LICENSE Rakefile ) + Dir['{bin,lib}/**/*']
36
36
  s.executables = [ 'nanoc' ]
37
37
  s.require_path = 'lib'
38
38
  s.bindir = 'bin'
@@ -44,7 +44,7 @@ Rake::GemPackageTask.new(spec) do |task|
44
44
  end
45
45
 
46
46
  Rake::TestTask.new(:test) do |test|
47
- test.test_files = Dir.glob('test/test_*.rb')
47
+ test.test_files = Dir['test/test_*.rb']
48
48
  end
49
49
 
50
50
  #####
data/bin/nanoc CHANGED
@@ -32,7 +32,7 @@ opts = GetoptLong.new(
32
32
  [ '--template', '-t', GetoptLong::REQUIRED_ARGUMENT ],
33
33
  [ '--version', '-v', GetoptLong::NO_ARGUMENT ]
34
34
  )
35
- uncompileed_opts = {}
35
+ unprocessed_opts = {}
36
36
  begin
37
37
  opts.each do |opt, arg|
38
38
  case opt
@@ -43,7 +43,7 @@ begin
43
43
  puts version_text
44
44
  exit
45
45
  else
46
- uncompileed_opts[opt] = arg
46
+ unprocessed_opts[opt] = arg
47
47
  end
48
48
  end
49
49
  rescue GetoptLong::InvalidOption
@@ -74,7 +74,7 @@ case command
74
74
  $stderr.puts 'Usage: nanoc create_page [page_name]'
75
75
  exit
76
76
  end
77
- Nanoc::Creator.create_page(ARGV[1], :template => uncompileed_opts['--template'])
77
+ Nanoc::Creator.create_page(ARGV[1], :template => unprocessed_opts['--template'])
78
78
 
79
79
  # Create template
80
80
  when 'create_template', 'ct'
data/lib/compiler.rb CHANGED
@@ -12,11 +12,11 @@ module Nanoc
12
12
  end
13
13
 
14
14
  def run
15
- Dir.glob('lib/*.rb').each { |f| require f }
15
+ Dir['lib/*.rb'].each { |f| require f }
16
16
 
17
17
  pages = compile_pages(uncompiled_pages)
18
18
  pages.each do |page|
19
- content = (page[:layout].nil? ? '<%= @page[:content] %>' : File.read("layouts/#{page[:layout]}.erb")).eruby(page.merge({ :page => page, :pages => pages }))
19
+ content = File.read("layouts/#{page[:layout]}.erb").eruby(page.merge({ :page => page, :pages => pages })) # fallback for nanoc 1.0
20
20
  FileManager.create_file(path_for_page(page)) { content }
21
21
  end
22
22
  end
@@ -24,12 +24,12 @@ module Nanoc
24
24
  private
25
25
 
26
26
  def uncompiled_pages
27
- Dir.glob('content/**/meta.yaml').collect do |filename|
27
+ Dir['content/**/meta.yaml'].collect do |filename|
28
28
  page = @global_page.merge(YAML.load_file_and_clean(filename))
29
29
  page[:path] = filename.sub(/^content/, '').sub('meta.yaml', '')
30
30
 
31
- content_filenames = Dir.glob(filename.sub('meta.yaml', File.basename(File.dirname(filename)) + '.*'))
32
- content_filenames += Dir.glob("#{File.dirname(filename)}/index.*") # fallback for nanoc 1.0
31
+ content_filenames = Dir[filename.sub('meta.yaml', File.basename(File.dirname(filename)) + '.*')].reject { |f| f =~ /~$/ }
32
+ content_filenames += Dir["#{File.dirname(filename)}/index.*"] # fallback for nanoc 1.0
33
33
  content_filenames.ensure_single('content files', File.dirname(filename))
34
34
  page[:_content_filename] = content_filenames[0]
35
35
 
@@ -46,7 +46,7 @@ module Nanoc
46
46
  def compile_pages(a_pages)
47
47
  a_pages.inject([]) do |pages, page|
48
48
  content = File.read(page[:_content_filename]).filter(page[:filters], :eruby_context => { :page => page, :pages => pages })
49
- pages + [ page.merge( { :content => content }) ]
49
+ pages + [ page.merge( { :content => content, :_content_filename => nil }) ]
50
50
  end
51
51
  end
52
52
 
data/lib/creator.rb CHANGED
@@ -108,8 +108,8 @@ module Nanoc
108
108
  template = a_params[:template] || 'default'
109
109
  begin
110
110
  template_meta = File.read("templates/#{template}/meta.yaml")
111
- template_content_filenames = Dir.glob("templates/#{template}/#{template}.*")
112
- template_content_filenames += Dir.glob("templates/#{template}/index.*")
111
+ template_content_filenames = Dir["templates/#{template}/#{template}.*"]
112
+ template_content_filenames += Dir["templates/#{template}/index.*"]
113
113
  template_content_filename = template_content_filenames[0]
114
114
  template_index = File.read(template_content_filename)
115
115
  rescue
@@ -122,7 +122,7 @@ module Nanoc
122
122
  # Create index and yaml file
123
123
  FileManager.create_dir 'content' do
124
124
  FileManager.create_dir a_pagename do
125
- FileManager.create_file "#{a_pagename}#{File.extname(template_content_filename)}" do
125
+ FileManager.create_file "#{a_pagename.sub(/.*\/([^\/]+)/, '\1')}#{File.extname(template_content_filename)}" do
126
126
  template_index
127
127
  end
128
128
  FileManager.create_file 'meta.yaml' do
@@ -151,5 +151,4 @@ module Nanoc
151
151
  end
152
152
 
153
153
  end
154
-
155
154
  end
data/lib/enhancements.rb CHANGED
@@ -89,26 +89,6 @@ end
89
89
  class FileManager
90
90
  @@stack = []
91
91
 
92
- COLORS = {
93
- :reset => "\e[0m",
94
-
95
- :bold => "\e[1m",
96
-
97
- :black => "\e[30m",
98
- :red => "\e[31m",
99
- :green => "\e[32m",
100
- :yellow => "\e[33m",
101
- :blue => "\e[34m",
102
- :magenta => "\e[35m",
103
- :cyan => "\e[36m",
104
- :white => "\e[37m"
105
- }
106
- ACTION_COLORS = {
107
- :create => COLORS[:bold] + COLORS[:green],
108
- :update => COLORS[:bold] + COLORS[:yellow],
109
- :identical => COLORS[:bold]
110
- }
111
-
112
92
  def self.create_dir(a_name)
113
93
  @@stack.push(a_name)
114
94
  path = File.join(@@stack)
@@ -121,16 +101,36 @@ class FileManager
121
101
  end
122
102
 
123
103
  def self.create_file(a_name)
124
- path = @@stack.empty? ? a_name : File.join(@@stack + [ a_name ])
104
+ path = File.join(@@stack + [ a_name ])
125
105
  FileManager.create_dir(path.sub(/\/[^\/]+$/, '')) if @@stack.empty?
126
106
  content = block_given? ? yield : nil
127
107
  File.exist?(path) ? ( block_given? and File.read(path) == content ? log('identical', path) : log('update', path) ) : log('create', path)
128
108
  open(path, 'w') { |io| io.write(content) unless content.nil? }
129
109
  end
110
+ end
130
111
 
131
- def self.log(a_action, a_path)
132
- puts format('%s%12s%s %s', ACTION_COLORS[a_action.to_sym], a_action, COLORS[:reset], a_path) unless $quiet == true
133
- end
112
+ COLORS = {
113
+ :reset => "\e[0m",
114
+
115
+ :bold => "\e[1m",
116
+
117
+ :black => "\e[30m",
118
+ :red => "\e[31m",
119
+ :green => "\e[32m",
120
+ :yellow => "\e[33m",
121
+ :blue => "\e[34m",
122
+ :magenta => "\e[35m",
123
+ :cyan => "\e[36m",
124
+ :white => "\e[37m"
125
+ }
126
+ ACTION_COLORS = {
127
+ :create => COLORS[:bold] + COLORS[:green],
128
+ :update => COLORS[:bold] + COLORS[:yellow],
129
+ :identical => COLORS[:bold]
130
+ }
131
+
132
+ def log(a_action, a_path)
133
+ puts format('%s%12s%s %s', ACTION_COLORS[a_action.to_sym], a_action, COLORS[:reset], a_path) unless $quiet == true
134
134
  end
135
135
 
136
136
  def render(a_name, a_context={})
data/lib/nanoc.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Nanoc
2
- VERSION = '1.1'
2
+ VERSION = '1.1.1'
3
3
 
4
4
  def self.ensure_in_site
5
5
  unless in_site?
6
- $stderr.puts 'ERROR: The current working directory does not seem to be a valid/complete nanoc site directory; aborting.'
6
+ $stderr.puts 'ERROR: The current working directory does not seem to be a valid/complete nanoc site directory; aborting.' unless $quiet
7
7
  exit
8
8
  end
9
9
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: nanoc
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.1"
7
- date: 2007-05-08 00:00:00 +02:00
6
+ version: 1.1.1
7
+ date: 2007-05-17 00:00:00 +02:00
8
8
  summary: a CMS that doesn't run on your server
9
9
  require_paths:
10
10
  - lib