hx 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -8
- data/VERSION +1 -1
- data/lib/hx.rb +6 -4
- data/lib/hx/backend/rawfiles.rb +1 -0
- data/lib/hx/cli.rb +2 -1
- data/spec/rawfiles_spec.rb +54 -0
- data/spec/spec_helper.rb +2 -7
- metadata +36 -17
- data/.gitignore +0 -21
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ EOS
|
|
15
15
|
gem.email = "mental@rydia.net"
|
16
16
|
gem.homepage = "http://github.com/mental/hx"
|
17
17
|
gem.authors = ["MenTaLguY"]
|
18
|
-
gem.add_development_dependency "rspec", ">=
|
18
|
+
gem.add_development_dependency "rspec", ">= 2.0.0"
|
19
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
20
|
end
|
21
21
|
Jeweler::GemcutterTasks.new
|
@@ -23,15 +23,13 @@ rescue LoadError
|
|
23
23
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
24
24
|
end
|
25
25
|
|
26
|
-
require '
|
27
|
-
|
28
|
-
spec.
|
29
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
28
|
+
spec.rspec_opts = "--color"
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
spec.
|
34
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
32
|
+
spec.rspec_opts = "--color"
|
35
33
|
spec.rcov = true
|
36
34
|
end
|
37
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.4
|
data/lib/hx.rb
CHANGED
@@ -541,22 +541,24 @@ class Site
|
|
541
541
|
end
|
542
542
|
end
|
543
543
|
|
544
|
-
def self.refresh_file(pathname, content, update_time)
|
544
|
+
def self.refresh_file(pathname, content, update_time, executable=false)
|
545
545
|
begin
|
546
546
|
return false if update_time and update_time < pathname.mtime
|
547
547
|
rescue Errno::ENOENT
|
548
548
|
end
|
549
|
-
write_file(pathname, content)
|
549
|
+
write_file(pathname, content, executable)
|
550
550
|
true
|
551
551
|
end
|
552
552
|
|
553
|
-
def self.write_file(pathname, content)
|
553
|
+
def self.write_file(pathname, content, executable=false)
|
554
554
|
parent = pathname.parent
|
555
555
|
parent.mkpath()
|
556
556
|
tempfile = Tempfile.new('.hx-out', parent.to_s)
|
557
557
|
begin
|
558
558
|
File.open(tempfile.path, "wb") { |stream| stream << content.to_s }
|
559
|
-
|
559
|
+
base_mode = 0666
|
560
|
+
base_mode |= 0111 if executable
|
561
|
+
File.chmod(base_mode & ~File.umask, tempfile.path)
|
560
562
|
File.rename(tempfile.path, pathname.to_s)
|
561
563
|
ensure
|
562
564
|
tempfile.unlink
|
data/lib/hx/backend/rawfiles.rb
CHANGED
data/lib/hx/cli.rb
CHANGED
@@ -114,7 +114,8 @@ def self.do_gen(site, update_only)
|
|
114
114
|
else
|
115
115
|
update_time = nil
|
116
116
|
end
|
117
|
-
written = Hx.refresh_file(pathname, content, update_time
|
117
|
+
written = Hx.refresh_file(pathname, content, update_time,
|
118
|
+
entry['executable'])
|
118
119
|
puts "===> #{path}" if written
|
119
120
|
end
|
120
121
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require 'hx/backend/rawfiles'
|
4
|
+
require 'enumerator'
|
5
|
+
require 'set'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
describe Hx::Backend::RawFiles do
|
9
|
+
before :each do
|
10
|
+
@dir = Dir.mktmpdir
|
11
|
+
@input = Hx::Backend::RawFiles.new(Hx::NULL_INPUT, {:entry_dir => @dir})
|
12
|
+
end
|
13
|
+
|
14
|
+
after :each do
|
15
|
+
FileUtils.rm_rf @dir
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should retrieve file content" do
|
19
|
+
content = "foobar"
|
20
|
+
File.open(File.join(@dir, 'test'), 'w') { |s| s.write(content) }
|
21
|
+
@input.get_entry('test')['content'].to_s.should == content
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should enumerate files" do
|
25
|
+
entry_names = Set.new %q(foo bar baz)
|
26
|
+
for name in entry_names
|
27
|
+
File.open(File.join(@dir, name), 'w') {}
|
28
|
+
end
|
29
|
+
enum = Enumerable::Enumerator.new(@input, :each_entry_path, Hx::Path::ALL)
|
30
|
+
Set.new(enum).should == entry_names
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should retreive file content lazily" do
|
34
|
+
real_content = "foobar"
|
35
|
+
File.open(File.join(@dir, 'test'), 'w') { |s| s.write("blargh") }
|
36
|
+
entry_content = @input.get_entry('test')['content']
|
37
|
+
File.open(File.join(@dir, 'test'), 'w') { |s| s.write(real_content) }
|
38
|
+
entry_content.to_s.should == real_content
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should retrieve file mtime" do
|
42
|
+
File.open(File.join(@dir, 'test'), 'w') {}
|
43
|
+
time = Time.at(0)
|
44
|
+
File.utime(time, time, File.join(@dir, 'test'))
|
45
|
+
@input.get_entry('test')['updated'].should == time
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the executable bit" do
|
49
|
+
File.open(File.join(@dir, 'regular'), 'w') {}
|
50
|
+
File.open(File.join(@dir, 'executable'), 'w') { |s| s.chmod(0775) }
|
51
|
+
@input.get_entry('regular')['executable'].should be_false
|
52
|
+
@input.get_entry('executable')['executable'].should be_true
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,8 +2,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'hx'
|
4
4
|
require 'ostruct'
|
5
|
-
require '
|
6
|
-
require 'spec/autorun'
|
5
|
+
require 'rspec'
|
7
6
|
begin
|
8
7
|
require 'rubygems'
|
9
8
|
rescue LoadError
|
@@ -36,12 +35,8 @@ class FakeInput
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
|
38
|
+
RSpec::Matchers.define :accept do |value|
|
40
39
|
match do |acceptor|
|
41
40
|
acceptor.accept?(value)
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
|
-
Spec::Runner.configure do |config|
|
46
|
-
|
47
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 55
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 4
|
10
|
+
version: 0.8.4
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- MenTaLguY
|
@@ -9,19 +15,25 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-02-09 00:00:00 -08:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 2.0.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
25
37
|
description: |
|
26
38
|
Hx is a simple static site generator in the spirit of Hobix which reads a
|
27
39
|
YAML configuration file, constructs a filter graph, and generates output
|
@@ -38,7 +50,6 @@ extra_rdoc_files:
|
|
38
50
|
- README.rdoc
|
39
51
|
files:
|
40
52
|
- .document
|
41
|
-
- .gitignore
|
42
53
|
- LICENSE
|
43
54
|
- README.rdoc
|
44
55
|
- Rakefile
|
@@ -64,6 +75,7 @@ files:
|
|
64
75
|
- spec/overlay_spec.rb
|
65
76
|
- spec/pathops_spec.rb
|
66
77
|
- spec/rack_spec.rb
|
78
|
+
- spec/rawfiles_spec.rb
|
67
79
|
- spec/selector_spec.rb
|
68
80
|
- spec/site_spec.rb
|
69
81
|
- spec/spec.opts
|
@@ -73,37 +85,44 @@ homepage: http://github.com/mental/hx
|
|
73
85
|
licenses: []
|
74
86
|
|
75
87
|
post_install_message:
|
76
|
-
rdoc_options:
|
77
|
-
|
88
|
+
rdoc_options: []
|
89
|
+
|
78
90
|
require_paths:
|
79
91
|
- lib
|
80
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
81
94
|
requirements:
|
82
95
|
- - ">="
|
83
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
84
100
|
version: "0"
|
85
|
-
version:
|
86
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
87
103
|
requirements:
|
88
104
|
- - ">="
|
89
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
90
109
|
version: "0"
|
91
|
-
version:
|
92
110
|
requirements: []
|
93
111
|
|
94
112
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.3.
|
113
|
+
rubygems_version: 1.3.7
|
96
114
|
signing_key:
|
97
115
|
specification_version: 3
|
98
116
|
summary: A miniature static site generator.
|
99
117
|
test_files:
|
100
|
-
- spec/spec_helper.rb
|
101
118
|
- spec/cache_spec.rb
|
102
119
|
- spec/hx_dummy.rb
|
103
|
-
- spec/nullinput_spec.rb
|
104
|
-
- spec/site_spec.rb
|
105
120
|
- spec/hx_dummy2.rb
|
106
|
-
- spec/
|
121
|
+
- spec/nullinput_spec.rb
|
107
122
|
- spec/overlay_spec.rb
|
108
123
|
- spec/pathops_spec.rb
|
124
|
+
- spec/rack_spec.rb
|
125
|
+
- spec/rawfiles_spec.rb
|
109
126
|
- spec/selector_spec.rb
|
127
|
+
- spec/site_spec.rb
|
128
|
+
- spec/spec_helper.rb
|