ree_spec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +13 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +0 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +15 -0
  8. data/Gemfile.lock +101 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +0 -0
  11. data/Rakefile +8 -0
  12. data/exe/ree_spec +15 -0
  13. data/lib/ree_spec/.gitignore +3 -0
  14. data/lib/ree_spec/.ree/templates/package/.gitignore +0 -0
  15. data/lib/ree_spec/.ree/templates/package/.rspec +2 -0
  16. data/lib/ree_spec/.ree/templates/package/<%=package_subdir_name%>/<%=package_name%>/.gitkeep +0 -0
  17. data/lib/ree_spec/.ree/templates/package/<%=package_subdir_name%>/<%=package_name%>.rb +15 -0
  18. data/lib/ree_spec/.ree/templates/package/Package.schema.json +0 -0
  19. data/lib/ree_spec/.ree/templates/package/bin/console +5 -0
  20. data/lib/ree_spec/.ree/templates/package/spec/package_schema_spec.rb +14 -0
  21. data/lib/ree_spec/.ree/templates/package/spec/spec_helper.rb +3 -0
  22. data/lib/ree_spec/.rspec +3 -0
  23. data/lib/ree_spec/.vscode-ree/templates/functions/template.rb +12 -0
  24. data/lib/ree_spec/.vscode-ree/templates/spec_template.rb +9 -0
  25. data/lib/ree_spec/Packages.schema.json +132 -0
  26. data/lib/ree_spec/bin/console +5 -0
  27. data/lib/ree_spec/packages/.vscode-ree/templates/spec_template.rb +11 -0
  28. data/lib/ree_spec/packages/ree_spec_cli/.gitignore +0 -0
  29. data/lib/ree_spec/packages/ree_spec_cli/.rspec +2 -0
  30. data/lib/ree_spec/packages/ree_spec_cli/Package.schema.json +40 -0
  31. data/lib/ree_spec/packages/ree_spec_cli/bin/console +5 -0
  32. data/lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/run_command.rb +22 -0
  33. data/lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/command_builder.rb +80 -0
  34. data/lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/run_package_specs.rb +49 -0
  35. data/lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/run_specs.rb +226 -0
  36. data/lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli.rb +7 -0
  37. data/lib/ree_spec/packages/ree_spec_cli/spec/package_schema_spec.rb +14 -0
  38. data/lib/ree_spec/packages/ree_spec_cli/spec/ree_spec_cli/run_command_spec.rb +34 -0
  39. data/lib/ree_spec/packages/ree_spec_cli/spec/spec_helper.rb +3 -0
  40. data/lib/ree_spec/ree.setup.rb +3 -0
  41. data/lib/ree_spec/spec.init.rb +16 -0
  42. data/lib/ree_spec/version.rb +5 -0
  43. data/lib/ree_spec.rb +9 -0
  44. data/sig/ree_spec.rbs +2 -0
  45. metadata +132 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89bcb531fc1b60277abd1326ee6951b0a6986bdbf24a3124edb1115275d8fe8f
