guides 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/guides/cli.rb +4 -4
- data/lib/guides/generator.rb +1 -1
- data/lib/guides/preview.rb +17 -9
- data/lib/guides/version.rb +1 -1
- data/spec/preview_spec.rb +5 -2
- data/spec/support/cli.rb +8 -4
- data/spec/support/rack.rb +1 -1
- metadata +3 -3
data/lib/guides/cli.rb
CHANGED
@@ -46,10 +46,10 @@ module Guides
|
|
46
46
|
Preview.start
|
47
47
|
end
|
48
48
|
|
49
|
-
desc "update", "when running from the pkg, updates the gem"
|
50
|
-
def update
|
51
|
-
Update.start
|
52
|
-
end
|
49
|
+
#desc "update", "when running from the pkg, updates the gem"
|
50
|
+
#def update
|
51
|
+
#Update.start
|
52
|
+
#end
|
53
53
|
|
54
54
|
no_tasks do
|
55
55
|
def invoke_task(*)
|
data/lib/guides/generator.rb
CHANGED
data/lib/guides/preview.rb
CHANGED
@@ -2,16 +2,24 @@ require "rack"
|
|
2
2
|
|
3
3
|
module Guides
|
4
4
|
class App
|
5
|
-
LOCAL_ASSETS = File.expand_path("../templates/assets", __FILE__)
|
6
|
-
SOURCE_ASSETS = File.join(Guides.root, "assets")
|
7
|
-
SOURCE_TEMPLATES = File.join(Guides.root, "source")
|
8
|
-
|
9
5
|
def initialize
|
10
|
-
@local = Rack::File.new(
|
11
|
-
@source = Rack::File.new(
|
6
|
+
@local = Rack::File.new(local_assets)
|
7
|
+
@source = Rack::File.new(source_assets)
|
12
8
|
@output = Rack::File.new(File.join(Guides.root, "output"))
|
13
9
|
end
|
14
10
|
|
11
|
+
def local_assets
|
12
|
+
File.expand_path("../templates/assets", __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def source_assets
|
16
|
+
File.join(Guides.root, "assets")
|
17
|
+
end
|
18
|
+
|
19
|
+
def source_templates
|
20
|
+
File.join(Guides.root, "source")
|
21
|
+
end
|
22
|
+
|
15
23
|
def call(env)
|
16
24
|
path = env["PATH_INFO"]
|
17
25
|
|
@@ -19,13 +27,13 @@ module Guides
|
|
19
27
|
when "/"
|
20
28
|
env["PATH_INFO"] = "/index.html"
|
21
29
|
return call(env)
|
22
|
-
when
|
30
|
+
when /\/(.*).html/
|
23
31
|
name = $1
|
24
32
|
generator = Guides::Generator.new({})
|
25
|
-
source_file = Dir["#{
|
33
|
+
source_file = Dir["#{source_templates}/#{name}.{html.erb,textile}"].first
|
26
34
|
|
27
35
|
unless source_file
|
28
|
-
return [404, {"Content-Type" => "text/html"}, ["#{name} not found"]]
|
36
|
+
return [404, {"Content-Type" => "text/html"}, ["#{name} not found in #{source_templates}: #{Guides.root}"]]
|
29
37
|
end
|
30
38
|
|
31
39
|
generator.send(:generate_guide, File.basename(source_file), "#{name}.html")
|
data/lib/guides/version.rb
CHANGED
data/spec/preview_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "guides
|
3
|
+
describe "guides preview" do
|
4
4
|
before(:all) do
|
5
5
|
reset_tmp
|
6
6
|
guides "new", "sample" and wait
|
@@ -14,10 +14,13 @@ describe "guides generate" do
|
|
14
14
|
|
15
15
|
before(:each) do
|
16
16
|
host! :preview
|
17
|
-
launch_test_server
|
18
17
|
guides "preview"
|
19
18
|
end
|
20
19
|
|
20
|
+
after(:each) do
|
21
|
+
kill!
|
22
|
+
end
|
23
|
+
|
21
24
|
it "downloads the index at /" do
|
22
25
|
get "/"
|
23
26
|
should_respond_with 200, /<!DOCTYPE html PUBLIC.*>.*<h3>Start Here<\/h3>/m
|
data/spec/support/cli.rb
CHANGED
@@ -35,21 +35,25 @@ module SpecHelpers
|
|
35
35
|
Guides::CLI.start(argv)
|
36
36
|
end
|
37
37
|
|
38
|
-
if argv.first == 'preview'
|
39
|
-
wait_for_preview_server
|
40
|
-
end
|
41
38
|
|
42
39
|
@stdout_child.close
|
43
40
|
@stdin_child.close
|
44
41
|
@stderr_child.close
|
42
|
+
|
43
|
+
if argv.first == 'preview'
|
44
|
+
wait_for_preview_server
|
45
|
+
end
|
46
|
+
|
45
47
|
@pid
|
46
48
|
end
|
47
49
|
|
48
50
|
def wait_for_preview_server
|
49
51
|
s = TCPSocket.new('0.0.0.0', 9292)
|
50
|
-
rescue Errno::ECONNREFUSED
|
52
|
+
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
|
51
53
|
sleep 0.2
|
52
54
|
retry
|
55
|
+
rescue Exception => e
|
56
|
+
puts [e.class, e.message]
|
53
57
|
ensure
|
54
58
|
s.close
|
55
59
|
end
|
data/spec/support/rack.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 2
|
9
|
+
version: 0.6.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yehuda Katz
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-14 00:00:00 -05:00
|
18
18
|
default_executable: guides
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|