foobara-empty-ruby-project-generator 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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/LICENSE-APACHE.txt +202 -0
  4. data/LICENSE-MIT.txt +21 -0
  5. data/LICENSE.txt +8 -0
  6. data/README.md +49 -0
  7. data/lib/foobara/empty_ruby_project_generator.rb +4 -0
  8. data/src/generate_empty_ruby_project.rb +43 -0
  9. data/src/generators/bin_console_generator.rb +15 -0
  10. data/src/generators/boot_finish_generator.rb +15 -0
  11. data/src/generators/changelog_generator.rb +15 -0
  12. data/src/generators/ci_yaml_generator.rb +13 -0
  13. data/src/generators/gemspec_generator.rb +19 -0
  14. data/src/generators/gitignore_generator.rb +15 -0
  15. data/src/generators/initial_spec_generator.rb +23 -0
  16. data/src/generators/lib_generator.rb +27 -0
  17. data/src/generators/license_generator.rb +15 -0
  18. data/src/generators/project_generator.rb +39 -0
  19. data/src/generators/version_generator.rb +15 -0
  20. data/src/manifests/project_config.rb +138 -0
  21. data/src/write_empty_ruby_project_to_disk.rb +192 -0
  22. data/templates/.bundle/config +2 -0
  23. data/templates/.github/workflows/ci.yml.erb +87 -0
  24. data/templates/.gitignore.erb +15 -0
  25. data/templates/.rspec +4 -0
  26. data/templates/.rubocop.yml +12 -0
  27. data/templates/.ruby-version +1 -0
  28. data/templates/CHANGELOG.md.erb +5 -0
  29. data/templates/Gemfile +38 -0
  30. data/templates/Guardfile +6 -0
  31. data/templates/LICENSE.txt.erb +21 -0
  32. data/templates/README.md +49 -0
  33. data/templates/Rakefile +14 -0
  34. data/templates/bin/console.erb +17 -0
  35. data/templates/bin/setup +8 -0
  36. data/templates/boot/config.rb +9 -0
  37. data/templates/boot/finish.rb.erb +24 -0
  38. data/templates/boot/start.rb +10 -0
  39. data/templates/boot.rb +2 -0
  40. data/templates/gemspec.gemspec.erb +30 -0
  41. data/templates/lib/project_require_file.rb.erb +3 -0
  42. data/templates/spec/initial_spec.rb.erb +5 -0
  43. data/templates/spec/spec_helper.rb +24 -0
  44. data/templates/spec/support/rubyprof.rb +14 -0
  45. data/templates/spec/support/simplecov.rb +9 -0
  46. data/templates/spec/support/term_trap.rb +6 -0
  47. data/templates/spec/support/vcr.rb +8 -0
  48. data/templates/src/version.rb.erb +7 -0
  49. metadata +123 -0
