actionframework-baseapi 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.
- checksums.yaml +15 -0
- data/lib/actionframework/baseapi.rb +49 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmYwOWNhMTE1YjE4YzRkNTk5ZDM5NWZlMjc4Y2U0ODRkZjRmOWZhYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
N2RjMmE1MzlmMzAzMjRhZGEzMTc0YzJkODI1YzdiNDJjMTllZWUxZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjUxMzY3ZWY2MTFmNmNhZDRlYmYyNTcyNWU3ZmY5OTVkNjMwNzYxOTU1NjA1
|
10
|
+
NGE5MjNiM2JmOThjYjczMDExZWFjMDgwYWJiN2QyMzk3NmI0ZTRjYzgyMDQ5
|
11
|
+
M2ZkOWM5M2VhOTViNDRkZTQ4YTI1N2QxNzk4YmQ0NGFhZjFjNmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmIzNjQ3ZGUwMWY2MTAwYzY5ZmUzYTU3OWFjNWJkMDZmMTFkNGZhZDE1ZjQ5
|
14
|
+
M2RhZjk1YjYxMTlmNmU5NWFjMWVhNWEzMGQ1YmExNzFkZWY1Zjk3NmEyNWM3
|
15
|
+
ZDkwYmQ1ZTJlNWZmYjMzOGQwYzQ1OGRlN2NjOTJmYjkxZjk1ZTQ=
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rack'
|
2
|
+
module ActionFramework
|
3
|
+
class BaseAPI
|
4
|
+
def initialize
|
5
|
+
api_init
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :config,:routes
|
10
|
+
|
11
|
+
def config key,value
|
12
|
+
@config[key] = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def api_init
|
16
|
+
@routes = {}
|
17
|
+
@config = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def api suffix,method
|
21
|
+
if(@config[:json] == true)
|
22
|
+
prefix = "/json/"
|
23
|
+
end
|
24
|
+
@routes[method] = prefix+(suffix.to_s.gsub("_","/"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def call env
|
28
|
+
@request = Rack::Request.new env
|
29
|
+
@response = Rack::Response.new
|
30
|
+
|
31
|
+
if(@routes[@request.method].nil?)
|
32
|
+
@response.write "404 Not Found"
|
33
|
+
return @response.finish
|
34
|
+
end
|
35
|
+
methodname = @routes[method].split("/")
|
36
|
+
response = self.send(methodname[methodname.length-1])
|
37
|
+
if(@config[:json] == true)
|
38
|
+
response = response.to_json
|
39
|
+
end
|
40
|
+
@response.write response
|
41
|
+
@response.finish
|
42
|
+
end
|
43
|
+
|
44
|
+
def params
|
45
|
+
@request.params
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionframework-baseapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bram Vandenbogaerde
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ActionFramework class to create simple API's (kind of like Grape)
|
14
|
+
email: ''
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/actionframework/baseapi.rb
|
20
|
+
homepage: https://rubygems.org/gems/example
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.1
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: ActionFramework BaseAPI
|
44
|
+
test_files: []
|
45
|
+
has_rdoc:
|