modware 0.1.2 → 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
- SHA1:
3
- metadata.gz: 69f274970332a9e8b996853befecaee2a5d386c4
4
- data.tar.gz: 6f4274479fb7fbe02d085e9e468960bb078f65b7
2
+ SHA256:
3
+ metadata.gz: ced548256c71edcf8a00411267322de511a112e4519053f82d9b51ea57e6d7c5
4
+ data.tar.gz: 00544aa8b177cd2efe530e6b84a2d022c151be8e647fade04a3bf5d1f69e1ec6
5
5
  SHA512:
6
- metadata.gz: 29a50dfea8185c607d62cc677516eb4109b762dc190cb41c070a0a30a8919691148e93b4b3c68e508b94623754a9b26a127553f7a0cca88547340dc9146f9636
7
- data.tar.gz: 2296664bee1116d4b0a201a93f0b88d4c37b811da374c540588cfb309a297838bef4a91ca2c7c9a9b9740ba5c29fdf35469bffa530a5e311c2a36759e4eb3e6d
6
+ metadata.gz: fa42c2ef53c3781e63ab64f7af0631bfaba2633cea351bf7c3d2067d0eed3837019bb753e86939c29a18b587567fc4abaaad872a980ea8353eccc3637e35ff9b
7
+ data.tar.gz: 277aa271c64efa6d9c9562a581b7aab7e7dab36da439759a7769c3acfb6a77d1fd2940e2047e8a98d5c9c5ebe954671b32b0b54baf207703896a4179da48d0a9
@@ -0,0 +1,49 @@
1
+ name: CI PR Builds
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ concurrency:
10
+ group: "ci-${{ github.ref }}"
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true
28
+
29
+ - name: 'Run bundle update'
30
+ run: bundle update
31
+
32
+ - name: Run tests
33
+ run: bundle exec rake spec
34
+
35
+ - name: Coveralls Parallel
36
+ uses: coverallsapp/github-action@master
37
+ with:
38
+ github-token: ${{ secrets.GITHUB_TOKEN }}
39
+ flag-name: run-${{ matrix.ruby-version }}
40
+ parallel: true
41
+ finish:
42
+ needs: 'test'
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - name: Coveralls Finished
46
+ uses: coverallsapp/github-action@master
47
+ with:
48
+ github-token: ${{ secrets.GITHUB_TOKEN }}
49
+ parallel-finished: true
data/.simplecov ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.configure do
4
+ enable_coverage :branch
5
+ add_filter '/spec/'
6
+
7
+ add_group 'Libraries', '/lib/'
8
+
9
+ if ENV['CI']
10
+ require 'simplecov-lcov'
11
+
12
+ SimpleCov::Formatter::LcovFormatter.config do |c|
13
+ c.report_with_single_file = true
14
+ c.single_report_path = 'coverage/lcov.info'
15
+ end
16
+
17
+ formatter SimpleCov::Formatter::LcovFormatter
18
+ end
19
+ end
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in modware.gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/modware.svg)](http://badge.fury.io/rb/modware)
2
- [![Build Status](https://secure.travis-ci.org/ronen/modware.svg)](http://travis-ci.org/ronen/modware)
3
- [![Coverage Status](https://img.shields.io/coveralls/ronen/modware.svg)](https://coveralls.io/r/ronen/modware)
2
+ [![Build Status](https://github.com/SchemaPlus/modware/actions/workflows/prs.yml/badge.svg)](https://github.com/SchemaPlus/modware/actions)
3
+ [![Coverage Status](https://coveralls.io/repos/github/SchemaPlus/modware/badge.svg)](https://coveralls.io/github/SchemaPlus/modware)
4
4
 
5
5
  # Modware
6
6
 
@@ -32,8 +32,7 @@ where `klass` is a Class for the environment instance that will be passed to the
32
32
  stack = Modware::Stack.new(env: [:name, :options, :results])
33
33
  ```
34
34
 
35
- and Modware will define a class that accepts those keys as keyword arguments, and has accessor methods for each (see
36
- [`KeyStruct`](https://rubygems.org/gems/key_struct)).
35
+ and Modware will define a class that accepts those keys as keyword arguments, and has accessor methods for each
37
36
 
38
37
 
39
38
  ### Defining middleware
@@ -102,7 +101,7 @@ class WrapsOperation < BaseClass
102
101
 
103
102
  attr_reader :stack
104
103
 
105
- def initialized(*args)
104
+ def initialize(*args)
106
105
  super
107
106
  @stack = Modware::Stack.new(env: [:time, :place, :result])
108
107
  end
@@ -132,6 +131,10 @@ The [middleware](https://rubygems.org/gems/middleware) gem works well, following
132
131
 
133
132
  ## Change Log
134
133
 
134
+ * 1.0.1 - Fix KeyStruct replacement
135
+ * 1.0.0 - use a major bump due to breakage with the 0.2.0 version and existing gems
136
+ * 0.2.0 - Add ruby 3.0 support and drop ruby < 2.5 (yanked)
137
+ * 0.1.3 - Remove its-it dependency :( #2
135
138
  * 0.1.2 - More thread safety in Stack#start
136
139
  * 0.1.1 - Thread safety in Stack#start
137
140
  * 0.1.0 - Initial release
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  require 'rspec/core/rake_task'
4
6
  RSpec::Core::RakeTask.new(:spec) do |spec|
5
7
  spec.rspec_opts = '-Ispec'
6
8
  end
7
-
8
- require 'coveralls/rake/task'
9
- Coveralls::RakeTask.new
10
- task :spec_with_coveralls => [:spec, 'coveralls:push']
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Modware
2
4
  class StackError < Exception
3
5
  end
data/lib/modware/stack.rb CHANGED
@@ -1,12 +1,16 @@
1
- require 'its-it'
2
- require 'key_struct'
1
+ # frozen_string_literal: true
3
2
 
4
3
  module Modware
5
4
  class Stack
6
5
  def initialize(env:)
7
6
  @env_klass = case env
8
7
  when Class then env
9
- else KeyStruct[*env]
8
+ else
9
+ Struct.new(*env, keyword_init: true) do
10
+ def to_hash
11
+ to_h
12
+ end
13
+ end
10
14
  end
11
15
  @middleware_mods = []
12
16
  end
@@ -49,7 +53,7 @@ module Modware
49
53
  end
50
54
 
51
55
  def call_implementation(env, base_implementation)
52
- if middleware = @middlewares.select(&it.respond_to?(:implement)).last
56
+ if middleware = @middlewares.select { |mw| mw.respond_to?(:implement) }.last
53
57
  middleware.implement(env)
54
58
  elsif base_implementation
55
59
  base_implementation.call env
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Modware
2
- VERSION = "0.1.2"
4
+ VERSION = "1.0.1"
3
5
  end
data/lib/modware.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "modware/errors"
2
4
  require "modware/stack"
3
5
  require "modware/version"
data/modware.gemspec CHANGED
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'modware/version'
@@ -17,15 +18,12 @@ Gem::Specification.new do |spec|
17
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
19
  spec.require_paths = ["lib"]
19
20
 
20
- spec.required_ruby_version = ">= 2.1.0"
21
- spec.add_dependency "key_struct", "~> 0.4"
22
- spec.add_dependency "its-it"
21
+ spec.required_ruby_version = ">= 2.5.0"
23
22
 
24
- spec.add_development_dependency 'coveralls'
25
- spec.add_development_dependency "bundler", "~> 1.7"
26
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake", "~> 13.0"
27
25
  spec.add_development_dependency "rspec", "~> 3.0"
28
26
  spec.add_development_dependency "rspec-given"
29
27
  spec.add_development_dependency "simplecov"
30
- spec.add_development_dependency "simplecov-gem-profile"
28
+ spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
31
29
  end
data/spec/env_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "Env" do
@@ -21,4 +23,12 @@ describe "Env" do
21
23
  Then { expect(env.to_hash).to eq args }
22
24
  end
23
25
 
26
+ context "if env: klass is an array of keys with nils in args" do
27
+
28
+ Given(:klass) { [:a, :b, :c] }
29
+ Given(:args) { {a: 1, b: 2, c: nil} }
30
+
31
+ Then { expect(env.to_hash).to eq args }
32
+ end
33
+
24
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "Execution" do
@@ -13,7 +15,7 @@ describe "Execution" do
13
15
 
14
16
  context "when start with base implementation" do
15
17
 
16
- When(:env) { stack.start result: [] { |env| env.result << :base } }
18
+ When(:env) { stack.start(result: []) { |env| env.result << :base } }
17
19
 
18
20
  Then { expect(env.result).to eq [:base] }
19
21
 
data/spec/helper_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "Helper" do
@@ -7,12 +9,12 @@ describe "Helper" do
7
9
  context "Modware.is_middleware?" do
8
10
  [:before, :after, :around, :implement].each do |method|
9
11
  it "returns truthy for a module with #{method.inspect} method" do
10
- expect(Modware.is_middleware? Factory.middleware(none.merge(method => true))).to be_truthy
12
+ expect(Modware.is_middleware? Factory.middleware(**none.merge(method => true))).to be_truthy
11
13
  end
12
14
  end
13
15
 
14
16
  it "returns falsey for other modules" do
15
- expect(Modware.is_middleware? Factory.middleware(none.merge(other: true))).to be_falsey
17
+ expect(Modware.is_middleware? Factory.middleware(**none.merge(other: true))).to be_falsey
16
18
  end
17
19
  end
18
20
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
- require 'simplecov-gem-profile'
3
- SimpleCov.start "gem"
4
+ SimpleCov.start
4
5
 
5
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Factory
2
4
  def self.middleware(n=nil, before: true, after: true, around: true, implement: true, other: nil)
3
5
 
@@ -35,6 +37,8 @@ module Factory
35
37
  end
36
38
  END
37
39
 
38
- Module.new.tap(&it.module_eval(methods.compact.join))
40
+ Module.new do
41
+ module_eval(methods.compact.join)
42
+ end
39
43
  end
40
44
  end
metadata CHANGED
@@ -1,45 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: key_struct
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.4'
27
- - !ruby/object:Gem::Dependency
28
- name: its-it
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: coveralls
14
+ name: bundler
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
@@ -52,34 +24,20 @@ dependencies:
52
24
  - - ">="
53
25
  - !ruby/object:Gem::Version
54
26
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.7'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.7'
69
27
  - !ruby/object:Gem::Dependency
70
28
  name: rake
71
29
  requirement: !ruby/object:Gem::Requirement
72
30
  requirements:
73
31
  - - "~>"
74
32
  - !ruby/object:Gem::Version
75
- version: '10.0'
33
+ version: '13.0'
76
34
  type: :development
77
35
  prerelease: false
78
36
  version_requirements: !ruby/object:Gem::Requirement
79
37
  requirements:
80
38
  - - "~>"
81
39
  - !ruby/object:Gem::Version
82
- version: '10.0'
40
+ version: '13.0'
83
41
  - !ruby/object:Gem::Dependency
84
42
  name: rspec
85
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,28 +81,29 @@ dependencies:
123
81
  - !ruby/object:Gem::Version
124
82
  version: '0'
125
83
  - !ruby/object:Gem::Dependency
126
- name: simplecov-gem-profile
84
+ name: simplecov-lcov
127
85
  requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
- - - ">="
87
+ - - "~>"
130
88
  - !ruby/object:Gem::Version
131
- version: '0'
89
+ version: 0.8.0
132
90
  type: :development
133
91
  prerelease: false
134
92
  version_requirements: !ruby/object:Gem::Requirement
135
93
  requirements:
136
- - - ">="
94
+ - - "~>"
137
95
  - !ruby/object:Gem::Version
138
- version: '0'
139
- description:
96
+ version: 0.8.0
97
+ description:
140
98
  email:
141
99
  - ronen@barzel.org
142
100
  executables: []
143
101
  extensions: []
144
102
  extra_rdoc_files: []
145
103
  files:
104
+ - ".github/workflows/prs.yml"
146
105
  - ".gitignore"
147
- - ".travis.yml"
106
+ - ".simplecov"
148
107
  - Gemfile
149
108
  - LICENSE.txt
150
109
  - README.md
@@ -163,7 +122,7 @@ homepage: https://github.com/ronen/modware
163
122
  licenses:
164
123
  - MIT
165
124
  metadata: {}
166
- post_install_message:
125
+ post_install_message:
167
126
  rdoc_options: []
168
127
  require_paths:
169
128
  - lib
@@ -171,16 +130,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
130
  requirements:
172
131
  - - ">="
173
132
  - !ruby/object:Gem::Version
174
- version: 2.1.0
133
+ version: 2.5.0
175
134
  required_rubygems_version: !ruby/object:Gem::Requirement
176
135
  requirements:
177
136
  - - ">="
178
137
  - !ruby/object:Gem::Version
179
138
  version: '0'
180
139
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.4.5
183
- signing_key:
140
+ rubygems_version: 3.0.8
141
+ signing_key:
184
142
  specification_version: 4
185
143
  summary: A middleware library, featuring a simple interface and "callback" style semantics
186
144
  in the middleware stack
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- sudo: false
2
- rvm:
3
- - 2.1.5
4
- script: bundle exec rake spec_with_coveralls
5
- notifications:
6
- recipients:
7
- - ronen@barzel.org