wd_sinatra 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +10 -1
- data/bin/wd_sinatra +3 -4
- data/lib/wd_sinatra/version.rb +1 -1
- data/templates/Thorfile +59 -0
- data/templates/test/test_helpers.rb +1 -0
- metadata +64 -41
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -42,6 +42,16 @@ While it's a nice feature to have, a lot of developers like to do that
|
|
42
42
|
differently and it seems more sensitive to let them pick the way they
|
43
43
|
like the most.
|
44
44
|
|
45
|
+
|
46
|
+
### Generating a new service
|
47
|
+
|
48
|
+
You need to have thor installed for that, you might want to add it yo
|
49
|
+
your gemfile.
|
50
|
+
|
51
|
+
$ thor :service get /foo/bar foo_bar.rb
|
52
|
+
|
53
|
+
This command will create a service and a failing test for it.
|
54
|
+
|
45
55
|
### Console
|
46
56
|
|
47
57
|
$ bundle exec bin/console
|
@@ -130,7 +140,6 @@ properly composed:
|
|
130
140
|
TestApi.post '/people/:id', :id => 123
|
131
141
|
```
|
132
142
|
|
133
|
-
|
134
143
|
## Writing a service
|
135
144
|
|
136
145
|
TODO see Weasel Diesel for now and the generated service example.
|
data/bin/wd_sinatra
CHANGED
@@ -40,10 +40,9 @@ class WdSinatra < Thor::Group
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def create_files
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
copy_file "Guardfile", "#{name}/Guardfile"
|
43
|
+
%W{Rakefile Gemfile config.ru Guardfile Thorfile}.each do |filename|
|
44
|
+
copy_file filename, "#{name}/#{filename}"
|
45
|
+
end
|
47
46
|
end
|
48
47
|
|
49
48
|
end
|
data/lib/wd_sinatra/version.rb
CHANGED
data/templates/Thorfile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require 'bundler'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
|
6
|
+
class Default < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc "service VERB URI FILENAME", "Generate scaffolding for a new service"
|
10
|
+
def service(verb, route, path)
|
11
|
+
route = route.gsub(/^\//, "") # strip leading forward slash
|
12
|
+
path_without_suffix = path.gsub(/\.rb$/, "")
|
13
|
+
create_file(File.join("api", "#{path_without_suffix}.rb")) do
|
14
|
+
<<-RUBY.gsub(/^\s{6}/, '')
|
15
|
+
describe_service "#{route}" do |service|
|
16
|
+
service.formats :json
|
17
|
+
service.http_verb :#{verb.downcase}
|
18
|
+
service.disable_auth # on by default
|
19
|
+
|
20
|
+
# INPUT
|
21
|
+
service.param.string :name, :default => 'World', :doc => "The name of the person to greet."
|
22
|
+
|
23
|
+
# OUTPUT
|
24
|
+
service.response do |response|
|
25
|
+
response.object do |obj|
|
26
|
+
obj.string :message, :doc => "The greeting message sent back. Defaults to 'World'"
|
27
|
+
obj.datetime :at, :doc => "The timestamp of when the message was dispatched"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# DOCUMENTATION
|
32
|
+
service.documentation do |doc|
|
33
|
+
doc.overall "This service provides a simple hello world implementation example."
|
34
|
+
doc.example "<code>curl -I 'http://localhost:9292/hello_world?name=Matt'</code>"
|
35
|
+
end
|
36
|
+
|
37
|
+
# ACTION/IMPLEMENTATION
|
38
|
+
service.implementation do
|
39
|
+
halt 501, "Not Implemented, which is a pity, I'm sure"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
RUBY
|
43
|
+
end
|
44
|
+
|
45
|
+
class_name = path_without_suffix.classify.gsub(/::/, '') # strip modules; just want a unique class name for spec
|
46
|
+
create_file(File.join("test", "integration", "#{path_without_suffix}_test.rb")) do
|
47
|
+
<<-RUBY.gsub(/^\s{6}/, '')
|
48
|
+
require 'test_helpers'
|
49
|
+
|
50
|
+
class #{class_name}Spec < MiniTest::Spec
|
51
|
+
it "performs request" do
|
52
|
+
TestApi.#{verb} "/#{route}", {}
|
53
|
+
assert_api_response
|
54
|
+
end
|
55
|
+
end
|
56
|
+
RUBY
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,47 +1,60 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wd_sinatra
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Matt Aimonetti
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-06-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: weasel_diesel
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
22
32
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
26
35
|
name: thor
|
27
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
38
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
33
46
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
apps using the Weasel Diesel DSL
|
38
|
-
email:
|
47
|
+
version_requirements: *id002
|
48
|
+
description: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps using the Weasel Diesel DSL
|
49
|
+
email:
|
39
50
|
- mattaimonetti@gmail.com
|
40
|
-
executables:
|
51
|
+
executables:
|
41
52
|
- wd_sinatra
|
42
53
|
extensions: []
|
54
|
+
|
43
55
|
extra_rdoc_files: []
|
44
|
-
|
56
|
+
|
57
|
+
files:
|
45
58
|
- .gitignore
|
46
59
|
- CHANGELOG.md
|
47
60
|
- Gemfile
|
@@ -58,6 +71,7 @@ files:
|
|
58
71
|
- templates/Gemfile
|
59
72
|
- templates/Guardfile
|
60
73
|
- templates/Rakefile
|
74
|
+
- templates/Thorfile
|
61
75
|
- templates/api/hello_world.rb
|
62
76
|
- templates/bin/console
|
63
77
|
- templates/config.ru
|
@@ -133,27 +147,36 @@ files:
|
|
133
147
|
- wd-sinatra.gemspec
|
134
148
|
homepage: https://github.com/mattetti/wd_sinatra
|
135
149
|
licenses: []
|
150
|
+
|
136
151
|
post_install_message:
|
137
152
|
rdoc_options: []
|
138
|
-
|
153
|
+
|
154
|
+
require_paths:
|
139
155
|
- lib
|
140
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
157
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
|
146
|
-
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
hash: 3
|
162
|
+
segments:
|
163
|
+
- 0
|
164
|
+
version: "0"
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
166
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
hash: 3
|
171
|
+
segments:
|
172
|
+
- 0
|
173
|
+
version: "0"
|
152
174
|
requirements: []
|
175
|
+
|
153
176
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.8.
|
177
|
+
rubygems_version: 1.8.18
|
155
178
|
signing_key:
|
156
179
|
specification_version: 3
|
157
|
-
summary: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps
|
158
|
-
using the Weasel Diesel DSL
|
180
|
+
summary: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps using the Weasel Diesel DSL
|
159
181
|
test_files: []
|
182
|
+
|