eac_ruby_gem_support 0.1.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_gem_support.rb +1 -1
- data/lib/eac_ruby_gem_support/rspec.rb +9 -0
- data/lib/eac_ruby_gem_support/rspec/helpers/filesystem.rb +73 -0
- data/lib/eac_ruby_gem_support/rspec/setup.rb +39 -0
- data/lib/eac_ruby_gem_support/rspec/specs/rubocop.rb +33 -0
- data/lib/eac_ruby_gem_support/version.rb +1 -1
- metadata +21 -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: 78a74df60ac64e3fc1434c2abfd80a2ca8011b3123c93f043fecbdfb8a6cc202
|
4
|
+
data.tar.gz: 98b98f8ecc9cc76e4a90b9196f92c65bc6b98439f1efb722500fab21e7f2d075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67976f114cbc716e604eda60a525f076d144b8858894e2cbcbd7678215f36eab528880d5a80f21e880344d2d88ece668eaf6ba79f2822173ff14b40ca2e508f9
|
7
|
+
data.tar.gz: 17efa59ecf539800429f6cc95df7591ff677d98308d2ddc250d7ee14f55174ea63842d2353cf62327d776acbe32a9c6d090787b73c175eddf75f12492b57442c
|
data/lib/eac_ruby_gem_support.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
module EacRubyGemSupport
|
8
|
+
module 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,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_gem_support/rspec/helpers/filesystem'
|
5
|
+
require 'eac_ruby_gem_support/rspec/specs/rubocop'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
module EacRubyGemSupport
|
9
|
+
module Rspec
|
10
|
+
module Setup
|
11
|
+
extend ::ActiveSupport::Concern
|
12
|
+
include ::EacRubyGemSupport::Rspec::Specs::Rubocop
|
13
|
+
|
14
|
+
def self.perform(setup_obj)
|
15
|
+
setup_obj.setup_load_path
|
16
|
+
setup_obj.setup_example_persistence
|
17
|
+
setup_obj.setup_filesystem_helper
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_filesystem_helper
|
21
|
+
rspec_config.include ::EacRubyGemSupport::Rspec::Helpers::Filesystem
|
22
|
+
rspec_config.after(:each) { purge_temp_files }
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_load_path
|
26
|
+
$LOAD_PATH.push app_root_path.join('lib').to_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_example_persistence
|
30
|
+
rspec_config.example_status_persistence_file_path = example_persistence_path.to_path
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Pathname]
|
34
|
+
def example_persistence_path
|
35
|
+
::File.join(::Dir.tmpdir, app_root_path.basename.to_path.variableize).to_pathname
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'rubocop'
|
5
|
+
|
6
|
+
module EacRubyGemSupport
|
7
|
+
module 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,15 +1,29 @@
|
|
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.3.2
|
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-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: eac_ruby_utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.72'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.72'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +87,10 @@ extensions: []
|
|
73
87
|
extra_rdoc_files: []
|
74
88
|
files:
|
75
89
|
- lib/eac_ruby_gem_support.rb
|
76
|
-
- lib/eac_ruby_gem_support/
|
90
|
+
- lib/eac_ruby_gem_support/rspec.rb
|
91
|
+
- lib/eac_ruby_gem_support/rspec/helpers/filesystem.rb
|
92
|
+
- lib/eac_ruby_gem_support/rspec/setup.rb
|
93
|
+
- lib/eac_ruby_gem_support/rspec/specs/rubocop.rb
|
77
94
|
- lib/eac_ruby_gem_support/version.rb
|
78
95
|
homepage: https://github.com/esquilo-azul/eac_ruby_gem_support
|
79
96
|
licenses: []
|
@@ -94,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
111
|
- !ruby/object:Gem::Version
|
95
112
|
version: '0'
|
96
113
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.7.7
|
114
|
+
rubygems_version: 3.1.6
|
99
115
|
signing_key:
|
100
116
|
specification_version: 4
|
101
117
|
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
|