operation 1.0.0 → 1.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 +4 -4
- data/lib/operation/core.rb +55 -0
- data/lib/operation/version.rb +1 -1
- data/lib/operation-rubymotion.rb +17 -0
- data/lib/operation.rb +1 -55
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16871a2f93e5608a23dc10a8ccfb3de5fb37df9
|
4
|
+
data.tar.gz: 23b0b796463017ce54f3be27b7e71fa2b469d641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da5a591a9b5c684cd762c5c5b484463328f11667a11d987e360e8975f57722e639a19e3144049317f0344ec3f2eac258b616d36610f9aa0751134b8c9c51c44
|
7
|
+
data.tar.gz: 33f699336e965f229c8a8c790bfa3b2cadfbf664306b59b256deb7dfcd2c3876a006e565d9d78fc5507d462e74dc77fa8e2af3cb84c43098cd74d980fed6cd35
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Operation
|
2
|
+
include ::Operation::Deferrable
|
3
|
+
attr_reader :metadata, :code
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def success?
|
10
|
+
[true, 'true', 1, '1'].include? options[:success]
|
11
|
+
end
|
12
|
+
|
13
|
+
def failure?
|
14
|
+
!success?
|
15
|
+
end
|
16
|
+
|
17
|
+
def code
|
18
|
+
return if options[:code].to_s == ''
|
19
|
+
options[:code].to_s.to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
# Convenience Wrapper
|
23
|
+
def object
|
24
|
+
meta[:object] || meta['object'] || meta.object
|
25
|
+
rescue
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def metadata
|
30
|
+
options[:metadata]
|
31
|
+
end
|
32
|
+
|
33
|
+
def meta
|
34
|
+
if defined? Hashie::Mash
|
35
|
+
metamash
|
36
|
+
else
|
37
|
+
metadata
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def metamash
|
42
|
+
if metadata.respond_to? :each_pair
|
43
|
+
Hashie::Mash.new metadata
|
44
|
+
elsif metadata
|
45
|
+
metadata
|
46
|
+
else
|
47
|
+
Hashie::Mash.new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
attr_reader :options
|
54
|
+
|
55
|
+
end
|
data/lib/operation/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
unless defined? Motion::Project::Config
|
2
|
+
fail 'This file must be required within a RubyMotion project Rakefile'
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'pathname'
|
6
|
+
lib = Pathname.new File.expand_path('..', __FILE__)
|
7
|
+
|
8
|
+
paths = lib.find.map do |path|
|
9
|
+
next unless path.extname == '.rb'
|
10
|
+
next if path.basename.to_s == 'operation.rb'
|
11
|
+
next if path.basename.to_s == 'operation-rubymotion.rb'
|
12
|
+
path.to_s
|
13
|
+
end.compact
|
14
|
+
|
15
|
+
Motion::Project::App.setup do |app|
|
16
|
+
app.files << paths
|
17
|
+
end
|
data/lib/operation.rb
CHANGED
@@ -1,59 +1,5 @@
|
|
1
1
|
require 'operation/deferrable'
|
2
2
|
require 'operation/progress'
|
3
|
+
require 'operation/core'
|
3
4
|
require 'operations'
|
4
5
|
|
5
|
-
class Operation
|
6
|
-
include ::Operation::Deferrable
|
7
|
-
attr_reader :metadata, :code
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def success?
|
14
|
-
[true, 'true', 1, '1'].include? options[:success]
|
15
|
-
end
|
16
|
-
|
17
|
-
def failure?
|
18
|
-
!success?
|
19
|
-
end
|
20
|
-
|
21
|
-
def code
|
22
|
-
return if options[:code].to_s == ''
|
23
|
-
options[:code].to_s.to_sym
|
24
|
-
end
|
25
|
-
|
26
|
-
# Convenience Wrapper
|
27
|
-
def object
|
28
|
-
meta[:object] || meta['object'] || meta.object
|
29
|
-
rescue
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
def metadata
|
34
|
-
options[:metadata]
|
35
|
-
end
|
36
|
-
|
37
|
-
def meta
|
38
|
-
if defined? Hashie::Mash
|
39
|
-
metamash
|
40
|
-
else
|
41
|
-
metadata
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def metamash
|
46
|
-
if metadata.respond_to? :each_pair
|
47
|
-
Hashie::Mash.new metadata
|
48
|
-
elsif metadata
|
49
|
-
metadata
|
50
|
-
else
|
51
|
-
Hashie::Mash.new
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
attr_reader :options
|
58
|
-
|
59
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: operation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halo
|
@@ -76,7 +76,9 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- README.md
|
78
78
|
- Rakefile
|
79
|
+
- lib/operation-rubymotion.rb
|
79
80
|
- lib/operation.rb
|
81
|
+
- lib/operation/core.rb
|
80
82
|
- lib/operation/deferrable.rb
|
81
83
|
- lib/operation/progress.rb
|
82
84
|
- lib/operation/version.rb
|