reqres_rspec 0.0.14 → 0.0.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 489c6ec987e6271ce2774c2dc1d2f75d862d83ce
4
- data.tar.gz: 44f7f0c8a4af0972332caa50225f4adcd3106256
3
+ metadata.gz: 37c81ea83e40e5956d5ac04dc91e70b7c82c71a4
4
+ data.tar.gz: 426569056ed69c40110d35968089b7bd23ecea7f
5
5
  SHA512:
6
- metadata.gz: ed35216a3eb1189921cadb4032517b3bc4c90926cd4c0eb15745bb4c3244c98e11560b67615c89e83fca499a389d46fda3669a9fd144f6e57e66f670e9526d6e
7
- data.tar.gz: afa5350b12255105840b248ed92ba1d766933897383d8f62f4eca1a843578c9528d27d3be2f1f9f701d87ccf69541ab26e1dd404c1c0ea2d1c3970f0c8d73e72
6
+ metadata.gz: 0b4ddf6150b33d84f1a9a5be2bdc77a4a8471b5d8ea2ecd6d63b8ad1aafe0f86f0cc8a07b9760fad195e57f00dfdb1c7ad7a40994eeb79f45493de2f31833cc2
7
+ data.tar.gz: 2ed8b1bb73d1f205d90612770a494d8fd5f463be54c4aa2000df89baa40400b8f8836def7cfa45c1d9ceeb7d778cd761fd1dc19a5cae3c0aaa2f7e177d38d79d
data/README.md CHANGED
@@ -4,6 +4,8 @@ Gem generates API documentation from your integration tests written with `rspec`
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### Gem
8
+
7
9
  Add this line to your application's Gemfile:
8
10
 
9
11
  gem 'reqres_rspec'
@@ -16,6 +18,19 @@ Or install it yourself as:
16
18
 
17
19
  $ gem install reqres_rspec
18
20
 
21
+ ### PDF generator
22
+
23
+ Install `prince` http://www.princexml.com/download/
24
+
25
+ For MacOS this will be
26
+
27
+ ```
28
+ wget http://www.princexml.com/download/prince-9.0r2-macosx.tar.gz
29
+ tar -xvf prince-9.0r2-macosx.tar.gz
30
+ cd prince-9.0r2-macosx
31
+ ./install.sh
32
+ ```
33
+
19
34
  ## Usage
20
35
 
21
36
  ### Sample controller action
@@ -4,23 +4,24 @@ module ReqresRspec
4
4
  # generates PDF file from existing HTML docs
5
5
  # TODO: more info
6
6
  def generate
7
- wkhtmltopdf_path = '/Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf'
7
+ # http://www.princexml.com/download/
8
+ pdf_tool_path = 'prince'
8
9
  html_docs_root = File.join(Rails.root, 'doc')
9
- pdf_doc_path = File.join(Rails.root, 'doc', "spec_#{Time.now.strftime("%d-%h-%Y_%H-%M")}.pdf")
10
+ pdf_doc_path = File.join(Rails.root, 'doc', "rspec_doc_#{Time.now.strftime("%d-%h-%Y_%H-%M")}.pdf")
10
11
 
11
- if File.exists?(wkhtmltopdf_path)
12
- files = Dir["#{html_docs_root}/rspec_docs_*.html"]
12
+ if `which #{pdf_tool_path}`.size > 0
13
+ files = Dir["#{html_docs_root}/rspec_doc_*.html"]
13
14
  if files.size > 0
14
- files_arg = files.map { |f| f if f =~ /\/rspec_docs_\d+\.html/ }.compact.sort.join('" "')
15
+ files_arg = files.map { |f| f if f =~ /\/rspec_doc_\d+\.html/ }.compact.sort.join('" "')
15
16
 
16
- `#{wkhtmltopdf_path} "#{files_arg}" "#{pdf_doc_path}"`
17
+ `#{pdf_tool_path} "#{files_arg}" -o "#{pdf_doc_path}"`
17
18
 
18
- puts "saved to #{pdf_doc_path}" if File.exists? pdf_doc_path
19
+ puts "ReqresRspec::Generators::Pdf saved doc to #{pdf_doc_path}" if File.exists? pdf_doc_path
19
20
  else
20
21
  puts 'No HTML files found'
21
22
  end
22
23
  else
