diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fd382e5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: RSpec and Rubocop + +on: + push: + branches: + - main + + pull_request: + +jobs: + ci: + runs-on: ubuntu-latest + name: RSpec and Rubocop + timeout-minutes: 3 + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.ruby_version }} + bundler-cache: true + - name: Run rspec + run: bundle exec rspec + - name: Run rubocop + run: bundle exec rubocop +# - name: Upload coverage directory +# if: always() +# uses: actions/upload-artifact@v2 +# with: +# name: coverage-report +# path: coverage/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81aeae2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ + +/.rspec_status +/.byebug_history + +/.idea/ +/.env.*.local +/.env.local diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..f2267bf --- /dev/null +++ b/.rspec @@ -0,0 +1,4 @@ +--format progress +--color +--require spec_helper +--seed 0 diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..fdde201 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,12 @@ +AllCops: + TargetRubyVersion: 3.2 + NewCops: enable + +inherit_gem: + foobara-rubocop-rules: + - rules/* + +Naming/FileName: + inherit_mode: + merge: + - Exclude diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..be94e6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..96be47d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## [Unreleased] + +## [0.0.1] - 2024-10-18 + +- Initial release diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ebbee30 --- /dev/null +++ b/Gemfile @@ -0,0 +1,31 @@ +source "https://rubygems.org" +ruby File.read("#{__dir__}/.ruby-version") + +gemspec + +gem "foobara-dotenv-loader" + +gem "rake" + +group :development do + gem "foob" + gem "foobara-rubocop-rules" + gem "guard-rspec" + gem "rubocop-rake" + gem "rubocop-rspec" +end + +group :development, :test do + gem "pry" + gem "pry-byebug" +end + +group :test do + gem "foobara-spec-helpers" + gem "rspec" + gem "rspec-its" + gem "ruby-prof" + gem "simplecov" + gem "vcr" + gem "webmock" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..cca0523 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,248 @@ +PATH + remote: . + specs: + foobara-http-command-connector (0.0.1) + foobara + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + byebug (11.1.3) + coderay (1.1.3) + crack (1.0.0) + bigdecimal + rexml + diff-lcs (1.5.1) + docile (1.4.1) + dotenv (3.1.4) + ffi (1.17.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + foob (0.0.6) + foobara + foobara-autocrud-generator + foobara-command-generator + foobara-domain-generator + foobara-domain-mapper-generator + foobara-empty-ruby-project-generator + foobara-empty-typescript-react-project-generator + foobara-organization-generator + foobara-rack-connector-generator + foobara-redis-crud-driver-generator + foobara-remote-imports-generator + foobara-resque-connector-generator + foobara-resque-scheduler-connector-generator + foobara-sh-cli-connector + foobara-sh-cli-connector-generator + foobara-type-generator + foobara-typescript-react-command-form-generator + foobara-typescript-remote-command-generator + foobara (0.0.9) + foobara-util + foobara-autocrud-generator (0.0.1) + foobara + foobara-files-generator + foobara-command-generator (0.0.2) + foobara + foobara-files-generator + foobara-domain-generator (0.0.2) + foobara + foobara-files-generator + foobara-domain-mapper-generator (0.0.3) + foobara + foobara-files-generator + foobara-dotenv-loader (0.0.1) + dotenv + foobara-empty-ruby-project-generator (0.0.5) + foobara + foobara-files-generator + foobara-empty-typescript-react-project-generator (0.0.3) + foobara + foobara-files-generator + foobara-files-generator (0.0.3) + foobara + foobara-organization-generator (0.0.1) + foobara + foobara-files-generator + foobara-rack-connector-generator (0.0.6) + foobara + foobara-files-generator + foobara-redis-crud-driver-generator (0.0.2) + foobara + foobara-files-generator + foobara-remote-imports-generator (0.0.2) + foobara + foobara-files-generator + foobara-resque-connector-generator (0.0.1) + foobara + foobara-files-generator + foobara-resque-scheduler-connector-generator (0.0.1) + foobara + foobara-files-generator + foobara-rubocop-rules (0.0.4) + rubocop + rubocop-rspec + foobara-sh-cli-connector (0.0.4) + foobara + foobara-sh-cli-connector-generator (0.0.2) + foobara + foobara-files-generator + foobara-spec-helpers (0.0.3) + foobara-util + foobara-type-generator (0.0.3) + foobara + foobara-files-generator + foobara-typescript-react-command-form-generator (0.0.2) + foobara + foobara-files-generator + foobara-typescript-remote-command-generator + foobara-typescript-remote-command-generator (0.0.6) + foobara + foobara-files-generator + foobara-util (0.0.6) + formatador (1.1.0) + guard (2.18.1) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.13.0) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) + hashdiff (1.1.1) + json (2.7.2) + language_server-protocol (3.17.0.3) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + lumberjack (1.2.10) + method_source (1.1.0) + nenv (0.3.0) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + public_suffix (6.0.1) + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + regexp_parser (2.9.2) + rexml (3.3.8) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.67.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (3.1.0) + rubocop (~> 1.61) + ruby-prof (1.7.0) + ruby-progressbar (1.13.0) + shellany (0.0.1) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + thor (1.3.2) + unicode-display_width (2.6.0) + vcr (6.3.1) + base64 + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + ruby + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + foob + foobara-dotenv-loader + foobara-http-command-connector! + foobara-rubocop-rules + foobara-spec-helpers + guard-rspec + pry + pry-byebug + rake + rspec + rspec-its + rubocop-rake + rubocop-rspec + ruby-prof + simplecov + vcr + webmock + +RUBY VERSION + ruby 3.2.2p53 + +BUNDLED WITH + 2.5.22 diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..22dc05a --- /dev/null +++ b/Guardfile @@ -0,0 +1,6 @@ +guard :rspec, all_after_pass: true, all_on_start: true, cmd: "bundle exec rspec", failed_mode: :focus do + watch(%r{^spec/(.+)_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { "spec/" } + watch(%r{^src/(.+)\.rb$}) { "spec/" } + watch(%r{^spec/spec_helper.rb$}) { "spec/" } +end diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5c81c96 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 Miles Georgi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..689b093 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Foobara::EmptyRubyProjectGenerator + +TODO: Delete this and the text below, and describe your gem + +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library +into a gem. Put your Ruby code in the file `lib/foobara/empty_ruby_project_generator`. To experiment with that code, +run `bin/console` for an interactive prompt. + +## Installation + +TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it +to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with +instructions to install your gem from git if you don't plan to release to RubyGems.org. + +Install the gem and add to the application's Gemfile by executing: + + $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG + +If bundler is not being used to manage dependencies, install the gem by executing: + + $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG + +## Usage + +TODO: Write usage instructions here + +## Development + +If using Foobara locally, then run the following (TODO: make this no-longer necessary.) + +```bash +bundle config set disable_local_branch_check true +``` + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can +also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the +version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, +push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub +at https://github.com/[USERNAME]/foobara-empty_ruby_project_generator. + +## License + +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..6468697 --- /dev/null +++ b/Rakefile @@ -0,0 +1,14 @@ +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +require "rubocop/rake_task" + +RuboCop::RakeTask.new + +task default: %i[spec rubocop] + +task :environment do + require_relative "boot" +end diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..4a44681 --- /dev/null +++ b/bin/console @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "irb" +require_relative "../boot" + +IRB.setup(nil) + +if ENV.key?("IRB_PROMPT_PREFIX") + prefix = ENV["IRB_PROMPT_PREFIX"] + IRB.conf[:PROMPT][:DEFAULT].merge! PROMPT_I: "#{prefix}> ", + PROMPT_N: "#{prefix}> ", + PROMPT_S: "#{prefix}%l ", + PROMPT_C: "#{prefix}* " +end + +IRB::Irb.new.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/boot.rb b/boot.rb new file mode 100644 index 0000000..d22ad00 --- /dev/null +++ b/boot.rb @@ -0,0 +1,2 @@ +require_relative "boot/start" +require_relative "boot/finish" diff --git a/boot/config.rb b/boot/config.rb new file mode 100644 index 0000000..db2b772 --- /dev/null +++ b/boot/config.rb @@ -0,0 +1,9 @@ +require "dotenv" + +require "foobara/load_dotenv" + +Dotenv.require_keys("FOOBARA_ENV") + +env = ENV.fetch("FOOBARA_ENV", nil) + +Foobara::LoadDotenv.run!(env:) diff --git a/boot/finish.rb b/boot/finish.rb new file mode 100644 index 0000000..f229a1b --- /dev/null +++ b/boot/finish.rb @@ -0,0 +1,24 @@ +first = [ + "remote.rb" +] + +last = %w[ + async.rb + cron.rb +] + +skip = ["start.rb", "finish.rb", *first, *last] + +first.each { |f| require_relative f if File.exist?("#{__dir__}/#{f}") } + +require "foobara/http_command_connector" + +Dir.entries(__dir__).each do |boot_file| + next unless boot_file.end_with?(".rb") + next if skip.include?(boot_file) + next unless File.exist?("#{__dir__}/#{boot_file}") + + require_relative boot_file +end + +last.each { |f| require_relative f if File.exist?("#{__dir__}/#{f}") } diff --git a/boot/start.rb b/boot/start.rb new file mode 100644 index 0000000..1a04366 --- /dev/null +++ b/boot/start.rb @@ -0,0 +1,10 @@ +ENV["FOOBARA_ENV"] ||= "development" + +require "bundler/setup" + +if ENV["FOOBARA_ENV"] == "development" || ENV["FOOBARA_ENV"] == "test" + require "pry" + require "pry-byebug" +end + +require_relative "config" diff --git a/foobara-http-command-connector.gemspec b/foobara-http-command-connector.gemspec new file mode 100644 index 0000000..69ddb88 --- /dev/null +++ b/foobara-http-command-connector.gemspec @@ -0,0 +1,30 @@ +require_relative "src/version" + +Gem::Specification.new do |spec| + spec.name = "foobara-http-command-connector" + spec.version = Foobara::HttpCommandConnector::VERSION + spec.authors = ["Miles Georgi"] + spec.email = ["azimux@gmail.com"] + + spec.summary = "No description. Add one." + spec.homepage = "https://github.com/foobara/http-command-connector" + spec.license = "None specified yet" + spec.required_ruby_version = ">= #{File.read("#{__dir__}/.ruby-version")}" + + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = spec.homepage + spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md" + + spec.files = Dir[ + "lib/**/*", + "src/**/*", + "LICENSE*.txt", + "README.md", + "CHANGELOG.md" + ] + + spec.add_dependency "foobara" + + spec.require_paths = ["lib"] + spec.metadata["rubygems_mfa_required"] = "true" +end diff --git a/lib/foobara/http_command_connector.rb b/lib/foobara/http_command_connector.rb new file mode 100644 index 0000000..a429481 --- /dev/null +++ b/lib/foobara/http_command_connector.rb @@ -0,0 +1,3 @@ +require "foobara/all" + +Foobara::Util.require_directory "#{__dir__}/../../src" diff --git a/spec/foobara/http_command_connector_spec.rb b/spec/foobara/http_command_connector_spec.rb new file mode 100644 index 0000000..fb6ad90 --- /dev/null +++ b/spec/foobara/http_command_connector_spec.rb @@ -0,0 +1,5 @@ +RSpec.describe Foobara::HttpCommandConnector do + it "has a version number" do + expect(Foobara::HttpCommandConnector::VERSION).to_not be_nil + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..6ae31a4 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,24 @@ +ENV["FOOBARA_ENV"] = "test" + +require "bundler/setup" + +require "pry" +require "pry-byebug" +require "rspec/its" + +require_relative "support/simplecov" +require_relative "../boot/start" + +RSpec.configure do |config| + config.filter_run_when_matching :focus + config.example_status_persistence_file_path = ".rspec_status" + config.disable_monkey_patching! + config.order = :defined + config.expect_with(:rspec) { |c| c.syntax = :expect } + config.raise_errors_for_deprecations! +end + +Dir["#{__dir__}/support/**/*.rb"].each { |f| require f } + +require "foobara/spec_helpers/all" +require_relative "../boot/finish" diff --git a/spec/support/rubyprof.rb b/spec/support/rubyprof.rb new file mode 100644 index 0000000..1bdc2d1 --- /dev/null +++ b/spec/support/rubyprof.rb @@ -0,0 +1,14 @@ +RSpec.configure do |config| + # TODO: move this to foobara-spec-helpers project + config.around(:each, :profile) do |example| + require "ruby-prof" + RubyProf.start + example.run + result = RubyProf.stop + + printer = RubyProf::GraphHtmlPrinter.new(result) + File.open("tmp/profile-out.html", "w+") do |file| + printer.print(file) + end + end +end diff --git a/spec/support/simplecov.rb b/spec/support/simplecov.rb new file mode 100644 index 0000000..50577cf --- /dev/null +++ b/spec/support/simplecov.rb @@ -0,0 +1,9 @@ +require "simplecov" + +SimpleCov.start do + add_filter "spec/support" + # enable_coverage :branch + minimum_coverage line: 100 + # TODO: enable this? worth it to get to 100% branch coverage? + # minimum_coverage line: 100, branch: 100 +end diff --git a/spec/support/term_trap.rb b/spec/support/term_trap.rb new file mode 100644 index 0000000..b805d7e --- /dev/null +++ b/spec/support/term_trap.rb @@ -0,0 +1,6 @@ +# Convenient whenever running into an infinite loop +Signal.trap("TERM") do + puts "SIGTERM received, printing backtrace:" + puts caller.join("\n") + exit +end diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb new file mode 100644 index 0000000..6caadf5 --- /dev/null +++ b/spec/support/vcr.rb @@ -0,0 +1,8 @@ +require "vcr" + +VCR.configure do |config| + # config.filter_sensitive_data("") { ENV.fetch("SOME_API_KEY", nil) } + config.cassette_library_dir = "spec/vcr_cassettes" + config.hook_into :webmock + config.configure_rspec_metadata! +end diff --git a/src/version.rb b/src/version.rb new file mode 100644 index 0000000..36eb147 --- /dev/null +++ b/src/version.rb @@ -0,0 +1,5 @@ +module Foobara + module HttpCommandConnector + VERSION = "0.0.1".freeze + end +end