rack-backend-api 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -1,5 +1,5 @@
1
1
  class BackendAPI
2
- VERSION = [0,3,4]
2
+ VERSION = [0,3,5]
3
3
  WRAP = <<-EOT
4
4
  <!doctype html>
5
5
  <html>
@@ -19,6 +19,7 @@ class BackendAPI
19
19
  def call!(env)
20
20
  @req = ::Rack::Request.new(env)
21
21
  @res = ::Rack::Response.new
22
+ @res.headers['Content-Type'] = 'text/html'
22
23
 
23
24
  # Simple dispatcher
24
25
  @model_name, @id, *a = @req.path_info.split('/').find_all{|s| s!=''}
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rack-backend-api'
3
- s.version = "0.3.4"
3
+ s.version = "0.3.5"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "A Rack middleware that provides a simple API for your Admin section"
6
6
  s.description = "The purpose of this Rack Middleware is to provide an API that interfaces with database actions in order to build a CMS."
@@ -9,4 +9,10 @@ Gem::Specification.new do |s|
9
9
  s.author = "Mickael Riga"
10
10
  s.email = "mig@mypeplum.com"
11
11
  s.homepage = "http://github.com/mig-hub/backend-api"
12
+
13
+ s.add_dependency('rack')
14
+ s.add_development_dependency('sqlite3')
15
+ s.add_development_dependency('sequel')
16
+ s.add_development_dependency('sequel-crushyform')
17
+ s.add_development_dependency('bacon')
12
18
  end
data/test/db.rb CHANGED
@@ -14,7 +14,7 @@ class Haiku < ::Sequel::Model
14
14
  plugin :crushyform
15
15
  many_to_one :author
16
16
  def validate
17
- errors[:title] << "Should start with a decent char" if title.to_s!='' && title[0]<65
17
+ errors[:title] << "Should not start with a number" if title.to_s.to_i!=0
18
18
  end
19
19
  def backend_show; 'Me, the Haiku'; end
20
20
  end
@@ -8,7 +8,7 @@ Bacon.summary_on_exit
8
8
  # Helpers
9
9
  F = ::File
10
10
  D = ::Dir
11
- ROOT = F.dirname(__FILE__)+'/..'
11
+ ROOT = F.expand_path(F.dirname(__FILE__)+'/..')
12
12
  def req_lint(app)
13
13
  ::Rack::MockRequest.new(::Rack::Lint.new(app))
14
14
  end
@@ -179,11 +179,15 @@ end
179
179
  describe 'API Get' do
180
180
 
181
181
  should "Return the form for a fresh entry when no id is provided" do
182
- req_lint(BackendAPI.new).get('/haiku').body.should==wrap('Haiku', Haiku.new.backend_form('/haiku'))
182
+ res = req_lint(BackendAPI.new).get('/haiku')
183
+ res.body.should==wrap('Haiku', Haiku.new.backend_form('/haiku'))
184
+ res.content_type.should=='text/html'
183
185
  end
184
186
 
185
187
  should "Return the form for an update when id is provided" do
186
- req_lint(BackendAPI.new).get('/haiku/3').body.should==wrap('Haiku', Haiku[3].backend_form('/haiku/3'))
188
+ res = req_lint(BackendAPI.new).get('/haiku/3')
189
+ res.body.should==wrap('Haiku', Haiku[3].backend_form('/haiku/3'))
190
+ res.content_type.should=='text/html'
187
191
  end
188
192
 
189
193
  should "Send a 404 if the entry does not exist" do
@@ -5,7 +5,7 @@ Bacon.summary_on_exit
5
5
  # Helpers
6
6
  F = ::File
7
7
  D = ::Dir
8
- ROOT = F.dirname(__FILE__)+'/..'
8
+ ROOT = F.expand_path(F.dirname(__FILE__)+'/..')
9
9
  $:.unshift ROOT+'/lib'
10
10
  require ROOT+'/test/db.rb'
11
11
  ::Sequel::Model.plugin :rack_backend_api_adapter
metadata CHANGED
@@ -1,32 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-backend-api
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 4
10
- version: 0.3.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mickael Riga
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-21 00:00:00 Z
19
- dependencies: []
20
-
21
- description: The purpose of this Rack Middleware is to provide an API that interfaces with database actions in order to build a CMS.
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sequel
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sequel-crushyform
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: bacon
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: The purpose of this Rack Middleware is to provide an API that interfaces
95
+ with database actions in order to build a CMS.
22
96
  email: mig@mypeplum.com
23
97
  executables: []
24
-
25
98
  extensions: []
26
-
27
99
  extra_rdoc_files: []
28
-
29
- files:
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
30
103
  - LICENSE
31
104
  - README.md
32
105
  - example/basic_admin.rb
@@ -39,36 +112,26 @@ files:
39
112
  - test/spec_sequel_adapter.rb
40
113
  homepage: http://github.com/mig-hub/backend-api
41
114
  licenses: []
42
-
43
115
  post_install_message:
44
116
  rdoc_options: []
45
-
46
- require_paths:
117
+ require_paths:
47
118
  - ./lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
119
+ required_ruby_version: !ruby/object:Gem::Requirement
49
120
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- hash: 3
54
- segments:
55
- - 0
56
- version: "0"
57
- required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
126
  none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
66
131
  requirements: []
67
-
68
132
  rubyforge_project:
69
- rubygems_version: 1.8.15
133
+ rubygems_version: 1.8.23
70
134
  signing_key:
71
135
  specification_version: 3
72
136
  summary: A Rack middleware that provides a simple API for your Admin section
73
137
  test_files: []
74
-