23
- puts 'ERROR: wkhtmltopdf app not installed! Please check http://code.google.com/p/wkhtmltopdf/ for more info'
24
+ puts "ERROR: #{pdf_tool_path} is not installed! Check README.md for more info"
24
25
  end
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module ReqresRspec
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
@@ -26,7 +26,7 @@ module ReqresRspec
26
26
  # deletes previous version of HTML docs
27
27
  # TODO: more info
28
28
  def cleanup
29
- FileUtils.rm_rf(Dir.glob("#{Rails.root}/doc/rspec_docs_*.html"), secure: true)
29
+ FileUtils.rm_rf(Dir.glob("#{Rails.root}/doc/rspec_doc_*.html"), secure: true)
30
30
  end
31
31
 
32
32
  # generates contents of HTML docs
@@ -35,7 +35,7 @@ module ReqresRspec
35
35
  tpl_path = File.join(File.dirname(__FILE__), 'templates', 'header.erb')
36
36
  rendered_doc = ERB.new(File.open(tpl_path).read).result(binding)
37
37
 
38
- path = File.join(Rails.root, 'doc', 'rspec_docs_00000.html')
38
+ path = File.join(Rails.root, 'doc', 'rspec_doc_00000.html')
39
39
  file = File.open(path, 'w')
40
40
  file.write(rendered_doc)
41
41
  file.close
@@ -53,7 +53,7 @@ module ReqresRspec
53
53
 
54
54
  rendered_doc = ERB.new(File.open(tpl_path).read).result(binding)
55
55
 
56
- path = File.join(Rails.root, 'doc', "rspec_docs_#{('0000' + (@index).to_s)[-5, 5]}.html")
56
+ path = File.join(Rails.root, 'doc', "rspec_doc_#{('0000' + (@index).to_s)[-5, 5]}.html")
57
57
  file = File.open(path, 'w')
58
58
  file.write(rendered_doc)
59
59
  file.close
@@ -4,6 +4,8 @@
4
4
  <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
5
5
  <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
6
6
  <style>
7
+ @page { size: 24.5cm 35cm } /* http://www.princexml.com/doc/9.0/page-size/ */
8
+
7
9
  body {
8
10
  color: #333333;
9
11
  font-family: 'Verdana', 'Droid Sans', sans-serif;
@@ -17,7 +19,8 @@
17
19
  box-sizing: border-box;
18
20
  }
19
21
  .container {
20
- padding: 40px;
22
+ padding: 0;
23
+ width: 100%;
21
24
  }
22
25
  h1, h2, ul {
23
26
  margin: 0 0 10px;
@@ -61,7 +64,7 @@
61
64
  <% @records.each_with_index do |record, index| %>
62
65
  <li>
63
66
  <%= index+1 %>.
64
- <a href="rspec_docs_<%= ('0000' + (index + 1).to_s)[-5, 5] %>.html">
67
+ <a href="rspec_doc_<%= ('0000' + (index + 1).to_s)[-5, 5] %>.html">
65
68
  <%= record[:title] %>
66
69
  </a>
67
70
  </li>
@@ -4,6 +4,8 @@
4
4
  <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
5
5
  <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
6
6
  <style>
7
+ @page { size: 24.5cm 35cm } /* http://www.princexml.com/doc/9.0/page-size/ */
8
+
7
9
  body {
8
10
  color: #333333;
9
11
  font-family: 'Verdana', 'Droid Sans', sans-serif;
@@ -17,7 +19,8 @@
17
19
  box-sizing: border-box;
18
20
  }
19
21
  .container {
20
- padding: 40px;
22
+ padding: 0;
23
+ width: 100%;
21
24
  }
22
25
  h1, h2, ul {
23
26
  margin: 0 0 10px;
@@ -141,7 +144,7 @@
141
144
  <body>
142
145
  <div class="container">
143
146
  <h3>
144
- <a href="rspec_docs_00000.html">&#9650</a>
147
+ <a href="rspec_doc_00000.html">&#9650</a>
145
148
  <a id="<%= @index %>"></a><%= @index %>. <%= @record[:title] %>
146
149
  </h3>
147
150
 
data/lib/reqres_rspec.rb CHANGED
@@ -26,5 +26,5 @@ if defined?(RSpec) && ENV['REQRES_RSPEC'] == '1'
26
26
  end
27
27
  end
28
28
  else
29
- puts "\nNOTICE: ReqresRspec is disabled. run RSpec with REQRES_RSPEC=1 environment var\n"
29
+ puts "\nNOTICE: ReqresRspec is disabled. run `REQRES_RSPEC=1 bundle exec rspec`\n"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reqres_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - rilian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-17 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler