rescik 0.2.0

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/README ADDED
@@ -0,0 +1,9 @@
1
+ Rescik
2
+ ====
3
+
4
+ Use prawn to generate REST API docummentation.
5
+
6
+ Usage
7
+ ====
8
+
9
+ Check examples/example.rb for basic usage
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "rescik"
7
+ gemspec.summary = "REST API docummentation generator"
8
+ gemspec.description = "Generates docummentation in pdf format using simple DSL"
9
+ gemspec.email = "imoryc@gmail.com"
10
+ gemspec.homepage = "http://github.com/ignacy/rescik"
11
+ gemspec.authors = ["Ignacy Moryc"]
12
+ end
13
+ rescue LoadError
14
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
15
+ end
16
+
17
+ ############################
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + "/../lib/rescik"
2
+
3
+ Rescik.generate("REST_API.pdf") do
4
+ method("POST", "/products") do
5
+ description "This methods allows us to create new products using XML REST API"
6
+ params({"name" => ["required", "string", "This is the name"],
7
+ "product_type" => ["required", "string", "This is product's type"],
8
+ "cover_id" => ["required", "string", "this is cover id"]})
9
+
10
+ example_response(<<-RESPONSE
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <access-tokens type="array">
13
+ <access-token>
14
+ <single-access-token>WuBcURTUTt4GRg56nRj</single-access-token>
15
+ <user-id type="integer">1</user-id>
16
+ </access-token>
17
+ </access-tokens>
18
+ RESPONSE
19
+ )
20
+ end
21
+ end
data/lib/rescik.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'prawn'
3
+ require "prawn/measurement_extensions"
4
+
5
+ Prawn.debug = true
6
+
7
+ class Rescik < Prawn::Document
8
+
9
+ def self.generate(outfile, &block)
10
+ @doc = new(:top_margin => 0.75.in,
11
+ :bottom_margin => 1.in,
12
+ :left_margin => 1.in,
13
+ :right_margin => 1.in,
14
+ :page_size => [7.0.in, 9.19.in])
15
+ @doc.instance_eval(&block)
16
+ @doc.render_file(outfile)
17
+ end
18
+
19
+ def method(type, path)
20
+ text "#{type.upcase} #{path}", :size => 11, :style => :bold
21
+ stroke_horizontal_rule
22
+ move_down 15
23
+ yield
24
+ end
25
+
26
+ def description(desc)
27
+ move_down 10
28
+ text "Description:", :style => :bold, :size => 9
29
+ move_down 5
30
+ text desc, :size => 9
31
+ end
32
+
33
+ def params(opts)
34
+ move_down 10
35
+ text "Parameters", :style => :bold, :size => 9
36
+ move_down 5
37
+ opts.each { |k, v|
38
+ text "- #{k}", :style => :bold, :size => 9
39
+ text "(#{v.first} prameter; type: #{v[1]}) #{v.last || ""}", :size => 9
40
+ move_down(3)
41
+ }
42
+ end
43
+
44
+ def example_response(response)
45
+ move_down 10
46
+ text "Response example:", :style => :bold, :size => 9
47
+ move_down 5
48
+ text response, :size => 9
49
+ end
50
+
51
+ end
Binary file
data/rescik.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rescik}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ignacy Moryc"]
12
+ s.date = %q{2010-11-26}
13
+ s.description = %q{Generates docummentation in pdf format using simple DSL}
14
+ s.email = %q{imoryc@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ "README",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "examples/example.rb",
23
+ "lib/rescik.rb",
24
+ "pkg/rescik-0.1.0.gem",
25
+ "rescik.gemspec"
26
+ ]
27
+ s.homepage = %q{http://github.com/ignacy/rescik}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.7}
31
+ s.summary = %q{REST API docummentation generator}
32
+ s.test_files = [
33
+ "examples/example.rb"
34
+ ]
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
46
+
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rescik
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Ignacy Moryc
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-26 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Generates docummentation in pdf format using simple DSL
23
+ email: imoryc@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ files:
31
+ - README
32
+ - Rakefile
33
+ - VERSION
34
+ - examples/example.rb
35
+ - lib/rescik.rb
36
+ - pkg/rescik-0.1.0.gem
37
+ - rescik.gemspec
38
+ has_rdoc: true
39
+ homepage: http://github.com/ignacy/rescik
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ hash: 3
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: REST API docummentation generator
72
+ test_files:
73
+ - examples/example.rb