calcifer 0.3.0 → 0.4.0

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: 8c5707a10355cd294158d90205376066eeb28c86641e9fc19175b2cd416bcd37
4
- data.tar.gz: 060ab3bf12ca9c3794aed8735d66ac20676a950374c4fc00ab5f68ac4218ca50
3
+ metadata.gz: c7d116a75730c531b8425c3358f6988fd46c3cf480fa73e6fea53a783ae9db4e
4
+ data.tar.gz: bcd079c57f89dcdedac1c6d3f43d656a09dff5b14a058b6655a218c76ab6a97e
5
5
  SHA512:
6
- metadata.gz: a431a5422bacd73123f432c964d1150a1d4d10de982f8e411c2b6a334a8c3d447930e46376075706d2e9dbbdcc86ddce13973a34f88cd42fed5074ef4b3cafd7
7
- data.tar.gz: 2be6476fdde544faa31240ffb52237d56baf4bb28e9f254c9c92de72d221faf396397a388f6332f81902b81967b131935629d770d08503b28d4b4849737b8a3a
6
+ metadata.gz: e12138c209b2a7a49aced35daa7c9f181d0b7668a6066a3a565135480781ff1c12ffe6157d35201f0e9892f97fbe9bc4c756ab41a88a0cfaf992578c6fbe67a6
7
+ data.tar.gz: 6f2b9e7ca8fe6392804f9a641559ce4df4998734f81bf3b8cd227172860a4486dd222e2d8f6dea67d85cd3d518b49d72e7323db351927e084193efd4b16cf46a
@@ -0,0 +1,41 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CI
4
+
5
+ # Controls when the workflow will run
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the main branch
8
+ push:
9
+ branches: [ main ]
10
+ pull_request:
11
+ branches: [ main ]
12
+
13
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
14
+ jobs:
15
+ # This workflow contains a single job called "build"
16
+ build:
17
+ # The type of runner that the job will run on
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v2
23
+
24
+ - name: Setup Ruby and install gems
25
+ uses: actions/setup-ruby@v1
26
+ with:
27
+ ruby-version: 2.6
28
+
29
+ - name: Build env
30
+ run: |
31
+ sudo apt-get -yqq install libpq-dev
32
+ gem install bundler:1.17.0
33
+ bundle install
34
+
35
+ - name: Run Rspec
36
+ run: bundle exec rspec
37
+ - name: Run Rubocop
38
+ run: bundle exec rubocop
39
+
40
+
41
+
data/Gemfile.lock CHANGED
@@ -1,16 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- calcifer (0.3.0)
5
- rgl
4
+ calcifer (0.4.0)
5
+ rgl (~> 0.5.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.2)
10
11
  diff-lcs (1.5.0)
11
12
  generator (0.0.1)
12
13
  lazy_priority_queue (0.1.1)
14
+ parallel (1.21.0)
15
+ parser (3.1.0.0)
16
+ ast (~> 2.4.1)
17
+ rainbow (3.1.1)
13
18
  rake (10.5.0)
19
+ regexp_parser (2.2.0)
20
+ rexml (3.2.5)
14
21
  rgl (0.5.7)
15
22
  lazy_priority_queue (~> 0.1.0)
16
23
  stream (~> 0.5.3)
@@ -27,8 +34,21 @@ GEM
27
34
  diff-lcs (>= 1.2.0, < 2.0)
28
35
  rspec-support (~> 3.10.0)
29
36
  rspec-support (3.10.3)
37
+ rubocop (1.25.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 3.1.0.0)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.8, < 3.0)
42
+ rexml
43
+ rubocop-ast (>= 1.15.1, < 2.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 1.4.0, < 3.0)
46
+ rubocop-ast (1.15.1)
47
+ parser (>= 3.0.1.1)
48
+ ruby-progressbar (1.11.0)
30
49
  stream (0.5.3)
31
50
  generator
