eldr-action 0.0.1
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 +7 -0
- data/.gitignore +13 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/TODOS +5 -0
- data/eldr-action.gemspec +25 -0
- data/lib/eldr/action.rb +52 -0
- data/lib/eldr/action/version.rb +5 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cdfbd7148bb5c625b65f20da629729b154a3d3f4
|
4
|
+
data.tar.gz: fa734b4929d4017ef17bcadd8ef0619e97caa01c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bcb63c812b3582f9b7830917df3afadd33036e1bac0dfbc4515f0a13b544440d489e5090b6d60d3c7dfd85e68299373d070061894df421ef8ee5bf5ceb3e1771
|
7
|
+
data.tar.gz: 58eb09ac9c17985ba3b86103e2f17a2a067fc7197f54ac0068104a339b5e8db51670ff4276b3bc98b03d6520c0545fe6c4307432e6d2a97b94468fc69550a435
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
eldr-action (0.0.1)
|
5
|
+
activemodel (~> 4.2)
|
6
|
+
eldr (~> 0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (4.2.0)
|
12
|
+
activesupport (= 4.2.0)
|
13
|
+
builder (~> 3.1)
|
14
|
+
activesupport (4.2.0)
|
15
|
+
i18n (~> 0.7)
|
16
|
+
json (~> 1.7, >= 1.7.7)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
builder (3.2.2)
|
21
|
+
eldr (0.0.3)
|
22
|
+
fast_blank (= 0.0.2)
|
23
|
+
mustermann (= 0.4.0)
|
24
|
+
rack (~> 1.5)
|
25
|
+
fast_blank (0.0.2)
|
26
|
+
i18n (0.7.0)
|
27
|
+
json (1.8.2)
|
28
|
+
minitest (5.5.1)
|
29
|
+
mustermann (0.4.0)
|
30
|
+
tool (~> 0.2)
|
31
|
+
rack (1.6.0)
|
32
|
+
rake (10.4.2)
|
33
|
+
thread_safe (0.3.4)
|
34
|
+
tool (0.2.3)
|
35
|
+
tzinfo (1.2.2)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
bundler (~> 1.7)
|
43
|
+
eldr-action!
|
44
|
+
rake (~> 10.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 K-2052
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Eldr::Action
|
2
|
+
|
3
|
+
A simple action object for [Eldr](https://github.com/eldr-rb/eldr). You can include it and make any class compatible with an Eldr route. You'll get validations and params for free.
|
4
|
+
Eldr::Action's respond to `call(env)` and return a valid rack response.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'eldr-action'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install eldr-action
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Just include it your handler:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
module Cats
|
28
|
+
class Show
|
29
|
+
include Eldr::Action
|
30
|
+
|
31
|
+
def call(env)
|
32
|
+
@env = env
|
33
|
+
|
34
|
+
Rack::Response.new 'Found the cat!'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Then pass it to a route in an Eldr::App:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
class App < Eldr::App
|
44
|
+
get '/', Cats::Show.new
|
45
|
+
end
|
46
|
+
```
|
data/Rakefile
ADDED
data/TODOS
ADDED
data/eldr-action.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eldr/action/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eldr-action"
|
8
|
+
spec.version = Eldr::Action::VERSION
|
9
|
+
spec.authors = ["K-2052"]
|
10
|
+
spec.email = ["k@2052.me"]
|
11
|
+
spec.summary = %q{A simple action object for Eldr}
|
12
|
+
spec.homepage = "https://github.com/eldr-rb/eldr-action"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'eldr', '~> 0.0'
|
21
|
+
spec.add_dependency 'activemodel', '~> 4.2'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
data/lib/eldr/action.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
class Errors
|
5
|
+
def merge!(errors)
|
6
|
+
messages.merge!(errors.messages)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Eldr
|
12
|
+
module Action
|
13
|
+
def self.included(klass)
|
14
|
+
klass.include ActiveModel::Validations
|
15
|
+
klass.attr_accessor :configuration, :env, :status, :body, :header
|
16
|
+
end
|
17
|
+
|
18
|
+
def header
|
19
|
+
@header ||= {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
@body ||= ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def valid?
|
27
|
+
errors.count == 0
|
28
|
+
end
|
29
|
+
|
30
|
+
def params
|
31
|
+
env['eldr.params']
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.configuration
|
35
|
+
@configuration ||= Configuration.new()
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize(configuration: Configuration.new)
|
39
|
+
@configuration = configuration
|
40
|
+
@configuration.merge! self.class.configuration.to_h
|
41
|
+
end
|
42
|
+
|
43
|
+
def config
|
44
|
+
configuration
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_a
|
48
|
+
[status, header, [body]]
|
49
|
+
end3
|
50
|
+
alias_method :to_ary, :to_a
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eldr-action
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- K-2052
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: eldr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- k@2052.me
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- TODOS
|
83
|
+
- eldr-action.gemspec
|
84
|
+
- lib/eldr/action.rb
|
85
|
+
- lib/eldr/action/version.rb
|
86
|
+
homepage: https://github.com/eldr-rb/eldr-action
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: A simple action object for Eldr
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|