restpack_service 0.0.3
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 +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +45 -0
- data/lib/restpack_service.rb +6 -0
- data/lib/restpack_service/error.rb +10 -0
- data/lib/restpack_service/response.rb +17 -0
- data/lib/restpack_service/service.rb +52 -0
- data/lib/restpack_service/version.rb +3 -0
- data/restpack_service.gemspec +27 -0
- data/spec/error_spec.rb +5 -0
- data/spec/response_spec.rb +5 -0
- data/spec/service_spec.rb +5 -0
- data/spec/spec_helper.rb +1 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fccc635463c097450ec18bd8b93f28bd9aa770e7
|
4
|
+
data.tar.gz: 7603f27dd19425b7407b891223d0d74810a9f0e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4af0651557c054af80f29c0498f9a244f5c934c8891bb1d4daa9c4c17156a5aa0afd5f32261c012101ebd1388094f34371ad63dbb41c1747372e2e41bac0801c
|
7
|
+
data.tar.gz: 399c04a95dc434872016d2469d943c0eb94d660916638a24a05a8695eb7da958f27c3c69f9ccc3e6e15e6ffd9c69e91dbd48fc99f37ac8d59b90fc309278ebc2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Gavin Joyce
|
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,29 @@
|
|
1
|
+
# RestpackService
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'restpack_service'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install restpack_service
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'bump/tasks'
|
3
|
+
|
4
|
+
task :default => :test
|
5
|
+
task :test => :spec
|
6
|
+
|
7
|
+
begin
|
8
|
+
require "rspec/core/rake_task"
|
9
|
+
|
10
|
+
desc "Run all specs"
|
11
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
12
|
+
t.rspec_opts = ['-cfs']
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
task :gem do
|
19
|
+
["gem:bump", "gem:tag", "gem:build", "gem:push"].each do |task|
|
20
|
+
Rake::Task[task].reenable
|
21
|
+
Rake::Task[task].invoke
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :gem do
|
26
|
+
task :build do
|
27
|
+
sh "gem build restpack_service.gemspec"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :push do
|
31
|
+
require 'bump'
|
32
|
+
sh "gem push restpack_service-#{Bump::Bump.current}.gem"
|
33
|
+
end
|
34
|
+
|
35
|
+
task :tag do
|
36
|
+
require 'bump'
|
37
|
+
version = Bump::Bump.current
|
38
|
+
puts "tagging v#{version}"
|
39
|
+
`git push && git tag v#{version} && git push --tags`
|
40
|
+
end
|
41
|
+
|
42
|
+
task :bump do
|
43
|
+
Rake::Task["bump:patch"].invoke
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RestPack
|
2
|
+
class Response
|
3
|
+
attr_accessor :result, :errors, :status
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@errors = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def success?
|
10
|
+
@errors.empty? and @status == :success
|
11
|
+
end
|
12
|
+
|
13
|
+
def field_errors(key)
|
14
|
+
@errors.select { |error| error.key.to_sym == key.to_sym }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module RestPack
|
2
|
+
class Service < Mutations::Command
|
3
|
+
attr_accessor :response
|
4
|
+
|
5
|
+
def run
|
6
|
+
@response = Response.new
|
7
|
+
|
8
|
+
begin
|
9
|
+
init
|
10
|
+
mutation = super
|
11
|
+
|
12
|
+
if mutation.errors
|
13
|
+
mutation.errors.message.each do |error|
|
14
|
+
@response.errors << Error.new(error[0], error[1].gsub(error[0].capitalize, ''))
|
15
|
+
end
|
16
|
+
|
17
|
+
@response.status ||= :unprocessable_entity
|
18
|
+
else
|
19
|
+
@response.status ||= :success
|
20
|
+
end
|
21
|
+
|
22
|
+
if @response.status == :success
|
23
|
+
@response.result = mutation.result
|
24
|
+
end
|
25
|
+
rescue
|
26
|
+
@response.errors << Error.new(:base, 'Service Error')
|
27
|
+
@response.status = :internal_service_error
|
28
|
+
end
|
29
|
+
|
30
|
+
@response
|
31
|
+
end
|
32
|
+
|
33
|
+
def init
|
34
|
+
end
|
35
|
+
|
36
|
+
def status(status)
|
37
|
+
@response.status = status
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid?
|
41
|
+
!has_errors?
|
42
|
+
end
|
43
|
+
|
44
|
+
def service_error(message)
|
45
|
+
field_error :base, message
|
46
|
+
end
|
47
|
+
|
48
|
+
def field_error(key, message)
|
49
|
+
add_error key, key, message
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'restpack_service/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "restpack_service"
|
8
|
+
spec.version = RestpackService::VERSION
|
9
|
+
spec.authors = ["Gavin Joyce"]
|
10
|
+
spec.email = ["gavinjoyce@gmail.com"]
|
11
|
+
spec.description = %q{RestPack service base}
|
12
|
+
spec.summary = %q{A base for RestPack services}
|
13
|
+
spec.homepage = "https://github.com/RestPack"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "mutations", "~> 0.6.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "bump", "~> 0.4"
|
27
|
+
end
|
data/spec/error_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'restpack_service'
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: restpack_service
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gavin Joyce
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mutations
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.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.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bump
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
description: RestPack service base
|
84
|
+
email:
|
85
|
+
- gavinjoyce@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/restpack_service.rb
|
97
|
+
- lib/restpack_service/error.rb
|
98
|
+
- lib/restpack_service/response.rb
|
99
|
+
- lib/restpack_service/service.rb
|
100
|
+
- lib/restpack_service/version.rb
|
101
|
+
- restpack_service.gemspec
|
102
|
+
- spec/error_spec.rb
|
103
|
+
- spec/response_spec.rb
|
104
|
+
- spec/service_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://github.com/RestPack
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.3
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: A base for RestPack services
|
130
|
+
test_files:
|
131
|
+
- spec/error_spec.rb
|
132
|
+
- spec/response_spec.rb
|
133
|
+
- spec/service_spec.rb
|
134
|
+
- spec/spec_helper.rb
|