asyncable 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/asyncable.gemspec +32 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/asyncable/version.rb +3 -0
- data/lib/asyncable.rb +75 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aabe4e759a2c4de508c15a37967de123dfcdc14b
|
4
|
+
data.tar.gz: a0279830b3c30b57f313aa66860ab731ee76ce95
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aac35efbe2799031d8546f973ec6aafb707fbce7afb8d027af589f30347c85569328077092840e93d92e4b6908857f11339ad2c295cdde7ee77ed7010b8f2feb
|
7
|
+
data.tar.gz: 7c125fc7fdffc1e94fed3dd97e5cc4fd81487a99e972ca4d05645d0311c43acc45ee2c37ed5f540697381d1f801ab666d6e7bc81d2f4ed628b9ea63fe80c7438
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Asyncable
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asyncable`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'asyncable'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install asyncable
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/asyncable.
|
36
|
+
|
data/Rakefile
ADDED
data/asyncable.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'asyncable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "asyncable"
|
8
|
+
spec.version = Asyncable::VERSION
|
9
|
+
spec.authors = ["Ryan Francis"]
|
10
|
+
spec.email = ["ryan@launchpadlab.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Handle async operations with ease}
|
13
|
+
spec.description = %q{Simple ruby gem to provide an API for managing async processes}
|
14
|
+
spec.homepage = "https://github.com/LaunchPadLab/asyncable"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "asyncable"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/asyncable.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "asyncable/version"
|
2
|
+
|
3
|
+
module Asyncable
|
4
|
+
module Statuses
|
5
|
+
PROCESSING = 'processing'
|
6
|
+
FAILED = 'failed'
|
7
|
+
SUCCEEDED = 'succeeded'
|
8
|
+
end
|
9
|
+
|
10
|
+
# === CLASS HOOKS ===
|
11
|
+
def self.handle_asynchronously(method)
|
12
|
+
end
|
13
|
+
# === END CLASS HOOKS ===
|
14
|
+
|
15
|
+
def start_async
|
16
|
+
self.status = Statuses::PROCESSING
|
17
|
+
save
|
18
|
+
process_in_background
|
19
|
+
end
|
20
|
+
|
21
|
+
def succeeded?
|
22
|
+
status == Statuses::SUCCEEDED
|
23
|
+
end
|
24
|
+
|
25
|
+
def failed?
|
26
|
+
status == Statuses::FAILED
|
27
|
+
end
|
28
|
+
|
29
|
+
def processing?
|
30
|
+
status == Statuses::PROCESSING
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def process_in_background
|
36
|
+
begin
|
37
|
+
async_operation
|
38
|
+
complete!
|
39
|
+
rescue Exception => e
|
40
|
+
failed!(e)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
handle_asynchronously :process_in_background
|
44
|
+
|
45
|
+
|
46
|
+
def complete!
|
47
|
+
self.status = Statuses::SUCCEEDED
|
48
|
+
save
|
49
|
+
after_async_complete
|
50
|
+
end
|
51
|
+
|
52
|
+
def failed!(error)
|
53
|
+
self.status = Statuses::FAILED
|
54
|
+
save
|
55
|
+
handle_async_error(error)
|
56
|
+
end
|
57
|
+
|
58
|
+
# === INTERFACE ===
|
59
|
+
def async_operation
|
60
|
+
fail "async_operation method is required for #{self.class.name}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def save
|
64
|
+
fail "save method is required for #{self.class.name}"
|
65
|
+
end
|
66
|
+
# === END INTERFACE ===
|
67
|
+
|
68
|
+
# === HOOKS ===
|
69
|
+
def after_async_complete
|
70
|
+
end
|
71
|
+
|
72
|
+
def handle_async_error(_error)
|
73
|
+
end
|
74
|
+
# === END HOOKS ===
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asyncable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Francis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Simple ruby gem to provide an API for managing async processes
|
56
|
+
email:
|
57
|
+
- ryan@launchpadlab.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- asyncable.gemspec
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/asyncable.rb
|
72
|
+
- lib/asyncable/version.rb
|
73
|
+
homepage: https://github.com/LaunchPadLab/asyncable
|
74
|
+
licenses: []
|
75
|
+
metadata:
|
76
|
+
allowed_push_host: https://rubygems.org
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.5.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Handle async operations with ease
|
97
|
+
test_files: []
|