missing_rspec 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 888af8a4fa95a09ab591ee728e0823ff6e9f01225d044f67f76eb6dc50a38cab
4
+ data.tar.gz: 8c0aaca09f36a0c742ab1b04780262451383c5bc738cdde009ea064d99e7a9d2
5
+ SHA512:
6
+ metadata.gz: 955517ab17f8f76b5fea0f42c71d5c1c69e398a94c5690776a9acc30cff06b2f629fdab2fc9f74f328ebf4ed3e7cca92e959942d1db8c8b6eaffa2242663d77e
7
+ data.tar.gz: 67eba0657ca16adfb866d2294e3d39c66e3f064e515f3874d4da86b9ae4dcc56e50ffcbae29d43114a984b4bfa4a928893b6ff79eaa53b2d152fd56900e4e681
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.3
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at keiichi.kayama@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in missing_rspec.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ missing_rspec (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ x86_64-darwin-21
12
+
13
+ DEPENDENCIES
14
+ missing_rspec!
15
+
16
+ BUNDLED WITH
17
+ 2.3.20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 keiichi.kayama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # MissingRspec
2
+
3
+ This Gem extracts RSpec files that have not yet been created.
4
+
5
+ ## Installation
6
+
7
+ To use it, add it to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'missing_rspec', group: :development
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### How to specify rails path as an argument to rake
16
+
17
+ ```shell
18
+ bin/rails runner "puts Rails.root.to_s"
19
+ ```
20
+
21
+ Example when rails path is /app
22
+
23
+ ```shell
24
+ bin/rails libmissing_rspec[/app]
25
+ ```
26
+
27
+ ### How to specify the rails path in the environment variable
28
+
29
+ ```shell
30
+ bin/rails runner "puts Rails.root.to_s"
31
+ ```
32
+
33
+ Set environment variables using methods such as dot_env
34
+
35
+ Example .env file when rails path is /app
36
+
37
+ ```shell
38
+ RAILS_APP_PATH=/app
39
+ ```
40
+
41
+ ```shell
42
+ bin/rails libmissing_rspec
43
+ ```
44
+ ## Execution example
45
+
46
+ ```shell
47
+ root@be31b61b9f18:/app/missing_rspec# bin/rails libmissing_rspec
48
+
49
+
50
+
51
+ The following folders are targeted: ["channels", "controllers", "forms", "helpers", "jobs", "lib", "mailers", "models", "presenters", "services"]
52
+ <channels>
53
+ └<application_cable>
54
+ ├channel.rb
55
+ └connection.rb
56
+ <controllers>
57
+ ├<admin>
58
+ │ ├allowed_sources_controller.rb
59
+ │ ├base.rb
60
+ │ ├sessions_controller.rb
61
+ │ ├staff_events_controller.rb
62
+ │ ├staff_members_controller.rb
63
+ │ └top_controller.rb
64
+ ├<concerns>
65
+ │ └error_handlers.rb
66
+ ├<customer>
67
+ │ ├accounts_controller.rb
68
+ │ ├base.rb
69
+ │ ├entries_controller.rb
70
+ │ ├messages_controller.rb
71
+ │ ├programs_controller.rb
72
+ │ ├replies_controller.rb
73
+ │ ├sessions_controller.rb
74
+ │ └top_controller.rb
75
+ ├<staff>
76
+ │ ├accounts_controller.rb
77
+ │ ├base.rb
78
+ │ ├customers_controller.rb
79
+ │ ├entries_controller.rb
80
+ │ ├messages_controller.rb
81
+ │ ├passwords_controller.rb
82
+ │ ├programs_controller.rb
83
+ │ ├replies_controller.rb
84
+ │ ├sessions_controller.rb
85
+ │ └top_controller.rb
86
+ ├application_controller.rb
87
+ └errors_controller.rb
88
+ <forms>
89
+ ├<admin>
90
+ │ └login_form.rb
91
+ ├<customer>
92
+ │ ├account_form.rb
93
+ │ └login_form.rb
94
+ └<staff>
95
+ ├change_password_form.rb
96
+ ├customer_form.rb
97
+ ├customer_search_form.rb
98
+ ├entries_form.rb
99
+ └login_form.rb
100
+ <helpers>
101
+ ├application_helper.rb
102
+ └staff_helper.rb
103
+ <jobs>
104
+ └application_job.rb
105
+ <lib>
106
+ ├html_builder.rb
107
+ └simple_tree.rb
108
+ <mailers>
109
+ └application_mailer.rb
110
+ <models>
111
+ ├<concerns>
112
+ │ ├email_holder.rb
113
+ │ ├password_holder.rb
114
+ │ ├personal_name_holder.rb
115
+ │ └string_normalizer.rb
116
+ ├address.rb
117
+ ├application_record.rb
118
+ ├customer.rb
119
+ ├customer_message.rb
120
+ ├entry.rb
121
+ ├hash_lock.rb
122
+ ├home_address.rb
123
+ ├message.rb
124
+ ├message_tag_link.rb
125
+ ├phone.rb
126
+ ├program.rb
127
+ ├staff_event.rb
128
+ ├staff_member.rb
129
+ ├staff_message.rb
130
+ ├tag.rb
131
+ └work_address.rb
132
+ <presenters>
133
+ ├address_form_presenter.rb
134
+ ├address_presenter.rb
135
+ ├allowed_source_presenter.rb
136
+ ├confirming_address_form_presenter.rb
137
+ ├confirming_customer_form_presenter.rb
138
+ ├confirming_form_presenter.rb
139
+ ├confirming_user_form_presenter.rb
140
+ ├customer_form_presenter.rb
141
+ ├customer_presenter.rb
142
+ ├form_presenter.rb
143
+ ├message_presenter.rb
144
+ ├model_presenter.rb
145
+ ├program_form_presenter.rb
146
+ ├program_presenter.rb
147
+ ├staff_event_presenter.rb
148
+ ├staff_member_form_presenter.rb
149
+ ├staff_member_presenter.rb
150
+ └user_form_presenter.rb
151
+ <services>
152
+ ├<admin>
153
+ │ ├allowed_sources_deleter.rb
154
+ ├<customer>
155
+ │ ├authenticator.rb
156
+ │ └entry_acceptor.rb
157
+ └<staff>
158
+ ```
159
+
160
+ ## Contributing
161
+
162
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kayamak/missing_rspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kayamak/missing_rspec).
163
+
164
+ ## License
165
+
166
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
167
+
168
+ ## Code of Conduct
169
+
170
+ Everyone interacting in the MissingRspec project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kayamak/missing_rspec).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "missing_rspec"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ require 'missing_rspec/directory'
2
+ require 'missing_rspec/folder_types_finder'
3
+ require 'missing_rspec/version'
4
+
5
+ module MissingRspec
6
+ class Core
7
+ attr_reader :app_path
8
+
9
+ def initialize(app_path)
10
+ # e.g. /app
11
+ @app_path = app_path || ENV['RAILS_APP_PATH']
12
+ raise "Set the rails app path to the rake argument or the environment variable RAILS_APP_PATH." unless @app_path
13
+ end
14
+
15
+ def execute
16
+ folder_types = MissingRspec::FolderTypesFinder.new(app_path).fetch_folder_types
17
+ puts "The following folders are targeted: #{folder_types}"
18
+ folder_types.each do |folder_type|
19
+ missing_tree = create_missing_tree(folder_type)
20
+ print_tree(missing_tree)
21
+ end
22
+
23
+ 'hogehoge'
24
+ end
25
+
26
+ private
27
+ def create_missing_tree(folder_type)
28
+ MissingRspec::Directory.new(app_path: app_path, folder_type: folder_type).missing_tree
29
+ end
30
+
31
+ def print_tree(tree)
32
+ puts tree.join("\n")
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,78 @@
1
+ module MissingRspec
2
+ class Directory
3
+ attr_reader :app_path, :folder_type
4
+
5
+ def initialize(app_path:, folder_type:)
6
+ @app_path = app_path
7
+ @folder_type = folder_type
8
+ end
9
+
10
+ def missing_tree
11
+ original_tree = make_original_tree
12
+ spec_tree = make_spec_tree
13
+
14
+ # Extract <xxx> rows from spec_tree and make them appear in the diff
15
+ title_of_spec_tree = spec_tree.filter { |st| /<.*>/ =~ st }
16
+
17
+ missing_spec_tree = original_tree - (spec_tree - title_of_spec_tree)
18
+ end
19
+
20
+ private
21
+
22
+ def make_original_tree
23
+ models_path = "#{app_path}/app/#{folder_type}"
24
+ fetch_tree(target_path: models_path, is_rspec: false)
25
+ end
26
+
27
+ def make_spec_tree
28
+ spec_models_path = "#{app_path}/spec/#{folder_type}"
29
+ fetch_tree(target_path: spec_models_path, is_rspec: true)
30
+ end
31
+
32
+ def fetch_tree(target_path: ,is_rspec:)
33
+ unless File.directory?(target_path)
34
+ if folder_type == target_path.split('/').last
35
+ return []
36
+ end
37
+ raise "#{target_path} is not directory."
38
+ end
39
+
40
+ result = []
41
+
42
+ result << "<#{File.basename(target_path)}>"
43
+
44
+ trace_dir = lambda do |dir, pre|
45
+ Dir.chdir(dir)
46
+ dir_files = Dir.glob('*').sort
47
+ lower_dirs = dir_files.select { |df| File.directory?(df) }
48
+ files = dir_files - lower_dirs
49
+ end_num = dir_files.size
50
+ line_num = 1
51
+
52
+ lower_dirs.each do |lower_dir|
53
+ char0 = (line_num == end_num) ? '└' : '├'
54
+ line_num += 1
55
+ result << "#{pre}#{char0}<#{lower_dir}>"
56
+ char1 = pre + ((char0 == '└') ? ' ' : '│ ')
57
+ trace_dir.call(lower_dir, char1)
58
+ end
59
+
60
+ files.each do |file|
61
+ next unless /.rb$/ =~ file
62
+
63
+ char = (line_num == end_num) ? '└' : '├'
64
+ line_num += 1
65
+
66
+ replaced_file = is_rspec ? file.sub(/_spec.rb$/, '.rb') : file
67
+ result << "#{pre}#{char}#{replaced_file}"
68
+ end
69
+
70
+ Dir.chdir('..')
71
+ end
72
+ trace_dir.call(target_path, ' ')
73
+
74
+ result
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,19 @@
1
+ module MissingRspec
2
+ class FolderTypesFinder
3
+ EXCLUDED_FOLDER_TYPES = %w[assets javascript views]
4
+
5
+ attr_reader :app_path
6
+
7
+ def initialize(app_path)
8
+ @app_path = app_path
9
+ end
10
+
11
+ def fetch_folder_types
12
+ Dir.chdir(app_path)
13
+ Dir.chdir('app')
14
+ folder_types = Dir.glob('*/')
15
+ folder_types.each(&:chop!)
16
+ (folder_types - EXCLUDED_FOLDER_TYPES)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module MissingRspec
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_model/railtie'
2
+
3
+ module MissingRspec
4
+ class Railtie < ::Rails::Railtie
5
+ rake_tasks do
6
+ load "tasks/missing_rspec.rake"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ require 'missing_rspec/core'
2
+
3
+ desc "mechanically extracts uncreated RSpecs"
4
+ task :missing_rspec, ['app_path'] => :environment do |_, args|
5
+ MissingRspec::Core.new(args.app_path).execute
6
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/missing_rspec/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "missing_rspec"
5
+ spec.version = MissingRspec::VERSION
6
+ spec.authors = ["Keiichi Kayama"]
7
+ spec.email = ["kayama.keiichi@gmai.com"]
8
+
9
+ spec.summary = %q{find missing rspec files.}
10
+ spec.description = %q{This Gem extracts RSpec files that have not yet been created.}
11
+ spec.homepage = "https://github.com/kayamak/missing_rspec"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/kayamak/missing_rspec"
19
+ spec.metadata["changelog_uri"] = "https://github.com/kayamak/missing_rspec"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: missing_rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Keiichi Kayama
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This Gem extracts RSpec files that have not yet been created.
14
+ email:
15
+ - kayama.keiichi@gmai.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/missing_rspec.rb
32
+ - lib/missing_rspec/core.rb
33
+ - lib/missing_rspec/directory.rb
34
+ - lib/missing_rspec/folder_types_finder.rb
35
+ - lib/missing_rspec/version.rb
36
+ - lib/tasks/missing_rspec.rake
37
+ - missing_rspec.gemspec
38
+ homepage: https://github.com/kayamak/missing_rspec
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ homepage_uri: https://github.com/kayamak/missing_rspec
43
+ source_code_uri: https://github.com/kayamak/missing_rspec
44
+ changelog_uri: https://github.com/kayamak/missing_rspec
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.3.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.0.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: find missing rspec files.
64
+ test_files: []