guides 0.6.1 → 0.6.2

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/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(*)
@@ -178,7 +178,7 @@ module Guides
178
178
  end
179
179
 
180
180
  def set_header_section(body, view)
181
- new_body = body.gsub(/(.*?)endprologue\./m, '').strip
181
+ new_body = body.sub(/(.*?)endprologue\./m, '').strip
182
182
  header = $1
183
183
 
184
184
  unless header
@@ -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(LOCAL_ASSETS)
11
- @source = Rack::File.new(SOURCE_ASSETS)
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 /(.*).html/
30
+ when /\/(.*).html/
23
31
  name = $1
24
32
  generator = Guides::Generator.new({})
25
- source_file = Dir["#{SOURCE_TEMPLATES}/#{name}.{html.erb,textile}"].first
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")
@@ -1,3 +1,3 @@
1
1
  module Guides
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/spec/preview_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "guides generate" do
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
@@ -64,7 +64,7 @@ module SpecHelpers
64
64
  if host == :preview
65
65
  ip = host = 'http://localhost:9292'
66
66
  else
67
- ip = ENV['STROBEAPP_URL']
67
+ ip = ENV['GUIDES_URL']
68
68
  end
69
69
 
70
70
  headers['Host'] = host
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 1
9
- version: 0.6.1
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-13 00:00:00 -08:00
17
+ date: 2011-01-14 00:00:00 -05:00
18
18
  default_executable: guides
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency