sinatra-rest-dsl 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5a779489378c2261dcb70ca7d77808ad4199a158ab8762e8ef2da697a0de8515
4
+ data.tar.gz: 7d12c722d5c7e115926cda101c3a72e85677e508fb08bfc940bf7729402e7a40
5
+ SHA512:
6
+ metadata.gz: 17e4242469962df355a857125fdbbd100b8d5eb795c86653b261b1f93fbb9ae84d09605dbbcacceaae7be776e0fd63dd154558fa07dcfa497cf160a38ef01832
7
+ data.tar.gz: 96058b7e0204aa3551986924127b43f854a31d70326b03b77978d4a268979e6dad2da5845ca178117de37a0da986f5560257e81c09e8e9c5096c0fccc3637cbc
@@ -0,0 +1,29 @@
1
+ require "dry/inflector"
2
+
3
+ module Sinatra
4
+ module Restful
5
+ class Resource
6
+ attr_accessor :model_class, :path_base
7
+
8
+ def self.inflector
9
+ @@inflector ||= Dry::Inflector.new
10
+ end
11
+
12
+ def initialize(model_class)
13
+ @model_class = model_class
14
+ @path_base = "/" + Resource.inflector.pluralize(@model_class.to_s).downcase
15
+ end
16
+
17
+ def path_id
18
+ "#{@path_base}/:id"
19
+ end
20
+
21
+ def add_routes(app)
22
+ path = self.path_id
23
+ app.get path do |id|
24
+ "hello world path:#{path} id:#{id}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ require 'sinatra/base'
2
+
3
+ LIBDIR = File.expand_path('./sinatra-restful', File.dirname(__FILE__))
4
+ Dir["#{LIBDIR}/**/*.rb"].each {|file| require file }
5
+
6
+ module Sinatra
7
+ module Restful
8
+
9
+ def resource(klass)
10
+ Resource.new(klass).add_routes(self)
11
+ end
12
+
13
+ def self.registered(app)
14
+ # app.helpers SessionAuth::Helpers
15
+ # app.set :username, 'frank'
16
+ # app.set :password, 'changeme'
17
+ end
18
+ end
19
+
20
+ register Restful
21
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-rest-dsl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chuck Smith
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: sinatra
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: dry-inflector
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.2'
40
+ description: 'Sinatra extension to create a RESTful API using the Sequel ORM '
41
+ email: chuck@pinchaque.com
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - lib/sinatra-rest-dsl.rb
47
+ - lib/sinatra-rest-dsl/resource.rb
48
+ homepage: https://gitlab.com/pinchaque/sinatra-rest-dsl
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 3.4.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.6.7
67
+ specification_version: 4
68
+ summary: Sinatra extension to create a RESTful API using the Sequel ORM
69
+ test_files: []