@@ -0,0 +1,138 @@
1
+ require "English"
2
+
3
+ module Foobara
4
+ module Generators
5
+ module EmptyRubyProjectGenerator
6
+ class ProjectConfig < Foobara::Model
7
+ attributes do
8
+ name :string, "Name can be the directory to create or optionally org/directory. " \
9
+ "The org will be used as the github org and " \
10
+ "the directory will be used as the github repository." \
11
+ "For example, `some-org-on-github/some-repository-name` would create " \
12
+ "a project modules of `SomeOrgOnGithub::SomeRepositoryName` " \
13
+ "(unless you override the module name.)"
14
+ # This specifies the module nesting for generated files for this project. It might have prefixes left out of
15
+ # the project_name. It will default to Org::Project
16
+ full_module_name :string, "If you want a different module name than the one inferred from the name input " \
17
+ "then specify it with this option."
18
+ description :string, default: "No description. Add one."
19
+ author_names [:string]
20
+ author_emails [:string]
21
+ homepage_url :string
22
+ # Probably need a better default such as not licensed.
23
+ license :string, default: "None specified yet"
24
+ end
25
+
26
+ def kebab_case_project_name
27
+ Util.kebab_case(project_module_path.join)
28
+ end
29
+
30
+ def kebab_case_full_project_name
31
+ Util.kebab_case(full_project_path.join)
32
+ end
33
+
34
+ def org_slash_project_kebab(organization_name = self.organization_name, project_name = self.project_name)
35
+ org_part = Util.kebab_case(organization_name)&.gsub("::", "-")
36
+ project_part = Util.kebab_case(project_name).gsub("::", "-")
37
+
38
+ if org_part.nil? || org_part.empty?
39
+ project_part
40
+ else
41
+ "#{org_part}/#{project_part}"
42
+ end
43
+ end
44
+
45
+ def org_slash_project_underscore
46
+ org_slash_project_kebab.gsub("-", "_")
47
+ end
48
+
49
+ def project_lib_file_path
50
+ full_project_path.map { |part| Util.underscore(part) }.join("/")
51
+ end
52
+
53
+ def organization_name
54
+ @organization_name ||= begin
55
+ org_and_project = name.split("/")
56
+
57
+ if org_and_project.size == 2
58
+ org_and_project.first
59
+ end
60
+ end
61
+ end
62
+
63
+ def project_name
64
+ @project_name ||= name.split("/").last
65
+ end
66
+
67
+ def project_module_path
68
+ @project_module_path ||= kebab_to_module_path(project_name)
69
+ end
70
+
71
+ def project_module_name
72
+ @project_module_name ||= project_module_path.join("::")
73
+ end
74
+
75
+ def organization_module_path
76
+ @organization_module_path ||= kebab_to_module_path(organization_name)
77
+ end
78
+
79
+ def organization_module_name
80
+ @organization_module_name ||= organization_module_path.join("::")
81
+ end
82
+
83
+ # TODO: These two are not great names. Should have the word "module" in them.
84
+ def full_project_path
85
+ @full_project_path ||= full_module_name&.split("::") || [*organization_module_path, *project_module_path]
86
+ end
87
+
88
+ def full_project_name
89
+ @full_project_name ||= [organization_module_name, project_module_name].compact.join("::")
90
+ end
91
+
92
+ def author_names
93
+ # TODO: implement #[] or move it up to Model from Entity if it exists there.
94
+ @author_names ||= read_attribute(:author_names) || begin
95
+ # TODO: dump a git config file in CI so we don't have to skip this
96
+ # :nocov:
97
+ name = `git config --get user.name`
98
+
99
+ if $CHILD_STATUS.exitstatus == 0
100
+ [name.strip]
101
+ else
102
+ raise "Must set author_names because we can't get it from git for some reason"
103
+ end
104
+ # :nocov:
105
+ end
106
+ end
107
+
108
+ def author_emails
109
+ @author_emails ||= read_attribute(:author_emails) || begin
110
+ # :nocov:
111
+ email = `git config --get user.email`
112
+
113
+ if $CHILD_STATUS.exitstatus == 0
114
+ [email.strip]
115
+ else
116
+ raise "Must set author_emails because we can't get it from git for some reason"
117
+ end
118
+ # :nocov:
119
+ end
120
+ end
121
+
122
+ def homepage_url
123
+ @homepage_url ||= "https://github.com/#{org_slash_project_kebab(organization_name, project_module_name)}"
124
+ end
125
+
126
+ private
127
+
128
+ def kebab_to_module_path(kebab)
129
+ if kebab
130
+ kebab.split("_").map { |part| Util.classify(part.gsub("-", "_")) }
131
+ else
132
+ []
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,192 @@
1
+ require_relative "generate_empty_ruby_project"
2
+
3
+ module Foobara
4
+ module Generators
5
+ module EmptyRubyProjectGenerator
6
+ class WriteEmptyRubyProjectToDisk < Foobara::Generators::WriteGeneratedFilesToDisk
7
+ class << self
8
+ def generator_key
9
+ "ruby-project"
10
+ end
11
+ end
12
+
13
+ depends_on GenerateEmptyRubyProject
14
+
15
+ inputs do
16
+ project_config ProjectConfig, :required
17
+ # TODO: should be able to delete this and inherit it
18
+ output_directory :string
19
+ end
20
+
21
+ def execute
22
+ generate_file_contents
23
+ write_all_files_to_disk
24
+ run_post_generation_tasks
25
+
26
+ output
27
+ end
28
+
29
+ def output_directory
30
+ inputs[:output_directory] || default_output_directory
31
+ end
32
+
33
+ def default_output_directory
34
+ project_config.org_slash_project_kebab
35
+ end
36
+
37
+ def generate_file_contents
38
+ puts "generating..."
39
+ # TODO: just pass this in as the inputs instead of the command??
40
+ self.paths_to_source_code = run_subcommand!(GenerateEmptyRubyProject, project_config.attributes)
41
+ end
42
+
43
+ def run_post_generation_tasks
44
+ Dir.chdir output_directory do
45
+ bundle_install
46
+ make_bin_files_executable
47
+ rubocop_autocorrect
48
+ git_init
49
+ git_add_all
50
+ git_commit
51
+ github_create_repo
52
+ git_add_remote_origin
53
+ git_branch_main
54
+ push_to_github
55
+ rbenv_bundler_on
56
+ end
57
+ end
58
+
59
+ def bundle_install
60
+ puts "bundling..."
61
+ Bundler.with_unbundled_env do
62
+ Open3.popen3("bundle install") do |_stdin, _stdout, stderr, wait_thr|
63
+ exit_status = wait_thr.value
64
+ unless exit_status.success?
65
+ # :nocov:
66
+ raise "could not bundle install. #{stderr.read}"
67
+ # :nocov:
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ def rubocop_autocorrect
74
+ puts "linting..."
75
+ Open3.popen3("bundle exec rubocop --no-server -A") do |_stdin, _stdout, stderr, wait_thr|
76
+ exit_status = wait_thr.value
77
+ unless exit_status.success?
78
+ # :nocov:
79
+ raise "could not bundle exec rubocop -A. #{stderr.read}"
80
+ # :nocov:
81
+ end
82
+ end
83
+ end
84
+
85
+ def make_bin_files_executable
86
+ Dir["bin/*"].each do |file|
87
+ if File.file?(file)
88
+ system("chmod u+x #{file}")
89
+ end
90
+ end
91
+ end
92
+
93
+ def git_init
94
+ cmd = "git init"
95
+
96
+ Open3.popen3(cmd) do |_stdin, _stdout, stderr, wait_thr|
97
+ exit_status = wait_thr.value
98
+ unless exit_status.success?
99
+ # :nocov:
100
+ raise "could not #{cmd}\n#{stderr.read}"
101
+ # :nocov:
102
+ end
103
+ end
104
+ end
105
+
106
+ def git_add_all
107
+ unless system("git add .")
108
+ # :nocov:
109
+ raise "could not git add ."
110
+ # :nocov:
111
+ end
112
+ end
113
+
114
+ def git_commit
115
+ # TODO: set author/name with git config in CI so we don't have to skip this
116
+ # :nocov:
117
+ Open3.popen3("git commit -m 'Initial commit'") do |_stdin, _stdout, stderr, wait_thr|
118
+ exit_status = wait_thr.value
119
+ unless exit_status.success?
120
+ raise "could not git commit -m 'Initial commit'. #{stderr.read}"
121
+ end
122
+ end
123
+ # :nocov:
124
+ end
125
+
126
+ attr_accessor :origin_set, :pushed
127
+
128
+ def github_create_repo
129
+ puts "pushing to github..."
130
+
131
+ cmd = "gh repo create --public --push --source=. #{project_config.org_slash_project_kebab}"
132
+
133
+ Open3.popen3(cmd) do |_stdin, _stdout, _stderr, wait_thr|
134
+ exit_status = wait_thr.value
135
+ if exit_status.success?
136
+ # :nocov:
137
+ self.origin_set = true
138
+ self.pushed = true
139
+ # :nocov:
140
+ else
141
+ warn "WARNING: could not #{cmd}"
142
+ end
143
+ end
144
+ end
145
+
146
+ def git_add_remote_origin
147
+ return if origin_set
148
+
149
+ unless system("git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git")
150
+ # :nocov:
151
+ raise "could not git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git"
152
+ # :nocov:
153
+ end
154
+ end
155
+
156
+ def git_branch_main
157
+ unless system("git branch -M main")
158
+ # :nocov:
159
+ raise "could not git branch -M main"
160
+ # :nocov:
161
+ end
162
+ end
163
+
164
+ def push_to_github
165
+ return if pushed
166
+
167
+ Open3.popen3("git push -u origin main") do |_stdin, _stdout, stderr, wait_thr|
168
+ exit_status = wait_thr.value
169
+ unless exit_status.success?
170
+ warn "WARNING: could not git push -u origin main \n #{stderr.read}"
171
+ end
172
+ end
173
+ end
174
+
175
+ def rbenv_bundler_on
176
+ # :nocov:
177
+ Open3.popen3("rbenv bundler on") do |_stdin, _stdout, stderr, wait_thr|
178
+ exit_status = wait_thr.value
179
+ unless exit_status.success?
180
+ warn "WARNING: could not rbenv bundler on \n #{stderr.read}"
181
+ end
182
+ end
183
+ # :nocov:
184
+ end
185
+
186
+ def output
187
+ "\nDone. #{stats}"
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_LOCAL_BRANCH_CHECK: "true"
@@ -0,0 +1,87 @@
1
+ name: RSpec and Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ ci:
12
+ runs-on: ubuntu-latest
13
+ name: RSpec and Rubocop
14
+ timeout-minutes: 3
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+ - name: setup ruby version and foobara branch and sha1
18
+ run: |
19
+ foobara_entry=`grep -A2 -m 1 ' remote: foobara$' Gemfile.lock`
20
+ regex="revision: ([0-9a-f]+)\s+branch: ([-_[:alnum:]]+)$"
21
+
22
+ if [[ $foobara_entry =~ $regex ]]; then
23
+ foobara_sha1="${BASH_REMATCH[1]}"
24
+ foobara_branch="${BASH_REMATCH[2]}"
25
+
26
+ echo foobara_sha1=$foobara_sha1 >> "$GITHUB_ENV"
27
+ echo foobara_branch=$foobara_branch >> "$GITHUB_ENV"
28
+ else
29
+ echo "$foobara_entry doesn't match $regex" >&2
30
+ fi
31
+
32
+ echo ruby_version=`cat .ruby-version` >> "$GITHUB_ENV"
33
+ - name: cache foobara
34
+ id: cache-foobara
35
+ uses: actions/cache@v3
36
+ env:
37
+ cache-name: cache-foobara
38
+ with:
39
+ path: ~/work/<%= kebab_case_project_name %>/foobara
40
+ key: ${{ env.cache-name }}-${{ env.foobara_branch }}-${{ env.foobara_sha1 }}
41
+ restore-keys: |
42
+ ${{ env.cache-name }}-${{ env.foobara_branch }}-
43
+ ${{ env.cache-name }}-
44
+ - if: ${{ steps.cache-foobara.outputs.cache-hit != 'true' }}
45
+ name: clone or pull foobara
46
+ run: |
47
+ set -e
48
+ cd ..
49
+ if [ -d foobara ]; then
50
+ echo pulling
51
+ cd foobara
52
+ ssh-agent sh -c 'echo "${{ secrets.FOOBARA_KEY }}" | ssh-add - &&
53
+ git fetch --depth=1 origin $foobara_sha1 &&
54
+ if git rev-parse --verify -q $foobara_branch; then
55
+ git checkout -q $foobara_branch
56
+ git reset --hard $foobara_sha1
57
+ else
58
+ git branch $foobara_branch $foobara_sha1
59
+ git checkout -q $foobara_branch
60
+ fi'
61
+ else
62
+ echo cloning
63
+ ssh-agent sh -c 'echo "${{ secrets.FOOBARA_KEY }}" | ssh-add - &&
64
+ git clone -b $foobara_branch --depth=1 git@github.com:foobara/foobara.git'
65
+ fi
66
+ - name: symlink foobara and point bundler at it
67
+ run: |
68
+ set -e
69
+ mkdir -p .bundle
70
+ echo -e "---\nBUNDLE_LOCAL__FOOBARA: '/home/runner/work/<%= kebab_case_project_name %>/foobara'" > .bundle/config
71
+ mkdir ../../foobara
72
+ ln -s ../../<%= kebab_case_project_name %>/foobara ../../foobara/foobara
73
+ - name: Set up Ruby
74
+ uses: ruby/setup-ruby@v1
75
+ with:
76
+ ruby-version: ${{ env.ruby_version }}
77
+ bundler-cache: true
78
+ - name: Run rspec
79
+ run: bundle exec rspec
80
+ - name: Run rubocop
81
+ run: bundle exec rubocop
82
+ # - name: Upload coverage directory
83
+ # if: always()
84
+ # uses: actions/upload-artifact@v2
85
+ # with:
86
+ # name: coverage-report
87
+ # path: coverage/
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ /.rspec_status
11
+ /.byebug_history
12
+
13
+ /.idea/
14
+ /.env.*.local
15
+ /.env.local
data/templates/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
4
+ --seed 0
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2
3
+ NewCops: enable
4
+
5
+ inherit_gem:
6
+ foobara-rubocop-rules:
7
+ - rules/*
8
+
9
+ Naming/FileName:
10
+ inherit_mode:
11
+ merge:
12
+ - Exclude
@@ -0,0 +1 @@
1
+ 3.2.2
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.0.1] - <%= Time.now.strftime("%Y-%m-%d") %>
4
+
5
+ - Initial release
data/templates/Gemfile ADDED
@@ -0,0 +1,38 @@
1
+ source "https://rubygems.org"
2
+ ruby File.read("#{__dir__}/.ruby-version")
3
+
4
+ gemspec
5
+
6
+ gem "foobara-dotenv-loader", github: "foobara/dotenv-loader"
7
+
8
+ gem "rake"
9
+
10
+ group :development do
11
+ gem "foobara-command-generator", github: "foobara/command-generator"
12
+ gem "foobara-domain-generator", github: "foobara/domain-generator"
13
+ gem "foobara-empty-ruby-project-generator", github: "foobara/empty-ruby-project-generator"
14
+ gem "foobara-files-generator", github: "foobara/files-generator"
15
+ # TODO: only need this one once everything is published gems and we can use .gemspec for this
16
+ gem "foob"
17
+ gem "foobara-organization-generator", github: "foobara/organization-generator"
18
+ gem "foobara-rubocop-rules"
19
+ gem "foobara-sh-cli-connector", github: "foobara/sh-cli-connector"
20
+ gem "guard-rspec"
21
+ gem "rubocop-rake"
22
+ gem "rubocop-rspec"
23
+ end
24
+
25
+ group :development, :test do
26
+ gem "pry"
27
+ gem "pry-byebug"
28
+ end
29
+
30
+ group :test do
31
+ gem "foobara-spec-helpers"
32
+ gem "rspec"
33
+ gem "rspec-its"
34
+ gem "ruby-prof"
35
+ gem "simplecov"
36
+ gem "vcr"
37
+ gem "webmock"
38
+ end
@@ -0,0 +1,6 @@
1
+ guard :rspec, all_after_pass: true, all_on_start: true, cmd: "bundle exec rspec", failed_mode: :focus do
2
+ watch(%r{^spec/(.+)_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { "spec/" }
4
+ watch(%r{^src/(.+)\.rb$}) { "spec/" }
5
+ watch(%r{^spec/spec_helper.rb$}) { "spec/" }
6
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%= Time.now.strftime("%Y") %> <%= author_names.join(", ") %>
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.
@@ -0,0 +1,49 @@
1
+ # Foobara::EmptyRubyProjectGenerator
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
6
+ into a gem. Put your Ruby code in the file `lib/foobara/empty_ruby_project_generator`. To experiment with that code,
7
+ run `bin/console` for an interactive prompt.
8
+
9
+ ## Installation
10
+
11
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it
12
+ to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with
13
+ instructions to install your gem from git if you don't plan to release to RubyGems.org.
14
+
15
+ Install the gem and add to the application's Gemfile by executing:
16
+
17
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ If bundler is not being used to manage dependencies, install the gem by executing:
20
+
21
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ If using Foobara locally, then run the following (TODO: make this no-longer necessary.)
30
+
31
+ ```bash
32
+ bundle config set disable_local_branch_check true
33
+ ```
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
36
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
39
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
40
+ push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub
45
+ at https://github.com/[USERNAME]/foobara-empty_ruby_project_generator.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rubocop/rake_task"
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
11
+
12
+ task :environment do
13
+ require_relative "boot"
14
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "irb"
5
+ require_relative "../boot"
6
+
7
+ IRB.setup(nil)
8
+
9
+ if ENV.key?("IRB_PROMPT_PREFIX")
10
+ prefix = ENV["IRB_PROMPT_PREFIX"]
11
+ IRB.conf[:PROMPT][:DEFAULT].merge! PROMPT_I: "#{prefix}> ",
12
+ PROMPT_N: "#{prefix}> ",
13
+ PROMPT_S: "#{prefix}%l ",
14
+ PROMPT_C: "#{prefix}* "
15
+ end
16
+
17
+ IRB::Irb.new.run
@@ -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,9 @@
1
+ require "dotenv"
2
+
3
+ require "foobara/load_dotenv"
4
+
5
+ Dotenv.require_keys("FOOBARA_ENV")
6
+
7
+ env = ENV.fetch("FOOBARA_ENV", nil)
8
+
9
+ Foobara::LoadDotenv.run!(env:)
@@ -0,0 +1,24 @@
1
+ first = [
2
+ "remote.rb"
3
+ ]
4
+
5
+ last = %w[
6
+ async.rb
7
+ cron.rb
8
+ ]
9
+
10
+ skip = ["start.rb", "finish.rb", *first, *last]
11
+
12
+ first.each { |f| require_relative f if File.exist?("#{__dir__}/#{f}") }
13
+
14
+ require "<%= project_lib_file_path %>"
15
+
16
+ Dir.entries(__dir__).each do |boot_file|
17
+ next unless boot_file.end_with?(".rb")
18
+ next if skip.include?(boot_file)
19
+ next unless File.exist?("#{__dir__}/#{boot_file}")
20
+
21
+ require_relative boot_file
22
+ end
23
+
24
+ last.each { |f| require_relative f if File.exist?("#{__dir__}/#{f}") }
@@ -0,0 +1,10 @@
1
+ ENV["FOOBARA_ENV"] ||= "development"
2
+
3
+ require "bundler/setup"
4
+
5
+ if ENV["FOOBARA_ENV"] == "development" || ENV["FOOBARA_ENV"] == "test"
6
+ require "pry"
7
+ require "pry-byebug"
8
+ end
9
+
10
+ require_relative "config"
data/templates/boot.rb ADDED
@@ -0,0 +1,2 @@
1
+ require_relative "boot/start"
2
+ require_relative "boot/finish"