early_bird 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 11a2fe291571c28805e17591fb53da82eaa775691bc402299fd8ddac2a501863
4
+ data.tar.gz: f57f2c41713fdf1ead723ed5a51953589040d482994bf080f921abd19b290133
5
+ SHA512:
6
+ metadata.gz: 94f5c6384a03a83f1138b5f688cc36f0c986eb12ef4d72a6edb0b52aaa9ed8cf6211dc11ef4cd1855bc1199d50d87d5eb2f406e693ef25090310e6152d3607ea
7
+ data.tar.gz: 33ea58143db1c5e695588cca8993d0b8d9760700f73c0e2fa68b0bc104bfea72efccf118c042b7f0e12397fbc118ed18f59c7491f2022d51b56eb1af8b5e45b1
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 Carl Dawson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # EarlyBird
2
+
3
+ A very simple Gem to add waitlist functionality to a WIP Rails app.
4
+
5
+ ## Usage
6
+ Follow the installation instructions and you're good to go!
7
+
8
+ ## Installation
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "early_bird"
13
+ ```
14
+
15
+ And then execute:
16
+ ```bash
17
+ $ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+ ```bash
22
+ $ gem install early_bird
23
+ ```
24
+
25
+ Then install the migrations:
26
+ ```bash
27
+ $ bin/rails early_bird:install:migrations
28
+ ```
29
+
30
+ And migrate the database:
31
+ ```bash
32
+ $ bin/rails db:migrate
33
+ ```
34
+
35
+ EarlyBird requires both new and show views:
36
+ ```ruby
37
+ # app/views/early_bird/submissions/new.html.erb
38
+ <%= form_with(model: @submission) do |form| %>
39
+ <%= form.email_field :email, placeholder: "Your email" %>
40
+ <%= form.submit "Join the Waitlist" %>
41
+ <% end %>
42
+ ```
43
+
44
+ ```ruby
45
+ # app/views/early_bird/submissions/show.html.erb
46
+ <p>Thank you! <%= @submission.email %> has been added to the waitlist!</p>
47
+ ```
48
+
49
+ Then mount the engine in your routes.rb file:
50
+ ```ruby
51
+ mount EarlyBird::Engine => "/"
52
+ ```
53
+
54
+ And (optionally) prevent access to the rest of the app while you're building it:
55
+ ```ruby
56
+ class ApplicationController < ActionController::Base
57
+ http_basic_authenticate_with name: "dev", password: "secret"
58
+ end
59
+ ```
60
+
61
+ ## Contributing
62
+ Contributions welcome
63
+
64
+ ## License
65
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/early_bird .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module EarlyBird
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,26 @@
1
+ module EarlyBird
2
+ class SubmissionsController < ApplicationController
3
+ def show
4
+ @submission = Submission.find(params[:id])
5
+ end
6
+
7
+ def new
8
+ @submission = Submission.new
9
+ end
10
+
11
+ def create
12
+ @submission = Submission.find_or_initialize_by(submission_params)
13
+ if @submission.save
14
+ redirect_to @submission
15
+ else
16
+ render 'new', status: :unprocessable_entity
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def submission_params
23
+ params.require(:submission).permit(:email)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ module EarlyBird
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module EarlyBird
2
+ module SubmissionsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module EarlyBird
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module EarlyBird
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module EarlyBird
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module EarlyBird
2
+ class Submission < ApplicationRecord
3
+ validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
4
+ end
5
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ EarlyBird::Engine.routes.draw do
2
+ resources :submissions
3
+ root "submissions#new"
4
+ end
@@ -0,0 +1,9 @@
1
+ class CreateEarlyBirdSubmissions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :early_bird_submissions do |t|
4
+ t.string :email
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module EarlyBird
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace EarlyBird
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module EarlyBird
2
+ VERSION = "0.1.1"
3
+ end
data/lib/early_bird.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "early_bird/version"
2
+ require "early_bird/engine"
3
+
4
+ module EarlyBird
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :early_bird do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: early_bird
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Carl Dawson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.8
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.8
33
+ description:
34
+ email:
35
+ - carldawson@hey.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - MIT-LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - app/assets/config/early_bird_manifest.js
44
+ - app/assets/stylesheets/early_bird/application.css
45
+ - app/controllers/early_bird/application_controller.rb
46
+ - app/controllers/early_bird/submissions_controller.rb
47
+ - app/helpers/early_bird/application_helper.rb
48
+ - app/helpers/early_bird/submissions_helper.rb
49
+ - app/jobs/early_bird/application_job.rb
50
+ - app/mailers/early_bird/application_mailer.rb
51
+ - app/models/early_bird/application_record.rb
52
+ - app/models/early_bird/submission.rb
53
+ - config/routes.rb
54
+ - db/migrate/20230928193732_create_early_bird_submissions.rb
55
+ - lib/early_bird.rb
56
+ - lib/early_bird/engine.rb
57
+ - lib/early_bird/version.rb
58
+ - lib/tasks/early_bird_tasks.rake
59
+ homepage: https://github.com/carldaws/early_bird
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/carldaws/early_bird
64
+ source_code_uri: https://github.com/carldaws/early_bird
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.4.10
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: EarlyBird provides simple waitlist functionality to WIP Rails apps
84
+ test_files: []