helpstation 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af844a5e1a3e0032fadba5408b8db05619ac7f0d
4
+ data.tar.gz: 9d068182dd59f310b67b3991cd4f92988872c830
5
+ SHA512:
6
+ metadata.gz: e90170974a29ea0af256d79060a48855f377a96db297c4d6bc20a4ad070b5776a71c6aa831cd3a56ca1a37d9f15eb502126ed3949b5abcd91e984cfa5a10dd6d
7
+ data.tar.gz: adeab0cd8b5602b6aae4cc0b668323747523162fc4695b7be1f2c6eead0754ba71dfe77167cdee6da426fbf5b2c1f108e95d45fd4efe1facc75cc820b00e1b3c
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1 @@
1
+ helpstation
@@ -0,0 +1 @@
1
+ 2.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ # Specify your gem's dependencies in helpstation.gemspec
6
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Indrek Juhkam
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.
@@ -0,0 +1,77 @@
1
+ # Helpstation
2
+
3
+ Helps to unify SaleMove services
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'helpstation'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ TODO: Write proper usage instructions here
18
+
19
+ Example:
20
+ ```ruby
21
+ require 'helpstation'
22
+
23
+ class PersonFinder < Helpstation::Process
24
+ def call
25
+ person = env.db.find_person(input.fetch(:person_id))
26
+ success(input.merge(person: person))
27
+ end
28
+ end
29
+
30
+ class ExportReadinessChecker < Helpstation::Process
31
+ def call
32
+ person = input.fetch(:person)
33
+ if SomeClassThatChecksPersonExportReadiness.check?(person)
34
+ success(input)
35
+ else
36
+ error('not ready')
37
+ end
38
+ end
39
+ end
40
+
41
+ class PersonExporter < Helpstation::Action
42
+ def call
43
+ # ... export ...
44
+ success
45
+ end
46
+ end
47
+
48
+ class ExportEmailNotifier < Helpstation::Observer
49
+ def call
50
+ mailer.deliver('...') if success?
51
+ end
52
+ end
53
+
54
+ substation = Helpstation.build_substation(env)
55
+ substation.register(:export) do
56
+ process PersonFinder
57
+ process ExportReadinessChecker
58
+ call PersonExporter, Substation::Chain::EMPTY, ExportEmailNotifier
59
+ end
60
+
61
+ response = substation.call(:export, {person_id: 5})
62
+ if response.success?
63
+ puts 'Everything went fine'
64
+ do_something_with response.output
65
+ else
66
+ puts 'Got error'
67
+ end
68
+
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'helpstation/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'helpstation'
7
+ spec.version = Helpstation::VERSION
8
+ spec.authors = ['Indrek Juhkam']
9
+ spec.email = ['indrek@salemove.com']
10
+ spec.description = %q{Helps to unify SaleMove services}
11
+ spec.summary = %q{}
12
+ spec.homepage = ''
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
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 'substation', '~> 0.0', '>= 0.0.10'
21
+ end
@@ -0,0 +1,17 @@
1
+ require 'substation'
2
+
3
+ require_relative 'helpstation/version'
4
+ require_relative 'helpstation/evaluator'
5
+ require_relative 'helpstation/processor'
6
+ require_relative 'helpstation/action'
7
+ require_relative 'helpstation/observer'
8
+ require_relative 'helpstation/legacy_process'
9
+
10
+ module Helpstation
11
+ def self.build_substation(env)
12
+ Substation::Environment.build(env) do
13
+ register :process, Substation::Processor::Evaluator::Request
14
+ register :call, Substation::Processor::Evaluator::Pivot
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Helpstation
2
+ class Action < Evaluator
3
+ def success(data)
4
+ @request.success({success: true}.merge(data))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ module Helpstation
2
+ class Evaluator
3
+ include AbstractType
4
+
5
+ # Perform the usecase
6
+ #
7
+ # @param [Substation::Request] request
8
+ # the request passed to the registered action
9
+ #
10
+ # @return [Substation::Response]
11
+ # the response returned when calling the action
12
+ #
13
+ # @api private
14
+ def self.call(request)
15
+ new(request).call
16
+ end
17
+
18
+ def initialize(request)
19
+ @request = request
20
+ @env = request.env
21
+ @input = request.input
22
+ end
23
+
24
+ abstract_method :call
25
+
26
+ private
27
+
28
+ attr_reader :request
29
+ attr_reader :env
30
+ attr_reader :input
31
+
32
+ def error(data)
33
+ @request.error(success: false, error: data)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,8 @@
1
+ module Helpstation
2
+ class LegacyProcess
3
+ def self.call(request)
4
+ result = process(request.env, request.input)
5
+ result[:success] ? request.success(result) : request.error(result)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ module Helpstation
2
+ class Observer
3
+ include AbstractType
4
+
5
+ # Perform the observer
6
+ #
7
+ # @param [Substation::Response]
8
+ # the response returned when calling the action
9
+ #
10
+ # @api private
11
+ def self.call(response)
12
+ new(response).call
13
+ end
14
+
15
+ def initialize(response)
16
+ @response = response
17
+ @env = response.env
18
+ @input = response.input
19
+ @output = response.output
20
+ @request = response.request
21
+ end
22
+
23
+ abstract_method :call
24
+
25
+ private
26
+
27
+ attr_reader :env
28
+ attr_reader :input
29
+ attr_reader :output
30
+
31
+ def success?
32
+ @response.success?
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Helpstation
2
+ class Processor < Evaluator
3
+ def success(data)
4
+ @request.success(data)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Helpstation
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: helpstation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Indrek Juhkam
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: substation
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.10
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.10
33
+ description: Helps to unify SaleMove services
34
+ email:
35
+ - indrek@salemove.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - ".ruby-gemset"
42
+ - ".ruby-version"
43
+ - Gemfile
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - helpstation.gemspec
48
+ - lib/helpstation.rb
49
+ - lib/helpstation/action.rb
50
+ - lib/helpstation/evaluator.rb
51
+ - lib/helpstation/legacy_process.rb
52
+ - lib/helpstation/observer.rb
53
+ - lib/helpstation/processor.rb
54
+ - lib/helpstation/version.rb
55
+ homepage: ''
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.2.2
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: ''
79
+ test_files: []