diff options
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | Rakefile | 27 | ||||
-rw-r--r-- | actionmailbox.gemspec | 24 | ||||
-rw-r--r-- | lib/action_mailbox.rb | 7 | ||||
-rw-r--r-- | lib/action_mailbox/base.rb | 2 | ||||
-rw-r--r-- | lib/action_mailbox/engine.rb | 14 | ||||
-rw-r--r-- | lib/action_mailbox/version.rb | 3 | ||||
-rw-r--r-- | lib/tasks/action_mailbox.rake | 30 | ||||
-rw-r--r-- | test/test_helper.rb | 25 |
11 files changed, 160 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..9b78acc762 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" +git_source(:github) { |repo_path| "https://github.com/#{repo_path}.git" } + +gemspec diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..4a5fe6361d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Basecamp, LLC + +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 0000000000..b92e467644 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Action Mailbox + +📬
\ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..a2fd477252 --- /dev/null +++ b/Rakefile @@ -0,0 +1,27 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'Action Mailbox' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.md') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +require 'bundler/gem_tasks' + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + +task default: :test diff --git a/actionmailbox.gemspec b/actionmailbox.gemspec new file mode 100644 index 0000000000..1fdfff7b00 --- /dev/null +++ b/actionmailbox.gemspec @@ -0,0 +1,24 @@ +$:.push File.expand_path("lib", __dir__) + +# Maintain your gem's version: +require "action_mailbox/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "actionmailbox" + s.version = ActionText::VERSION + s.authors = ["Jeremy Daer", "David Heinemeier Hansson"] + s.email = ["jeremy@basecamp.com", "david@loudthinking.com"] + s.summary = "Receive and process incoming emails in Rails" + s.homepage = "https://github.com/basecamp/actionmailbox" + s.license = "MIT" + + s.required_ruby_version = ">= 2.5.0" + + s.add_dependency "rails", ">= 5.2.0" + + s.add_development_dependency "bundler", "~> 1.15" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- test/*`.split("\n") +end diff --git a/lib/action_mailbox.rb b/lib/action_mailbox.rb new file mode 100644 index 0000000000..c4ed71d5cc --- /dev/null +++ b/lib/action_mailbox.rb @@ -0,0 +1,7 @@ +require "action_mailbox/engine" + +module ActionMailbox + extend ActiveSupport::Autoload + + autoload :Base +end diff --git a/lib/action_mailbox/base.rb b/lib/action_mailbox/base.rb new file mode 100644 index 0000000000..75098875eb --- /dev/null +++ b/lib/action_mailbox/base.rb @@ -0,0 +1,2 @@ +class ActionMailbox::Base +end diff --git a/lib/action_mailbox/engine.rb b/lib/action_mailbox/engine.rb new file mode 100644 index 0000000000..92852a0fa3 --- /dev/null +++ b/lib/action_mailbox/engine.rb @@ -0,0 +1,14 @@ +require "rails/engine" + +module ActionMailbox + class Engine < Rails::Engine + isolate_namespace ActionMailbox + config.eager_load_namespaces << ActionMailbox + + initializer "action_mailbox.config" do + config.after_initialize do |app| + # Configure + end + end + end +end diff --git a/lib/action_mailbox/version.rb b/lib/action_mailbox/version.rb new file mode 100644 index 0000000000..23c615dbbd --- /dev/null +++ b/lib/action_mailbox/version.rb @@ -0,0 +1,3 @@ +module ActionMailbox + VERSION = '0.1.0' +end diff --git a/lib/tasks/action_mailbox.rake b/lib/tasks/action_mailbox.rake new file mode 100644 index 0000000000..58dd59d9eb --- /dev/null +++ b/lib/tasks/action_mailbox.rake @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +namespace :action_mailbox do + # Prevent migration installation task from showing up twice. + Rake::Task["install:migrations"].clear_comments + + desc "Copy over the migration and fixtures" + task install: %w( environment active_storage:install copy_migration copy_fixtures ) + + task :copy_migration do + if Rake::Task.task_defined?("action_mailbox:install:migrations") + Rake::Task["action_mailbox:install:migrations"].invoke + else + Rake::Task["app:action_mailbox:install:migrations"].invoke + end + end + + FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__) + FIXTURE_APP_DIR_PATH = Rails.root.join("test/fixtures/action_mailbox") + FIXTURE_APP_PATH = FIXTURE_APP_DIR_PATH.join("inbound_emails.yml") + + task :copy_fixtures do + if File.exist?(FIXTURE_APP_PATH) + puts "Won't copy Action Mailbox fixtures as it already exists" + else + FileUtils.mkdir FIXTURE_APP_DIR_PATH + FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000000..81d14de111 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,25 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require_relative "../test/dummy/config/environment" +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +require "rails/test_help" + +require "rails/test_unit/reporter" +Rails::TestUnitReporter.executable = 'bin/test' + +# Load fixtures from the engine +if ActiveSupport::TestCase.respond_to?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) + ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path + ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" + ActiveSupport::TestCase.fixtures :all +end + +class ActiveSupport::TestCase + private + def create_file_blob(filename:, content_type:, metadata: nil) + ActiveStorage::Blob.create_after_upload! io: file_fixture(filename).open, + filename: filename, content_type: content_type, metadata: metadata + end +end |