embed_callbacks 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30084b7f7b4e7428eab54df0b76aa442b48ed867e0f422d8f84495afbb5f8c3f
4
- data.tar.gz: 9961711ce671a6056ec9d18dc5d3ba4920588c7f46392abb56437799b7ed6ed6
3
+ metadata.gz: 990a9b6265950f2406a56fde7ab9da8577a995b8ee29fc63ea4b47c85c5e3660
4
+ data.tar.gz: 93c663f603dd6320b6e0a659e46e8587be2ab64eee4100fdcdf72235d74e6ba7
5
5
  SHA512:
6
- metadata.gz: e1bc18923a237a94070a290a62eb70adbb119b4790baaa4c2bf3bb7fd18170c3ac069e71660b5ba8873b7d97e34b08647ee2e567ca32e8eee04efb27ffc95bef
7
- data.tar.gz: c1267dafece5ce7a0f8e38c709bdf5c6c3ced181f3636c7661f3032b1a2912c10b10d1319f29a5bf786d96a0e0b132cba4416d21c8d5f075561a40bd546c0c84
6
+ metadata.gz: 5638de8723e24c36cbca0c4e891f61fe31f4edaa4a5a11bda7ab27517342093d407c7d24d545bebb35d25de10003089391bee6ff04b4068943511d64c4f84c3f
7
+ data.tar.gz: 01fad0491691b400a5ab73435c1f9aa5512a8d3987172bb4834760306c9a7462bd2790cf3c16567582be5f04b6780d8c2acf50c06f3b7c5929585d546203491a
@@ -0,0 +1,25 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ name: Publish
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: '3.1'
16
+ - name: Publish to RubyGems
17
+ run: |
18
+ mkdir -p $HOME/.gem
19
+ touch $HOME/.gem/credentials
20
+ chmod 0600 $HOME/.gem/credentials
21
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
22
+ gem build *.gemspec
23
+ gem push *.gem
24
+ env:
25
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -0,0 +1,32 @@
1
+ name: Test
2
+
3
+ on:
4
+ [ push, pull_request ]
5
+
6
+ jobs:
7
+ build:
8
+ name: RSpec test
9
+
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest, windows-latest]
14
+ ruby: [ '2.6', '2.7', '3.0', '3.1' ]
15
+
16
+ runs-on: ${{ matrix.os }}
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ gem install bundler --no-document
29
+ bundle install
30
+
31
+ - name: Run test
32
+ run: bundle exec rspec spec
data/README.md CHANGED
@@ -10,7 +10,7 @@ This gem makes it easy to create callbacks.
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'simple_callbacker', github: 'hotoolong/embed_callbacks'
13
+ gem 'embed_callbacks'
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -19,8 +19,7 @@ And then execute:
19
19
 
20
20
  Or install it yourself as:
21
21
 
22
- $ gem install specific_install
23
- $ gem specific_install git@github.com:hotoolong/embed_callbacks.git main
22
+ $ gem install embed_callbacks
24
23
 
25
24
  ## Usage
26
25
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = %q{Whenever you want to add a callback, you can easily incorporate the process.\n }
11
11
  spec.homepage = "https://github.com/hotoolong/embed_callbacks"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
14
 
15
15
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -0,0 +1,24 @@
1
+ class Behavior
2
+ KINDS = %i(before after around rescue ensure)
3
+
4
+ def initialize(behavior)
5
+ @behavior = behavior
6
+ raise ArgumentError, 'The behavior should be set in the ' + KINDS.join(' ') unless KINDS.include?(behavior)
7
+ end
8
+
9
+ def before?
10
+ %i(before around).include?(@behavior)
11
+ end
12
+
13
+ def after?
14
+ %i(after around).include?(@behavior)
15
+ end
16
+
17
+ def rescue?
18
+ :rescue == @behavior
19
+ end
20
+
21
+ def ensure?
22
+ :ensure == @behavior
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ class Condition
2
+ def initialize(options)
3
+ @if = options[:if]
4
+ @unless = options[:unless]
5
+ raise ArgumentError, "Don't use if and unless at the same time." if @if && @unless
6
+ end
7
+
8
+ def call(record)
9
+ return @if.call(record) if @if
10
+ return !@unless&.call(record) if @unless
11
+ true
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module EmbedCallbacks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require "embed_callbacks/version"
2
+ require "embed_callbacks/condition"
3
+ require "embed_callbacks/behavior"
2
4
 
3
5
  module EmbedCallbacks
4
6
  def self.included(base)
@@ -27,42 +29,4 @@ module EmbedCallbacks
27
29
  end
28
30
  end