4
+ data.tar.gz: 1ff1c96f98fee14a6ec57bba45c0db9c67e17e09a0746f648696cfbef5e82add
5
+ SHA512:
6
+ metadata.gz: 62ca0fd3360f080a1caebc9d637a627daf77dd3002f04072cc1530ae56051798e06be9ac4c8b7947dfa66d89a7d7ba3692de3a7c514359f58ea85c9b18582eba
7
+ data.tar.gz: 54d3003cb59a171ebc58e1424d65238379c0e54f7c14981586e4d29e8a12240ed3a2b46c587855325d05202f8767c2b9672a7297eeab9fa9b426cc1d30c3e29b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ruslan.gatiyatov@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ree_lib.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ group :test do
11
+ gem 'rspec'
12
+ gem 'bootsnap'
13
+ gem 'webmock'
14
+ gem 'ruby-prof'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ree_spec (0.0.1)
5
+ commander (~> 5.0.0)
6
+ ree (~> 1.0.47)
7
+ ree_lib (~> 1.0.124)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.8.7)
13
+ public_suffix (>= 2.0.2, < 7.0)
14
+ bigdecimal (3.1.8)
15
+ binding_of_caller (1.0.1)
16
+ debug_inspector (>= 1.2.0)
17
+ bootsnap (1.18.4)
18
+ msgpack (~> 1.2)
19
+ commander (5.0.0)
20
+ highline (~> 3.0.0)
21
+ concurrent-ruby (1.3.4)
22
+ crack (1.0.0)
23
+ bigdecimal
24
+ rexml
25
+ crass (1.0.6)
26
+ debug_inspector (1.2.0)
27
+ diff-lcs (1.5.1)
28
+ hashdiff (1.1.1)
29
+ highline (3.0.1)
30
+ i18n (1.14.5)
31
+ concurrent-ruby (~> 1.0)
32
+ loofah (2.22.0)
33
+ crass (~> 1.0.2)
34
+ nokogiri (>= 1.12.0)
35
+ msgpack (1.7.2)
36
+ nokogiri (1.16.7-x86_64-darwin)
37
+ racc (~> 1.4)
38
+ nokogiri (1.16.7-x86_64-linux)
39
+ racc (~> 1.4)
40
+ oj (3.16.5)
41
+ bigdecimal (>= 3.0)
42
+ ostruct (>= 0.2)
43
+ ostruct (0.6.0)
44
+ public_suffix (6.0.1)
45
+ racc (1.8.1)
46
+ rainbow (3.1.1)
47
+ rake (13.2.1)
48
+ ree (1.0.47)
49
+ commander (~> 5.0.0)
50
+ ree_lib (1.0.124)
51
+ bigdecimal (~> 3.1.6)
52
+ binding_of_caller (~> 1.0.0)
53
+ i18n (~> 1.14.1)
54
+ loofah (~> 2.22.0)
55
+ oj (~> 3.16.3)
56
+ rainbow (~> 3.1.1)
57
+ ree (~> 1.0.0)
58
+ sequel (~> 5.76.0)
59
+ tzinfo (~> 2.0.5)
60
+ rexml (3.3.6)
61
+ strscan
62
+ rspec (3.13.0)
63
+ rspec-core (~> 3.13.0)
64
+ rspec-expectations (~> 3.13.0)
65
+ rspec-mocks (~> 3.13.0)
66
+ rspec-core (3.13.0)
67
+ rspec-support (~> 3.13.0)
68
+ rspec-expectations (3.13.2)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.13.0)
71
+ rspec-mocks (3.13.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.13.0)
74
+ rspec-support (3.13.1)
75
+ ruby-prof (1.7.0)
76
+ sequel (5.76.0)
77
+ bigdecimal
78
+ strscan (3.1.0)
79
+ tzinfo (2.0.6)
80
+ concurrent-ruby (~> 1.0)
81
+ webmock (3.23.1)
82
+ addressable (>= 2.8.0)
83
+ crack (>= 0.3.2)
84
+ hashdiff (>= 0.4.0, < 2.0.0)
85
+
86
+ PLATFORMS
87
+ x86_64-darwin-19
88
+ x86_64-darwin-21
89
+ x86_64-darwin-22
90
+ x86_64-linux
91
+
92
+ DEPENDENCIES
93
+ bootsnap
94
+ rake (~> 13.0)
95
+ ree_spec!
96
+ rspec
97
+ ruby-prof
98
+ webmock
99
+
100
+ BUNDLED WITH
101
+ 2.5.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Ruslan Gatiyatov
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
File without changes
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: %i[spec]
data/exe/ree_spec ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+ require "ree"
7
+
8
+ Ree.init(
9
+ File.expand_path(
10
+ File.join(__dir__, "../lib/ree_spec" )
11
+ )
12
+ )
13
+
14
+ package_require "ree_spec_cli/run_command"
15
+ ReeSpecCli::RunCommand.new.call
@@ -0,0 +1,3 @@
1
+ .irb_history
2
+ .ruby-version
3
+ .irbrc
File without changes
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,15 @@
1
+ module <%= Ree::StringUtils.camelize(package_name) %>
2
+ include Ree::PackageDSL
3
+
4
+ package do
5
+ # Example of usage:
6
+ # tags ['wip']
7
+ # depends_on :package_name
8
+ # env_var 'ENV_VAR_NAME'
9
+ # preload(
10
+ # production: [
11
+ # :bean_or_fn
12
+ # ]
13
+ # )
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "ree"
4
+
5
+ Ree.init(__dir__, irb: true)
@@ -0,0 +1,14 @@
1
+ RSpec.describe "<%= Ree::StringUtils.camelize(package_name) %>" do
2
+ it "generates package schema" do
3
+ require 'fileutils'
4
+
5
+ packages_schema_path = Ree.locate_packages_schema(__dir__)
6
+ packages_schema_dir = Pathname.new(packages_schema_path).dirname.to_s
7
+
8
+ FileUtils.cd packages_schema_dir do
9
+ expect(
10
+ system("bundle exec ree gen.package_json <%= package_name %> --silence")
11
+ ).to eq(true)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.extend Ree::RSpecLinkDSL
3
+ end
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require ./spec.init.rb
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PACKAGE_MODULE::OBJECT_CLASS
4
+ include Ree::FnDSL
5
+
6
+ fn :OBJECT_NAME do
7
+ end
8
+
9
+ contract(None => nil)
10
+ def call()
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe :OBJECT_NAME do
4
+ link :OBJECT_NAME, from: :PACKAGE_NAME
5
+
6
+ it {
7
+ OBJECT_NAME()
8
+ }
9
+ end
@@ -0,0 +1,132 @@
1
+ {
2
+ "schema_version": "1.0",
3
+ "schema_type": "packages",
4
+ "packages": [
5
+ {
6
+ "name": "ree_spec_cli",
7
+ "schema": "packages/ree_spec_cli/Package.schema.json"
8
+ }
9
+ ],
10
+ "gem_packages": [
11
+ {
12
+ "gem": "ree_lib",
13
+ "name": "ree_actions",
14
+ "schema": "packages/ree_actions/Package.schema.json"
15
+ },
16
+ {
17
+ "gem": "ree_lib",
18
+ "name": "ree_array",
19
+ "schema": "packages/ree_array/Package.schema.json"
20
+ },
21
+ {
22
+ "gem": "ree_lib",
23
+ "name": "ree_dao",
24
+ "schema": "packages/ree_dao/Package.schema.json"
25
+ },
26
+ {
27
+ "gem": "ree_lib",
28
+ "name": "ree_date",
29
+ "schema": "packages/ree_date/Package.schema.json"
30
+ },
31
+ {
32
+ "gem": "ree_lib",
33
+ "name": "ree_datetime",
34
+ "schema": "packages/ree_datetime/Package.schema.json"
35
+ },
36
+ {
37
+ "gem": "ree_lib",
38
+ "name": "ree_dto",
39
+ "schema": "packages/ree_dto/Package.schema.json"
40
+ },
41
+ {
42
+ "gem": "ree_lib",
43
+ "name": "ree_enum",
44
+ "schema": "packages/ree_enum/Package.schema.json"
45
+ },
46
+ {
47
+ "gem": "ree_lib",
48
+ "name": "ree_errors",
49
+ "schema": "packages/ree_errors/Package.schema.json"
50
+ },
51
+ {
52
+ "gem": "ree_lib",
53
+ "name": "ree_hash",
54
+ "schema": "packages/ree_hash/Package.schema.json"
55
+ },
56
+ {
57
+ "gem": "ree_lib",
58
+ "name": "ree_http",
59
+ "schema": "packages/ree_http/Package.schema.json"
60
+ },
61
+ {
62
+ "gem": "ree_lib",
63
+ "name": "ree_i18n",
64
+ "schema": "packages/ree_i18n/Package.schema.json"
65
+ },
66
+ {
67
+ "gem": "ree_lib",
68
+ "name": "ree_json",
69
+ "schema": "packages/ree_json/Package.schema.json"
70
+ },
71
+ {
72
+ "gem": "ree_lib",
73
+ "name": "ree_logger",
74
+ "schema": "packages/ree_logger/Package.schema.json"
75
+ },
76
+ {
77
+ "gem": "ree_lib",
78
+ "name": "ree_mapper",
79
+ "schema": "packages/ree_mapper/Package.schema.json"
80
+ },
81
+ {
82
+ "gem": "ree_lib",
83
+ "name": "ree_migrator",
84
+ "schema": "packages/ree_migrator/Package.schema.json"
85
+ },
86
+ {
87
+ "gem": "ree_lib",
88
+ "name": "ree_number",
89
+ "schema": "packages/ree_number/Package.schema.json"
90
+ },
91
+ {
92
+ "gem": "ree_lib",
93
+ "name": "ree_object",
94
+ "schema": "packages/ree_object/Package.schema.json"
95
+ },
96
+ {
97
+ "gem": "ree_lib",
98
+ "name": "ree_roda",
99
+ "schema": "packages/ree_roda/Package.schema.json"
100
+ },
101
+ {
102
+ "gem": "ree_lib",
103
+ "name": "ree_routes",
104
+ "schema": "packages/ree_routes/Package.schema.json"
105
+ },
106
+ {
107
+ "gem": "ree_lib",
108
+ "name": "ree_std",
109
+ "schema": "packages/ree_std/Package.schema.json"
110
+ },
111
+ {
112
+ "gem": "ree_lib",
113
+ "name": "ree_string",
114
+ "schema": "packages/ree_string/Package.schema.json"
115
+ },
116
+ {
117
+ "gem": "ree_lib",
118
+ "name": "ree_swagger",
119
+ "schema": "packages/ree_swagger/Package.schema.json"
120
+ },
121
+ {
122
+ "gem": "ree_lib",
123
+ "name": "ree_text",
124
+ "schema": "packages/ree_text/Package.schema.json"
125
+ },
126
+ {
127
+ "gem": "ree_lib",
128
+ "name": "ree_validator",
129
+ "schema": "packages/ree_validator/Package.schema.json"
130
+ }
131
+ ]
132
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "ree"
4
+
5
+ Ree.init(__dir__, irb: true)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ package_require('RELATIVE_FILE_PATH')
4
+
5
+ RSpec.describe MODULE_NAME::CLASS_NAME do
6
+ let(:OBJECT_NAME) { described_class.new }
7
+
8
+ it {
9
+ OBJECT_NAME.()
10
+ }
11
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,40 @@
1
+ {
2
+ "schema_type": "package",
3
+ "schema_version": "1.1",
4
+ "name": "ree_spec_cli",
5
+ "entry_path": "packages/ree_spec_cli/package/ree_spec_cli.rb",
6
+ "tags": [
7
+ "ree_spec_cli"
8
+ ],
9
+ "depends_on": [
10
+ {
11
+ "name": "ree_array"
12
+ }
13
+ ],
14
+ "env_vars": [
15
+
16
+ ],
17
+ "objects": [
18
+ {
19
+ "name": "run_command",
20
+ "schema": "packages/ree_spec_cli/schemas/ree_spec_cli/run_command.schema.json",
21
+ "tags": [
22
+ "fn"
23
+ ]
24
+ },
25
+ {
26
+ "name": "run_package_specs",
27
+ "schema": "packages/ree_spec_cli/schemas/ree_spec_cli/services/run_package_specs.schema.json",
28
+ "tags": [
29
+ "fn"
30
+ ]
31
+ },
32
+ {
33
+ "name": "run_specs",
34
+ "schema": "packages/ree_spec_cli/schemas/ree_spec_cli/services/run_specs.schema.json",
35
+ "tags": [
36
+ "fn"
37
+ ]
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "ree"
4
+
5
+ Ree.init(__dir__, irb: true)
@@ -0,0 +1,22 @@
1
+ require "commander"
2
+
3
+ class ReeSpecCli::RunCommand
4
+ include Ree::FnDSL
5
+
6
+ fn :run_command do
7
+ link "ree_spec_cli/services/command_builder", -> { CommandBuilder }
8
+ link :run_specs
9
+ end
10
+
11
+ def call
12
+ action_proc = Proc.new do |package_names, spec_matcher, tag, files, run_all, project_path, process_count, specs_per_process|
13
+ run_specs(
14
+ package_names, spec_matcher, tag, files, run_all,
15
+ project_path, process_count, specs_per_process
16
+ )
17
+ end
18
+
19
+ command = CommandBuilder.new.build(&action_proc)
20
+ command.run!
21
+ end
22
+ end
@@ -0,0 +1,80 @@
1
+ class ReeSpecCli::CommandBuilder
2
+ include Commander::Methods
3
+
4
+ DEFAULT_PROCESS_COUNT = 1
5
+ DEFAULT_SPECS_PER_PROCESS_COUNT = 5
6
+
7
+ def build(&action_proc)
8
+ files = []
9
+ package_names = []
10
+ run_all = false
11
+ process_count = DEFAULT_PROCESS_COUNT
12
+ specs_per_process = DEFAULT_SPECS_PER_PROCESS_COUNT
13
+
14
+ program :name, "Ree Spec"
15
+ program :version, ReeSpec::VERSION
16
+ program :description, "Ree extensions for Rspec framework"
17
+ program :help, "Author", "Ruslan Gatiyatov"
18
+
19
+ command :run do |c|
20
+ c.syntax = "ree spec PACKAGE_NAME SPEC_MATCHER [options]"
21
+ c.description = "run tests for specified package"
22
+ c.example "ree spec accounts", "Run specs for \"accounts\" package"
23
+ c.example "ree spec -p accounts -p roles", "Run specs for several packages"
24
+ c.example "ree spec accounts welcome_email:42", "Run specific spec from specified package using spec matcher"
25
+ c.example "ree spec --tag wip", "Run specs for packages which have \"wip\" tag"
26
+ c.option "--project_path [ROOT_DIR]", String, "Root project dir path"
27
+ c.option "--tag TAG_NAME", String, "Run specs for packages with specified tag"
28
+ c.option "--parallel OPTS", String, "Run specs in parallel processes (e.g. --parallel 15:5, 15 processes, max 5 package spec files per process)"
29
+
30
+ c.option "-f SPEC_FILE", "--fule SPEC_FILE", String, "List of spec files" do |f|
31
+ files ||= []
32
+ files << f
33
+ end
34
+
35
+ c.option "-p PACKAGE_NAME", "--package PACKAGE_NAME", String, "List of packages" do |o|
36
+ package_names << o.to_sym
37
+ end
38
+
39
+ c.action do |args, options|
40
+ package_name = args[0]&.to_sym
41
+ spec_matcher = args[1]
42
+ options_hash = options.__hash__
43
+ options_hash.delete(:trace)
44
+
45
+ if options_hash[:project_path]
46
+ options_hash[:project_path] = File.expand_path(options_hash[:project_path])
47
+ end
48
+
49
+ if package_name
50
+ package_names << package_name
51
+ end
52
+
53
+ if package_name.nil? && package_names.empty?
54
+ run_all = true
55
+ end
56
+
57
+ if options_hash[:parallel]
58
+ parallel = options_hash[:parallel].split(":")[0..1]
59
+ process_count = Integer(parallel.first)
60
+
61
+ if parallel.size > 1
62
+ specs_per_process = Integer(parallel.last)
63
+ end
64
+ end
65
+
66
+ if package_names.size > 1
67
+ files = []
68
+ end
69
+
70
+ action_proc.call(
71
+ package_names, spec_matcher, options_hash[:tag], files,
72
+ run_all, options_hash[:project_path] || File.expand_path(Dir.pwd),
73
+ process_count, specs_per_process
74
+ )
75
+ end
76
+ end
77
+
78
+ self
79
+ end
80
+ end
@@ -0,0 +1,49 @@
1
+ require "open3"
2
+ require "fileutils"
3
+
4
+ class ReeSpecCli::RunPackageSpecs
5
+ include Ree::FnDSL
6
+
7
+ fn :run_package_specs
8
+
9
+ class CommandResult < Struct.new(:out, :err, :status); end
10
+
11
+
12
+ contract(Ree::Package, ArrayOf[String], Integer => CommandResult)
13
+ def call(package, files, test_env_number)
14
+ package_path = File.join(Ree.root_dir, package.dir)
15
+ package_spec_path = File.join(package_path, 'spec')
16
+ package_spec_helper = File.join(package_path, 'spec', 'spec_helper.rb')
17
+ result = nil
18
+
19
+ FileUtils.cd(Ree.root_dir) do
20
+ result = run_shell_command(
21
+ "TEST_ENV_NUMBER=#{test_env_number} bundle exec rspec --color --tty #{files.join(" ")} --default-path=#{package_spec_path} --require=#{package_spec_helper}"
22
+ )
23
+ end
24
+
25
+ result
26
+ end
27
+
28
+ private
29
+
30
+ def run_shell_command(command)
31
+ out_str = ""
32
+ err_str = ""
33
+ status = nil
34
+
35
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
36
+ stdout.each_line do |line|
37
+ out_str << line
38
+ end
39
+
40
+ stderr.each_line do |line|
41
+ err_str << line
42
+ end
43
+
44
+ status = wait_thr.value
45
+ end
46
+
47
+ CommandResult.new(out_str, err_str, status)
48
+ end
49
+ end
@@ -0,0 +1,226 @@
1
+ class ReeSpecCli::RunSpecs
2
+ include Ree::FnDSL
3
+
4
+ fn :run_specs do
5
+ link :in_groups_of, from: :ree_array
6
+ link :run_package_specs
7
+ end
8
+
9
+ MAX_SPECS_PER_PROCESS = 1000
10
+
11
+ contract ArrayOf[Symbol], Nilor[String], Nilor[String], ArrayOf[String], Bool, String, Integer, Integer => nil
12
+ def call(package_names, spec_matcher, tag, files, run_all, project_path,
13
+ process_count, specs_per_process)
14
+ init_ree_project(project_path)
15
+
16
+ packages = filter_packages_to_run(package_names, tag, run_all)
17
+ specs_per_process = calculate_specs_per_process(process_count, specs_per_process)
18
+ jobs = get_jobs(packages, specs_per_process, spec_matcher, files)
19
+
20
+ processes = build_processes(process_count)
21
+ error_files = []
22
+ success_files = []
23
+
24
+ jobs.each do |job|
25
+ number = wait_for_vailable_process(processes)
26
+ error_file, success_file = Tempfile.new, Tempfile.new
27
+ error_files.push(error_file)
28
+ success_files.push(success_file)
29
+
30
+ processes[number] = Process.fork do
31
+ print_start_message(job)
32
+ result = run_package_specs(job.package, job.files, number)
33
+
34
+ if result.status.exitstatus != 0
35
+ error_file.write(result.out)
36
+ error_file.rewind
37
+ puts(result.out)
38
+ else
39
+ success_file.write(result.out)
40
+ success_file.rewind
41
+ end
42
+ end
43
+ end
44
+
45
+ processes.each { |k, v| Process.wait(v) if !v.nil? }
46
+
47
+ print_messages(error_files, success_files)
48
+
49
+ nil
50
+ end
51
+
52
+ private
53
+
54
+ def build_processes(process_count)
55
+ result = {}
56
+
57
+ process_count.times do |i|
58
+ result[i] = nil
59
+ end
60
+
61
+ result
62
+ end
63
+
64
+ def print_start_message(job)
65
+ puts("\n**** Running #{job.files.size} spec#{job.files.size == 1 ? "" : "s"} for #{job.package.name} ****\n")
66
+ end
67
+
68
+ def print_messages(error_files, success_files)
69
+ success_files.each { puts(_1.read) }
70
+
71
+ errors = error_files.map { _1.read }
72
+ return if errors.empty?
73
+
74
+ failures = errors
75
+ .map { _1.split("Failed examples:")[1].to_s.strip }
76
+ .compact
77
+ .reject(&:empty?)
78
+ .join("\n")
79
+
80
+ puts("**** Failed examples from all specs: ****\n\n")
81
+ puts(failures)
82
+ puts("\n\n")
83
+ ensure
84
+ error_files.each(&:close)
85
+ success_files.each(&:close)
86
+ end
87
+
88
+ def wait_for_vailable_process(processes)
89
+ process = processes.find { |k, v| v.nil? }
90
+
91
+ if process
92
+ return process.first
93
+ end
94
+
95
+ number = nil
96
+
97
+ processes.each do |k, v|
98
+ Process.wait(v)
99
+ processes[k] = nil
100
+ number = k
101
+ break
102
+ end
103
+
104
+ number
105
+ end
106
+
107
+ class Job < Struct.new(:package, :dir, :files); end
108
+
109
+ def get_jobs(package_names, specs_per_process, spec_matcher, files)
110
+ result = []
111
+ packages = package_names.map { packages_facade.get_package(_1) }
112
+
113
+ packages.each do |package|
114
+ dir = Ree::PathHelper.abs_package_module_dir(package)
115
+
116
+ spec_files = get_spec_files(package, spec_matcher, files)
117
+
118
+ in_groups_of(spec_files, specs_per_process).each do |specs_group|
119
+ result << Job.new(package, dir, specs_group)
120
+ end
121
+ end
122
+
123
+ result
124
+ end
125
+
126
+ def get_spec_files(package, spec_matcher, files)
127
+ package_dir = Ree::PathHelper.abs_package_dir(package)
128
+ all_specs = Dir["#{package_dir}/spec/**/*_spec.rb"]
129
+
130
+ if spec_matcher
131
+ line_number = nil
132
+
133
+ if spec_matcher.include?(":")
134
+ parts = spec_matcher.split(":")
135
+ spec_matcher = parts[0]
136
+ line_number = parts[1]
137
+ end
138
+
139
+ file_path = File.join(package_dir, spec_matcher)
140
+
141
+ if File.directory?(file_path)
142
+ Dir["#{file_path}/**/*_spec.rb"]
143
+ elsif File.exist?(file_path)
144
+ if line_number
145
+ ["#{file_path}:#{line_number}"]
146
+ else
147
+ [file_path]
148
+ end
149
+ else
150
+ result = all_specs.select do |spec|
151
+ spec =~ /#{spec_matcher.split('').join('.*')}/
152
+ end
153
+
154
+ if result.size == 0 && line_number
155
+ ["#{result.first}:#{line_number}"]
156
+ else
157
+ result
158
+ end
159
+ end
160
+ elsif files && files.size > 0
161
+ files
162
+ else
163
+ all_specs
164
+ end
165
+ end
166
+
167
+ def calculate_specs_per_process(process_count, specs_per_process)
168
+ if process_count > 1
169
+ specs_per_process
170
+ else
171
+ MAX_SPECS_PER_PROCESS
172
+ end
173
+ end
174
+
175
+ def filter_packages_to_run(package_names, tag, run_all)
176
+ packages_to_run = []
177
+
178
+ if tag
179
+ package_names = filter_existing_packages(package_names)
180
+ tagged_packages = filter_packages_by_tag(package_names, tag)
181
+ packages_to_run += tagged_packages
182
+ elsif run_all
183
+ packages_to_run += all_packages.map(&:name)
184
+ else
185
+ package_names = filter_existing_packages(package_names)
186
+ packages_to_run += package_names
187
+ end
188
+
189
+ packages_to_run.uniq
190
+ end
191
+
192
+ def init_ree_project(project_path)
193
+ schema_path = Ree.locate_packages_schema(project_path)
194
+ schema_dir = Pathname.new(schema_path).dirname.to_s
195
+ Ree.init(schema_dir)
196
+ packages_facade.load_packages_schema
197
+ end
198
+
199
+ def packages_facade
200
+ Ree.container.packages_facade
201
+ end
202
+
203
+ def all_packages
204
+ packages_facade.packages_store.packages.select { !_1.gem? }
205
+ end
206
+
207
+ def filter_existing_packages(package_names)
208
+ existing_packages = all_packages.map(&:name)
209
+ extra_packages = package_names - existing_packages
210
+
211
+ extra_packages.each do |package|
212
+ puts "Package #{package} not found"
213
+ end
214
+
215
+ package_names - extra_packages
216
+ end
217
+
218
+ def filter_packages_by_tag(packages, tag)
219
+ package_names = packages.map(&:name)
220
+
221
+ package_names.select do |package_name|
222
+ package = packages_facade.read_package_schema_json(package_name)
223
+ package.tags.include?(tag)
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,7 @@
1
+ module ReeSpecCli
2
+ include Ree::PackageDSL
3
+
4
+ package do
5
+ depends_on :ree_array
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ RSpec.describe "ReeSpecCli" do
2
+ it "generates package schema" do
3
+ require 'fileutils'
4
+
5
+ packages_schema_path = Ree.locate_packages_schema(__dir__)
6
+ packages_schema_dir = Pathname.new(packages_schema_path).dirname.to_s
7
+
8
+ FileUtils.cd packages_schema_dir do
9
+ expect(
10
+ system("bundle exec ree gen.package_json ree_spec_cli --silence")
11
+ ).to eq(true)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe :run_command do
4
+ link :run_command, from: :ree_spec_cli
5
+
6
+ it {
7
+ project_path = File.expand_path(
8
+ File.join(__dir__, "../../../../../../../ree/spec/sample_project")
9
+ )
10
+
11
+ ARGV.clear
12
+ ARGV << "run"
13
+ ARGV << "accounts"
14
+ ARGV << "--project_path"
15
+ ARGV << project_path
16
+
17
+ run_command()
18
+ }
19
+
20
+ it {
21
+ project_path = File.expand_path(
22
+ File.join(__dir__, "../../../../../../../ree/spec/sample_project")
23
+ )
24
+
25
+ ARGV.clear
26
+ ARGV << "run"
27
+ ARGV << "accounts"
28
+ ARGV << "build_user"
29
+ ARGV << "--project_path"
30
+ ARGV << project_path
31
+
32
+ run_command()
33
+ }
34
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.extend Ree::RSpecLinkDSL
3
+ end
@@ -0,0 +1,3 @@
1
+ require "ree_lib"
2
+
3
+ Ree.set_performance_mode
@@ -0,0 +1,16 @@
1
+ require 'bootsnap'
2
+
3
+ Bootsnap.setup(
4
+ cache_dir: '/tmp/bootsnap_cache',
5
+ development_mode: true,
6
+ load_path_cache: true,
7
+ compile_cache_iseq: true,
8
+ compile_cache_yaml: true
9
+ )
10
+
11
+ require 'rspec'
12
+ require 'ree'
13
+
14
+ ENV["RUBY_ENV"] = "test"
15
+
16
+ Ree.init(__dir__)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ReeSpec
4
+ VERSION = "0.0.1"
5
+ end
data/lib/ree_spec.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ree_spec/version"
4
+ require "ree"
5
+
6
+ module ReeSpec
7
+ end
8
+
9
+ Ree.register_gem(:ree_spec, File.join(__dir__, "ree_spec"))
data/sig/ree_spec.rbs ADDED
@@ -0,0 +1,2 @@
1
+ module ReeSpec
2
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ree_spec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ruslan Gatiyatov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.47
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.47
27
+ - !ruby/object:Gem::Dependency
28
+ name: ree_lib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.124
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.124
41
+ - !ruby/object:Gem::Dependency
42
+ name: commander
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 5.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 5.0.0
55
+ description: Ree Spec provides executable to run Rspec suite for Ree packages
56
+ email:
57
+ - ruslan.gatiyatov@gmail.com
58
+ executables:
59
+ - ree_spec
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".ruby-version"
66
+ - CHANGELOG.md
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - exe/ree_spec
74
+ - lib/ree_spec.rb
75
+ - lib/ree_spec/.gitignore
76
+ - lib/ree_spec/.ree/templates/package/.gitignore
77
+ - lib/ree_spec/.ree/templates/package/.rspec
78
+ - lib/ree_spec/.ree/templates/package/<%=package_subdir_name%>/<%=package_name%>.rb
79
+ - lib/ree_spec/.ree/templates/package/<%=package_subdir_name%>/<%=package_name%>/.gitkeep
80
+ - lib/ree_spec/.ree/templates/package/Package.schema.json
81
+ - lib/ree_spec/.ree/templates/package/bin/console
82
+ - lib/ree_spec/.ree/templates/package/spec/package_schema_spec.rb
83
+ - lib/ree_spec/.ree/templates/package/spec/spec_helper.rb
84
+ - lib/ree_spec/.rspec
85
+ - lib/ree_spec/.vscode-ree/templates/functions/template.rb
86
+ - lib/ree_spec/.vscode-ree/templates/spec_template.rb
87
+ - lib/ree_spec/Packages.schema.json
88
+ - lib/ree_spec/bin/console
89
+ - lib/ree_spec/packages/.vscode-ree/templates/spec_template.rb
90
+ - lib/ree_spec/packages/ree_spec_cli/.gitignore
91
+ - lib/ree_spec/packages/ree_spec_cli/.rspec
92
+ - lib/ree_spec/packages/ree_spec_cli/Package.schema.json
93
+ - lib/ree_spec/packages/ree_spec_cli/bin/console
94
+ - lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli.rb
95
+ - lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/run_command.rb
96
+ - lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/command_builder.rb
97
+ - lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/run_package_specs.rb
98
+ - lib/ree_spec/packages/ree_spec_cli/package/ree_spec_cli/services/run_specs.rb
99
+ - lib/ree_spec/packages/ree_spec_cli/spec/package_schema_spec.rb
100
+ - lib/ree_spec/packages/ree_spec_cli/spec/ree_spec_cli/run_command_spec.rb
101
+ - lib/ree_spec/packages/ree_spec_cli/spec/spec_helper.rb
102
+ - lib/ree_spec/ree.setup.rb
103
+ - lib/ree_spec/spec.init.rb
104
+ - lib/ree_spec/version.rb
105
+ - sig/ree_spec.rbs
106
+ homepage: https://github.com/glabix/ree/tree/main/ree_spec
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ homepage_uri: https://github.com/glabix/ree/tree/main/ree_spec
111
+ source_code_uri: https://github.com/glabix/ree/tree/main/ree_spec
112
+ changelog_uri: https://github.com/glabix/ree/blob/main/ree_spec/CHANGELOG.md
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '3.1'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.5.3
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Ree extensions for Rspec framework
132
+ test_files: []