logick 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/logick.rb +37 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15f68fea486324a27d99707d0a7237bf8cfe4ac3
4
+ data.tar.gz: 02f24d36d2fba5f6bfb3177a534677426d87680e
5
+ SHA512:
6
+ metadata.gz: f89cd35e76f5516720d957eeee17a5e9b3f4fde88189546331c4ebe9f13f892335e25af5e6b06e4b3c77582da5dd8ca3be8f7350bbf9e291236d51871acb5d04
7
+ data.tar.gz: 663c14d16639fdd343f332435a63cc2cf2d7879c33d42236d45e8d98bd2ce10d718c855d82d4bb6bb593721b16b171fc3f164deb9f3155ca74f9981e96ea40b6
@@ -0,0 +1,37 @@
1
+ require "scrivener"
2
+
3
+ class Logic
4
+ def self.perform(&block)
5
+ catch(:fail) { Result.new(type: :success, output: block.call) }
6
+ end
7
+
8
+ class Result
9
+ attr_accessor :type, :output, :errors
10
+
11
+ def initialize(atts)
12
+ @type = atts[:type]
13
+ @output = atts[:output]
14
+ @errors = atts[:errors]
15
+ end
16
+
17
+ def success?
18
+ @type == :success
19
+ end
20
+
21
+ def fail?
22
+ @type == :fail
23
+ end
24
+ end
25
+
26
+ class Scrivener < ::Scrivener
27
+ def self.run(atts)
28
+ scrivener = new(atts)
29
+
30
+ if !scrivener.valid?
31
+ throw(:fail, Result.new(type: :fail, errors: scrivener.errors))
32
+ end
33
+
34
+ scrivener.run
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Luis Vega
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: It's my first gem.
14
+ email: luiscvega@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/logick.rb
20
+ homepage: https://github.com/luiscvega/logick
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.1.11
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Logic for your code
44
+ test_files: []