29
31
 
30
- class Condition
31
- def initialize(options)
32
- @if = options[:if]
33
- @unless = options[:unless]
34
- raise ArgumentError, "Don't use if and unless at the same time." if @if && @unless
35
- end
36
-
37
- def call(record)
38
- return @if.call(record) if @if
39
- return !@unless&.call(record) if @unless
40
- true
41
- end
42
- end
43
-
44
- class Behavior
45
- KINDS = %i(before after around rescue ensure)
46
-
47
- def initialize(behavior)
48
- @behavior = behavior
49
- raise ArgumentError, 'The behavior should be set in the before after around rescue' unless KINDS.include?(behavior)
50
- end
51
-
52
- def before?
53
- %i(before around).include?(@behavior)
54
- end
55
-
56
- def after?
57
- %i(after around).include?(@behavior)
58
- end
59
-
60
- def rescue?
61
- :rescue == @behavior
62
- end
63
-
64
- def ensure?
65
- :ensure == @behavior
66
- end
67
- end
68
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embed_callbacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hotoolong
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -74,13 +74,13 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".github/workflows/gem-push.yml"
77
+ - ".github/workflows/gem-publish.yml"
78
+ - ".github/workflows/test.yml"
78
79
  - ".gitignore"
79
80
  - ".rspec"
80
81
  - ".travis.yml"
81
82
  - CODE_OF_CONDUCT.md
82
83
  - Gemfile
83
- - Gemfile.lock
84
84
  - LICENSE.txt
85
85
  - README.md
86
86
  - Rakefile
@@ -88,12 +88,14 @@ files:
88
88
  - bin/setup
89
89
  - embed_callbacks.gemspec
90
90
  - lib/embed_callbacks.rb
91
+ - lib/embed_callbacks/behavior.rb
92
+ - lib/embed_callbacks/condition.rb
91
93
  - lib/embed_callbacks/version.rb
92
94
  homepage: https://github.com/hotoolong/embed_callbacks
93
95
  licenses:
94
96
  - MIT
95
97
  metadata: {}
96
- post_install_message:
98
+ post_install_message:
97
99
  rdoc_options: []
98
100
  require_paths:
99
101
  - lib
@@ -101,15 +103,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
103
  requirements:
102
104
  - - ">="
103
105
  - !ruby/object:Gem::Version
104
- version: 2.5.0
106
+ version: 2.6.0
105
107
  required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  requirements:
107
109
  - - ">="
108
110
  - !ruby/object:Gem::Version
109
111
  version: '0'
110
112
  requirements: []
111
- rubygems_version: 3.1.2
112
- signing_key:
113
+ rubygems_version: 3.3.26
114
+ signing_key:
113
115
  specification_version: 4
114
116
  summary: Create a method callback.
115
117
  test_files: []
@@ -1,31 +0,0 @@
1
- name: Ruby Gem
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
- branches: [ main ]
8
-
9
- jobs:
10
- build:
11
- name: Build + Publish
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- ruby: [ '2.7.x', '2.6.x', '2.5.x' ]
17
-
18
- steps:
19
- - uses: actions/checkout@v2
20
- - name: Set up Ruby
21
- uses: actions/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby }}
24
-
25
- - name: Install dependencies
26
- run: |
27
- gem install bundler --no-document
28
- bundle install
29
-
30
- - name: Run test
31
- run: bundle exec rspec spec
data/Gemfile.lock DELETED
@@ -1,47 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- embed_callbacks (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- codecov (0.2.6)
10
- colorize
11
- json
12
- simplecov
13
- colorize (0.8.1)
14
- diff-lcs (1.4.4)
15
- docile (1.3.2)
16
- json (2.3.1)
17
- rake (12.3.3)
18
- rspec (3.9.0)
19
- rspec-core (~> 3.9.0)
20
- rspec-expectations (~> 3.9.0)
21
- rspec-mocks (~> 3.9.0)
22
- rspec-core (3.9.2)
23
- rspec-support (~> 3.9.3)
24
- rspec-expectations (3.9.2)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.9.0)
27
- rspec-mocks (3.9.1)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.9.0)
30
- rspec-support (3.9.3)
31
- simplecov (0.19.0)
32
- docile (~> 1.1)
33
- simplecov-html (~> 0.11)
34
- simplecov-html (0.12.2)
35
-
36
- PLATFORMS
37
- ruby
38
-
39
- DEPENDENCIES
40
- codecov
41
- embed_callbacks!
42
- rake (~> 12.0)
43
- rspec (~> 3.0)
44
- simplecov
45
-
46
- BUNDLED WITH
47
- 2.1.4