stubb 0.1.rc.1 → 0.1.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.markdown CHANGED
@@ -1,7 +1,6 @@
1
- Stubb
2
- =====
1
+ ![Stubb](https://github.com/knuton/stubb/raw/master/stubb.png)
3
2
 
4
- Stubb allows to **set up a REST API stub by putting responses in files** organized in a directory tree. Which file is picked in response to a particular HTTP request is primarily determined by the request's **method**, **path** and **accept header**. Thus adding a response for a certain type of request is as easy as adding a file with a matching name. For example, the file
3
+ Stubb is a testing and development tool for frontend developers and anyone else depending on HTTP-requesting resources for their work. It allows **setting up a REST API stub by putting responses in files** organized in a directory tree. Which file is picked in response to a particular HTTP request is primarily determined by the request's **method**, **path** and **accept header**. Thus adding a response for a certain type of request is as easy as adding a file with a matching name. For example, the file
5
4
 
6
5
  whales/narwhal.GET.json
7
6
 
@@ -18,6 +17,30 @@ or alternatively
18
17
 
19
18
  Additionally, **sequences of responses** to repeated identical requests can be defined through infix numerals in file names.
20
19
 
20
+ Getting Started
21
+ ---------------
22
+
23
+ Simply install the Stubb gem by running
24
+
25
+ gem install stubb --pre
26
+
27
+ and you are ready to run the stubb CLI:
28
+
29
+ $ stubb
30
+ Tasks:
31
+ stubb help [TASK] # Describe available tasks or one specific task
32
+ stubb server # Starts the server
33
+ stubb version # Print the version of Stubb
34
+
35
+ $ echo Ahoy > hello-world.GET
36
+ $ ls
37
+ hello-world.GET
38
+ $ stubb server &
39
+ $ curl http://localhost:4040/hello-world
40
+ Ahoy
41
+
42
+ By default the server runs on port 4040 and looks for response files in the working directory. Run `stubb help server` for information on configuration options.
43
+
21
44
  Directory Structure and Response Files
22
45
  --------------------------------------
23
46
 
@@ -146,6 +169,11 @@ Stubb depends on
146
169
  - <a href="http://github.com/rack/rack">Rack</a> for processing and serving requests, and
147
170
  - <a href="https://github.com/wycats/thor">Thor</a> for adding a CLI executable.
148
171
 
172
+ Acknowledgements
173
+ ----------------
174
+
175
+ The logo for Stubb was kindly provided by Andres Colmenares of [Wawawiwa](https://www.facebook.com/pages/Wawawiwa-design/201009879921770).
176
+
149
177
  License
150
178
  -------
151
179
 
data/lib/stubb/finder.rb CHANGED
@@ -3,7 +3,7 @@ module Stubb
3
3
  class NotFound < Exception; end
4
4
 
5
5
  class Finder
6
-
6
+
7
7
  attr_accessor :request, :root
8
8
 
9
9
  def initialize(options = {})
@@ -35,7 +35,7 @@ module Stubb
35
35
  ).finish
36
36
  rescue NotFound => e
37
37
  debug e.message
38
- [404, {}, e.message]
38
+ [404, {}, [e.message]]
39
39
  end
40
40
 
41
41
  def request_options_as_file_ending
@@ -17,7 +17,7 @@ module Stubb
17
17
  elsif match = matching_file(built_path)
18
18
  last_is_dir = false
19
19
  else
20
- raise NoMatch
20
+ raise NoMatch.new("Not found.")
21
21
  end
22
22
 
23
23
  built_path << match
data/lib/stubb/request.rb CHANGED
@@ -3,7 +3,7 @@ module Stubb
3
3
  class Request < Rack::Request
4
4
 
5
5
  def path_parts
6
- relative_path.split '/'
6
+ relative_path.empty? ? [''] : relative_path.split('/')
7
7
  end
8
8
 
9
9
  def path_dir_parts
@@ -29,7 +29,7 @@ module Stubb
29
29
  end
30
30
 
31
31
  def literal_directory(current_path, level)
32
- File.directory?(local_path_for(current_path + [level])) ? level: nil
32
+ File.directory?(local_path_for(current_path + [level])) ? level : nil
33
33
  end
34
34
 
35
35
  def literal_file(current_path, level, index)
data/lib/stubb.rb CHANGED
@@ -2,7 +2,7 @@ require 'rack'
2
2
 
3
3
  module Stubb
4
4
 
5
- VERSION = '0.1.rc.1'
5
+ VERSION = '0.1.0'
6
6
 
7
7
  class ResponseNotFound < Exception
8
8
  end
metadata CHANGED
@@ -1,14 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stubb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424239
5
- prerelease: true
6
- segments:
7
- - 0
8
- - 1
9
- - rc
10
- - 1
11
- version: 0.1.rc.1
4
+ prerelease:
5
+ version: 0.1.0
12
6
  platform: ruby
13
7
  authors:
14
8
  - Johannes Emerich
@@ -16,53 +10,41 @@ autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
12
 
19
- date: 2012-02-24 00:00:00 +01:00
20
- default_executable:
13
+ date: 2012-04-05 00:00:00 Z
21
14
  dependencies:
22
15
  - !ruby/object:Gem::Dependency
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ name: rake
17
+ requirement: &id001 !ruby/object:Gem::Requirement
24
18
  none: false
25
19
  requirements:
26
20
  - - ">="
27
21
  - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
22
  version: "0"
32
- requirement: *id001
33
- name: rake
34
23
  type: :development
35
24
  prerelease: false
25
+ version_requirements: *id001
36
26
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
27
+ name: rack
28
+ requirement: &id002 !ruby/object:Gem::Requirement
38
29
  none: false
39
30
  requirements:
40
31
  - - ">="
41
32
  - !ruby/object:Gem::Version
42
- hash: 31
43
- segments:
44
- - 1
45
- - 2
46
- - 0
47
33
  version: 1.2.0
48
- requirement: *id002
49
- name: rack
50
34
  type: :runtime
51
35
  prerelease: false
36
+ version_requirements: *id002
52
37
  - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
38
+ name: thor
39
+ requirement: &id003 !ruby/object:Gem::Requirement
54
40
  none: false
55
41
  requirements:
56
42
  - - ">="
57
43
  - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
44
  version: "0"
62
- requirement: *id003
63
- name: thor
64
45
  type: :runtime
65
46
  prerelease: false
47
+ version_requirements: *id003
66
48
  description: Stubb is the second mate.
67
49
  email: johannes@emerich.de
68
50
  executables:
@@ -85,7 +67,6 @@ files:
85
67
  - bin/stubb
86
68
  - LICENSE
87
69
  - README.markdown
88
- has_rdoc: true
89
70
  homepage: http://github.com/knuton/stubb
90
71
  licenses: []
91
72
 
@@ -99,25 +80,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
80
  requirements:
100
81
  - - ">="
101
82
  - !ruby/object:Gem::Version
102
- hash: 3
83
+ hash: -706694363361650737
103
84
  segments:
104
85
  - 0
105
86
  version: "0"
106
87
  required_rubygems_version: !ruby/object:Gem::Requirement
107
88
  none: false
108
89
  requirements:
109
- - - ">"
90
+ - - ">="
110
91
  - !ruby/object:Gem::Version
111
- hash: 25
92
+ hash: -706694363361650737
112
93
  segments:
113
- - 1
114
- - 3
115
- - 1
116
- version: 1.3.1
94
+ - 0
95
+ version: "0"
117
96
  requirements: []
118
97
 
119
98
  rubyforge_project:
120
- rubygems_version: 1.3.7
99
+ rubygems_version: 1.8.11
121
100
  signing_key:
122
101
  specification_version: 3
123
102
  summary: Specify REST API stubs using your file system