51
+ unicode-display_width (2.1.0)
32
52
 
33
53
  PLATFORMS
34
54
  ruby
@@ -38,6 +58,7 @@ DEPENDENCIES
38
58
  calcifer!
39
59
  rake (~> 10.0)
40
60
  rspec (~> 3.0)
61
+ rubocop (~> 1.25)
41
62
 
42
63
  BUNDLED WITH
43
64
  1.17.3
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Calcifer
2
+
3
+ Calcifer helps you find test files that are directly related to the files you changed.
2
4
  ## Installation
3
5
 
4
6
  Add this line to your application's Gemfile:
@@ -17,8 +19,14 @@ Or install it yourself as:
17
19
 
18
20
  ## Usage
19
21
 
20
- `bundle exec calcifer | xargs bundle exec rspec`
22
+ To search for related files using uncommitted changes, just do the following
23
+
24
+ $ bundle exec calcifer | xargs bundle exec rspec
25
+
26
+ To search for related files using the other branch changes as a reference, just do the following
27
+
21
28
 
29
+ $ bundle exec calcifer -b 'branch_name' | xargs bundle exec rspec
22
30
  ## Contributing
23
31
 
24
32
  Bug reports and pull requests are welcome on GitHub at https://github.com/GustavoDuarteM/calcifer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/calcifer.gemspec CHANGED
@@ -39,9 +39,10 @@ Gem::Specification.new do |spec|
39
39
  spec.executables = ['calcifer']
40
40
  spec.require_paths = ["lib"]
41
41
 
42
- spec.add_dependency 'rgl'
42
+ spec.add_dependency 'rgl', "~>0.5.7"
43
43
 
44
44
  spec.add_development_dependency "bundler", "~> 1.17"
45
45
  spec.add_development_dependency "rake", "~> 10.0"
46
46
  spec.add_development_dependency "rspec", "~> 3.0"
47
+ spec.add_development_dependency "rubocop", "~> 1.25"
47
48
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calcifer
4
+ module Factories
5
+ class ListFileFactory
6
+ PARAM_BRANCH = ['-b', '-branch'].freeze
7
+
8
+ def initialize(params)
9
+ @params = params
10
+ end
11
+
12
+ def fabricate
13
+ extract_parameters
14
+
15
+ return Calcifer::Finders::FilesDiffFinder.new if @branch.nil?
16
+
17
+ Calcifer::Finders::FilesBranchDiffFinder.new(@branch)
18
+ end
19
+
20
+ private
21
+
22
+ def extract_parameters
23
+ params_list.each do |param|
24
+ param_branch(param)
25
+ end
26
+ end
27
+
28
+ def params_list
29
+ @params_list = []
30
+ (0..@params.length - 1).step(2) do |num|
31
+ range = 2 + num
32
+ @params_list << @params[num..range]
33
+ end
34
+
35
+ @params_list
36
+ end
37
+
38
+ def param_branch(array_param)
39
+ param, value = array_param
40
+
41
+ return unless PARAM_BRANCH.include?(param)
42
+
43
+ @branch = value
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calcifer
4
+ module Finders
5
+ class FilesBranchDiffFinder
6
+ def initialize(branch)
7
+ @branch = branch
8
+ end
9
+
10
+ def execute
11
+ @file_list = git_files.split.map(&lambda { |file_path|
12
+ file = File.open(file_path)
13
+ file if file.size.positive? && File.extname(file.path) == '.rb'
14
+ }).compact
15
+ end
16
+
17
+ def git_files
18
+ `git diff --name-only #{@branch}...`
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calcifer
4
+ module Graph
5
+ class GraphListFile
6
+ def initialize(file_list)
7
+ @file_list = file_list
8
+ end
9
+
10
+ def execute
11
+ graph_list_file = @file_list.map(&->(file) { Calcifer::Buiders::RootFileBuilder.new(file).build }).compact
12
+
13
+ graph_list_file.each do |graph|
14
+ related_files = Calcifer::Finders::FileRelatedFinder.new(graph.module_name).execute
15
+ graph_vertices = related_files.map { |related_file| [graph.file_path, related_file] }
16
+ graph.graph_root.add_edges(*graph_vertices)
17
+ end
18
+
19
+ graph_list_file
20
+ end
21
+
22
+ def file_list
23
+ Calcifer::Finders::FilesDiffFinder.new.execute
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calcifer
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/calcifer.rb CHANGED
@@ -5,27 +5,15 @@ require 'rgl/adjacency'
5
5
 
