lite-service 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fef72613a3855f7613eebeb6b95aaf8663c7ba6948039cd5a32f2fd979364c0b
4
- data.tar.gz: d9e76c6c96391ba5f5c079a10b9fb42d1762fca9c0cd6e6081bdf97e7841c84e
3
+ metadata.gz: 5e6494a1b7ccefe36f2aee1a17040806bb8c4d80a737a26d0e19fedecfd79b68
4
+ data.tar.gz: f03bbccc41398f75e59182e7177c580e7b54efa9e189795a2f4cf9665ab472bc
5
5
  SHA512:
6
- metadata.gz: 7f82374c5b0d24533ef372e6c92df5f8f89f0099824eda0a06d7cf4a1e32d626e63a9907434ce8b84a29ec3b211a6ba79a597124755c3c2936ef98a4fed50976
7
- data.tar.gz: bc1daa4f5de2a1c39fc6ec520ec3fee460094c6c6ac0ab561c65f13485f041eb0287bf6545a94ac65b0886f27abd6950e0c7e1c954c444a1ff0f147c13ca1f86
6
+ metadata.gz: 911d83e318b8878da98e35808b4121baf0c2661299eed3c8cc9e7fe94ce08faf8c867835a8f8ea059c53e41ea10ae4d4ef1e11316371001774eaf1f360f1cdc1
7
+ data.tar.gz: 9d292b6f38cd39b008c10f90c09bfc9aaa789851c4edc08a88bb122aa095896338e2a4aeb16bf5280e4cb4d47597844b4a82c6f891b90a5e61b417876a154d21
@@ -11,7 +11,7 @@ Layout/EmptyLinesAroundBlockBody:
11
11
  Exclude:
12
12
  - 'spec/**/**/*'
13
13
  Layout/EmptyLinesAroundClassBody:
14
- EnforcedStyle: empty_lines
14
+ EnforcedStyle: empty_lines_except_namespace
15
15
  Layout/EmptyLinesAroundModuleBody:
16
16
  EnforcedStyle: empty_lines_except_namespace
17
17
  Metrics/BlockLength:
@@ -1,21 +1,24 @@
1
- ---
2
1
  sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
6
- - 2.5
7
- - 2.6
8
- - ruby-head
5
+ - 2.5
6
+ - 2.6
7
+ - ruby-head
9
8
  matrix:
10
9
  fast_finish: true
11
10
  allow_failures:
12
- - rvm: ruby-head
11
+ - rvm: ruby-head
13
12
  before_install:
14
- - gem update --system
15
- - gem install bundler
13
+ - gem update --system
14
+ - gem install bundler
16
15
  install:
17
- - bundle install --jobs=3 --retry=3
16
+ - bundle install --jobs=3 --retry=3
18
17
  script:
