eac_ruby_gem_support 0.1.2 → 0.2.0
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/eac_ruby_gem_support.rb +1 -1
- data/lib/eac_ruby_gem_support/rspec.rb +44 -0
- data/lib/eac_ruby_gem_support/rspec/helpers/filesystem.rb +73 -0
- data/lib/eac_ruby_gem_support/rspec/specs/rubocop.rb +33 -0
- data/lib/eac_ruby_gem_support/version.rb +1 -1
- metadata +6 -5
- data/lib/eac_ruby_gem_support/spec/examples/rubocop_check.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3eb984301f5fc4b7c3a517073ac14f228972e1b871469e5bc434c92555968f
|
4
|
+
data.tar.gz: c27b4fdcf994129729f64e53795f81487c04148bcf9becfc157ebbe50ef9ce88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4227f1a1e1f950fd9891f8a5e82e80ee0f3b90040ad827d1c6c53a8b7140ebdbffff47f29b12a612f803363e0572ce8d79831006b0e1bfb23a8ebe99119efe2
|
7
|
+
data.tar.gz: d400d5dea8d8316d334863b08a0711a018a7a93a835d7899efa847d88542556ee309580810a6f1671974608c6f759386872431950298fe8231d5a9692bb264c2
|
data/lib/eac_ruby_gem_support.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_gem_support/rspec/helpers/filesystem'
|
4
|
+
require 'eac_ruby_gem_support/rspec/specs/rubocop'
|
5
|
+
require 'rspec'
|
6
|
+
|
7
|
+
module EacRubyGemSupport
|
8
|
+
class Rspec
|
9
|
+
include ::EacRubyGemSupport::Rspec::Specs::Rubocop
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def default
|
13
|
+
@default || raise("Default instance was not set. Use #{self.class.name}.setup")
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup(app_root_path, config = nil)
|
17
|
+
@default = if config
|
18
|
+
new(app_root_path, config)
|
19
|
+
else
|
20
|
+
::RSpec.configure { |new_config| new(app_root_path, new_config) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :app_root_path, :config
|
26
|
+
|
27
|
+
def initialize(app_root_path, config)
|
28
|
+
@app_root_path = app_root_path
|
29
|
+
@config = config
|
30
|
+
setup
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def setup
|
36
|
+
setup_filesystem_helper
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_filesystem_helper
|
40
|
+
config.include ::EacRubyGemSupport::Rspec::Helpers::Filesystem
|
41
|
+
config.after(:each) { purge_temp_files }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
module EacRubyGemSupport
|
8
|
+
class Rspec
|
9
|
+
module Helpers
|
10
|
+
module Filesystem
|
11
|
+
def purge_temp_files
|
12
|
+
::FileUtils.rm_rf(temp_set.pop) while temp_set.any?
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Pathname]
|
16
|
+
def temp_copy(source_path)
|
17
|
+
source_path = to_pathname(source_path)
|
18
|
+
if source_path.file?
|
19
|
+
temp_file_copy(source_path)
|
20
|
+
elsif source_path.directory?
|
21
|
+
temp_dir_copy(source_path)
|
22
|
+
else
|
23
|
+
raise "Source path \"#{source_path}\" is not a file or directory"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Pathname]
|
28
|
+
def temp_dir(*mktmpdir_args)
|
29
|
+
add_to_temp_set(::Dir.mktmpdir(*mktmpdir_args))
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Pathname]
|
33
|
+
def temp_dir_copy(source_path)
|
34
|
+
r = temp_dir
|
35
|
+
::FileUtils.cp_r("#{source_path}/.", r.to_path)
|
36
|
+
r
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Pathname]
|
40
|
+
def temp_file(*tempfile_args)
|
41
|
+
file = ::Tempfile.new(*tempfile_args)
|
42
|
+
path = file.path
|
43
|
+
file.close
|
44
|
+
add_to_temp_set(path)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Pathname]
|
48
|
+
def temp_file_copy(source_path)
|
49
|
+
r = temp_file
|
50
|
+
::FileUtils.cp(to_pathname(source_path).to_path, r.to_path)
|
51
|
+
r
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Pathname]
|
55
|
+
def to_pathname(path)
|
56
|
+
path.is_a?(::Pathname) ? path : ::Pathname.new(path.to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def add_to_temp_set(path)
|
62
|
+
r = to_pathname(path)
|
63
|
+
temp_set << r
|
64
|
+
r
|
65
|
+
end
|
66
|
+
|
67
|
+
def temp_set
|
68
|
+
@temp_set ||= []
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'rubocop'
|
5
|
+
|
6
|
+
module EacRubyGemSupport
|
7
|
+
class Rspec
|
8
|
+
module Specs
|
9
|
+
module Rubocop
|
10
|
+
def describe_rubocop # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
11
|
+
this = self
|
12
|
+
::RSpec.describe ::RuboCop do
|
13
|
+
before do
|
14
|
+
::RuboCop::ConfigLoader.ignore_parent_exclusion = true
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:root_path) { this.app_root_path }
|
18
|
+
let(:config_store) do
|
19
|
+
r = ::RuboCop::ConfigStore.new
|
20
|
+
r.for(root_path)
|
21
|
+
r
|
22
|
+
end
|
23
|
+
let(:runner) { ::RuboCop::Runner.new({}, config_store) }
|
24
|
+
|
25
|
+
it 'rubocop return ok' do
|
26
|
+
expect(::Dir.chdir(root_path) { runner.run([]) }).to eq(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_gem_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -73,7 +73,9 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- lib/eac_ruby_gem_support.rb
|
76
|
-
- lib/eac_ruby_gem_support/
|
76
|
+
- lib/eac_ruby_gem_support/rspec.rb
|
77
|
+
- lib/eac_ruby_gem_support/rspec/helpers/filesystem.rb
|
78
|
+
- lib/eac_ruby_gem_support/rspec/specs/rubocop.rb
|
77
79
|
- lib/eac_ruby_gem_support/version.rb
|
78
80
|
homepage: https://github.com/esquilo-azul/eac_ruby_gem_support
|
79
81
|
licenses: []
|
@@ -94,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.7.7
|
99
|
+
rubygems_version: 3.0.9
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: Development support for Ruby' Gem.
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubocop'
|
4
|
-
require 'rspec'
|
5
|
-
|
6
|
-
RSpec.shared_examples 'rubocop_check' do |root_path|
|
7
|
-
before do
|
8
|
-
::RuboCop::ConfigLoader.ignore_parent_exclusion = true
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:root_path) { root_path }
|
12
|
-
let(:config_store) do
|
13
|
-
r = ::RuboCop::ConfigStore.new
|
14
|
-
r.for(root_path)
|
15
|
-
r
|
16
|
-
end
|
17
|
-
let(:runner) { ::RuboCop::Runner.new({}, config_store) }
|
18
|
-
|
19
|
-
it 'rubocop return ok' do
|
20
|
-
expect(::Dir.chdir(root_path) { runner.run([]) }).to eq(true)
|
21
|
-
end
|
22
|
-
end
|