6
6
  module Calcifer
7
7
  class Error < StandardError; end
8
-
9
- def self.execute
10
- spec_files_path = graph_list_file.map(&:related_files_paths).flatten
11
- spec_files_path_list = Calcifer::Finders::SpecFilesRelatedFinder.new(spec_files_path).execute
12
-
13
- printf `echo #{spec_files_path_list}`
14
- end
15
-
16
- private
17
-
18
- def graph_list_file
19
- graph_list_file = file_list.map(&->(file) { Calcifer::Buiders::RootFileBuilder.new(file).build }).compact
20
-
21
- graph_list_file.each do |graph|
22
- related_files = Calcifer::Finders::FileRelatedFinder.new(graph.module_name).execute
23
- graph_vertices = related_files.map { |related_file| [graph.file_path, related_file] }
24
- graph.graph_root.add_edges(*graph_vertices)
8
+ class << self
9
+ def execute
10
+ file_list_finder = Calcifer::Factories::ListFileFactory.new(ARGV).fabricate
11
+ file_list = file_list_finder.execute
12
+ graph_list_file = Calcifer::Graph::GraphListFile.new(file_list).execute
13
+ spec_files_path = graph_list_file.map(&:related_files_paths).flatten
14
+ spec_files_path_list = Calcifer::Finders::SpecFilesRelatedFinder.new(spec_files_path).execute
15
+
16
+ printf `echo #{spec_files_path_list}`
25
17
  end
26
18
  end
27
-
28
- def file_list
29
- Calcifer::Finders::FilesDiffFinder.new.execute
30
- end
31
19
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calcifer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Duarte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-19 00:00:00.000000000 Z
11
+ date: 2022-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgl
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.5.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.5.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.25'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.25'
69
83
  description:
70
84
  email:
71
85
  - gustavo_dmuniz@yahoo.com.br
@@ -74,6 +88,7 @@ executables:
74
88
  extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
91
+ - ".github/workflows/main.yml"
77
92
  - ".gitignore"
78
93
  - ".rspec"
79
94
  - ".rubocop.yml"
@@ -90,10 +105,13 @@ files:
90
105
  - calcifer.gemspec
91
106
  - lib/calcifer.rb
92
107
  - lib/calcifer/builders/root_file_builder.rb
108
+ - lib/calcifer/factories/list_file_factory.rb
93
109
  - lib/calcifer/finders/file_related_finder.rb
110
+ - lib/calcifer/finders/files_branch_diff_finder.rb
94
111
  - lib/calcifer/finders/files_diff_finder.rb
95
112
  - lib/calcifer/finders/module_name_finder.rb
96
113
  - lib/calcifer/finders/spec_files_related_finder.rb
114
+ - lib/calcifer/graph/graph_list_file.rb
97
115
  - lib/calcifer/graph/root_file.rb
98
116
  - lib/calcifer/version.rb
99
117
  homepage: https://github.com/GustavoDuarteM/calcifer
@@ -117,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
135
  - !ruby/object:Gem::Version
118
136
  version: '0'
119
137
  requirements: []
120
- rubygems_version: 3.0.8
138
+ rubygems_version: 3.1.6
121
139
  signing_key:
122
140
  specification_version: 4
123
141
  summary: This gem helps to find class test files related to pending changes in git.