19
- - bundle exec rspec
20
- - bundle exec rubocop
21
- # - bundle exec fasterer
18
+ - bundle exec rspec
19
+ - bundle exec rubocop
20
+ - bundle exec fasterer
21
+ notifications:
22
+ email: false
23
+ slack:
24
+ secure: iKadv0MEoe97ue3H+UQQQXM0eVvNIQ9WPgNJd8BBF2WveIpUZD+jF1TxiRlyclQz8kkxLjUy+dRXZ0/Xywhexn5ItGJfGm43yZ51PIXOJ7JIAIOeAIWWdVfvnkB3X0Nvm1ClE0IgHi2aG5uLylX3S4khaQ4TcxDTebdM72cdUfdXKFBy8Rthd1lOdU8NML9pmfuClc3ymcbP9CWEGxOAbU+GBGmb1tRFKr3N1j7f9nbbLw8xXL6WjZwUmHG3LC5DYLSp6m7I1pgUVO2bZwFLwtaIGtRBCwmHwxKyHqJ/NIU8zl03ZCi4lkQW3EncAxQnugzxToBrWep/k5UO3fkVtjDliOHFvWYBpqrxJOnHx7RIvK3IGCKSkNQ1Fxfwjvq4PetIaXDGLAoy8c9k6HsINeemzB/+Np8TYkYWeOpbid/jfS+ZVmftGlVZD/+32WQ9PYts9y6xkt8kaNr7uuVSMS2CU/vt5STA3+YV3hvJJ/hjsg1ZflTOi5y4DBLwzQp02qlmzWduZRucRYwrvtjAitUmrwbUStPGjGq28ZzHJwC70OtN0QVn9tA16tb7WXtdGY3gvfbNG0AvE++5yXbQWmZN2XUXA2eqTjh3EDOvogFUNYTYyq68j7HeQSY3BnzoQZ/HEGEVDi5fOMnGVB1DG30ImqfMQe41e58OJUBGfXo=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-service (1.0.0)
4
+ lite-service (1.0.1)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
data/README.md CHANGED
@@ -35,14 +35,14 @@ Learn more about using memoization subclass in [Lite::Memoize](https://github.co
35
35
  and errors subclass [Lite::Errors](https://github.com/drexed/lite-errors).
36
36
 
37
37
  ```ruby
38
- class SearchMovies
39
- prepend Lite::Service::Command
38
+ class SearchMovies < Lite::Service::Command
40
39
 
41
40
  def initialize(name)
42
41
  @name = name
43
42
  end
44
43
 
45
- def call
44
+ # NOTE: This method is required to call the command
45
+ def run
46
46
  { generate_fingerprint => movies_by_name }
47
47
  end
48
48
 
@@ -70,12 +70,13 @@ service = SearchMovies.new('Toy Story')
70
70
  service.called? #=> false
71
71
  service.call #=> { 'fingerprint_1' => [ 'Toy Story 1', ... ] }
72
72
  service.called? #=> true
73
+ service.run #=> Returns a fresh uncached value
73
74
 
74
75
  # or
75
76
 
76
77
  service = SearchMovies.call('Toy Story')
77
78
  service.called? #=> true
78
- service.result #=> { 'fingerprint_1' => [ 'Toy Story 2', ... ] }
79
+ service.result #=> { 'fingerprint_1' => [ 'Toy Story 1', ... ] }
79
80
  ```
80
81
 
81
82
  **Cache**
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version command].each do |name|
3
+ %w[version exception command].each do |name|
4
4
  require "lite/service/#{name}"
5
5
  end
@@ -5,13 +5,9 @@ require 'lite/memoize'
5
5
 
6
6
  module Lite
7
7
  module Service
8
+ class Command
8
9
 
9
- class NotImplementedError < StandardError; end
10
- class ValidationError < StandardError; end
11
-
12
- module Command
13
-
14
- module ClassMethods
10
+ class << self
15
11
 
16
12
  def call(*args)
17
13
  klass = new(*args)
@@ -23,16 +19,16 @@ module Lite
23
19
 
24
20
  attr_reader :result
25
21
 
26
- def self.prepended(base)
27
- base.extend(ClassMethods)
22
+ def initialize(*args)
23
+ @args = args
28
24
  end
29
25
 
30
26
  def call
31
- raise Lite::Service::NotImplementedError unless defined?(super)
27
+ raise Lite::Service::NotImplementedError unless defined?(run)
32
28
  return @result if called?
33
29
 
34
30
  @called = true
35
- @result = super
31
+ @result = run
36
32
  end
37
33
 
38
34
  def cache
@@ -82,6 +78,5 @@ module Lite
82
78
  alias valid? validate!
83
79
 
84
80
  end
85
-
86
81
  end
87
82
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lite
4
+ module Service
5
+
6
+ class NotImplementedError < StandardError; end
7
+ class ValidationError < StandardError; end
8
+
9
+ end
10
+ end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Service
5
5
 
6
- VERSION ||= '1.0.0'
6
+ VERSION ||= '1.0.1'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-24 00:00:00.000000000 Z
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-errors
@@ -160,6 +160,7 @@ files:
160
160
  - bin/setup
161
161
  - lib/lite/service.rb
162
162
  - lib/lite/service/command.rb
163
+ - lib/lite/service/exception.rb
163
164
  - lib/lite/service/version.rb
164
165
  - lite-service.gemspec
165
166
  homepage: http://drexed.github.io/lite-service