jeremylightsmith-actionsite 0.6 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/action_site.rb CHANGED
@@ -19,5 +19,5 @@ require 'action_site/link_checker'
19
19
  require 'action_site/async_link_checker'
20
20
 
21
21
  module ActionSite
22
- VERSION = "0.6"
22
+ VERSION = "0.6.1"
23
23
  end
@@ -38,12 +38,9 @@ module ActionSite
38
38
  @generators ||= DEFAULT_GENERATORS.dup
39
39
  end
40
40
 
41
- def generate(in_dir = @in_dir, out_dir = @out_dir)
42
- Dir.chdir(@in_dir) do
43
- Dir["**/*"].each do |path|
44
- refresh_page path
45
- end
46
- end
41
+ def generate
42
+ Dir[@in_dir + "/**/*"].map {|path| path.sub(@in_dir, '') }.
43
+ each {|path| refresh_page(path) }
47
44
  end
48
45
 
49
46
  def refresh_page(path)
@@ -58,19 +55,18 @@ module ActionSite
58
55
  # nothing
59
56
 
60
57
  elsif File.symlink?(in_file)
61
- mkdir_p File.dirname(out_file)
58
+ ensure_directory_exists(out_file)
62
59
  cp in_file, out_file rescue nil # maybe the links don't exist here
63
60
 
64
61
  elsif File.directory?(in_file)
65
- mkdir_p out_file
66
- generate in_file, out_file
62
+ ensure_directory_exists(out_file)
67
63
 
68
64
  elsif resource?(in_file)
69
- mkdir_p File.dirname(out_file)
65
+ ensure_directory_exists(out_file)
70
66
  ln_sf File.expand_path(in_file), File.expand_path(out_file)
71
67
 
72
68
  else
73
- mkdir_p File.dirname(out_file)
69
+ ensure_directory_exists(out_file)
74
70
  out_file = out_file.gsub(/\..+$/, '.html')
75
71
  generate_page(in_file, out_file)
76
72
  puts " #{in_file} => #{out_file}"
@@ -78,7 +74,11 @@ module ActionSite
78
74
  end
79
75
 
80
76
  def excluded?(file)
81
- File.directory?(file) && EXCLUDED_DIRECTORIES.include?(File.basename(file))
77
+ if File.directory?(file)
78
+ EXCLUDED_DIRECTORIES.include?(File.basename(file))
79
+ elsif File.file?(file)
80
+ EXCLUDED_DIRECTORIES.include?(File.basename(File.dirname(file)))
81
+ end
82
82
  end
83
83
 
84
84
  def resource?(file)
@@ -110,6 +110,11 @@ module ActionSite
110
110
 
111
111
  private
112
112
 
113
+ def ensure_directory_exists(file)
114
+ dir = File.dirname(file)
115
+ mkdir_p(dir) unless File.directory?(dir)
116
+ end
117
+
113
118
  def generate_page(in_file, out_file)
114
119
  File.open(out_file, "w") do |f|
115
120
  f << @generator.process_file(in_file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeremylightsmith-actionsite
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.6"
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Lightsmith