Skip to content

Commit 0caa839

Browse files
committed
Apply standard formatting
1 parent 66ffc05 commit 0caa839

File tree

11 files changed

+92
-92
lines changed

11 files changed

+92
-92
lines changed

files/app/controllers/application_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
55
private
66

77
def context
8-
{ current_user: current_user }
8+
{current_user: current_user}
99
end
1010

1111
def current_user

files/bin/sample-data

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env ruby
2-
require_relative '../config/environment'
2+
require_relative "../config/environment"
33

44
if Rails.env != "development"
55
puts "Rails environment is #{Rails.env}; not gonna truncate THAT!"

files/config/initializers/cors.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
Rails.application.config.middleware.insert_before 0, Rack::Cors do
99
allow do
10-
origins '*'
10+
origins "*"
1111

12-
resource '*',
12+
resource "*",
1313
headers: :any,
1414
methods: [:get, :post, :put, :patch, :delete, :options, :head]
1515
end

files/config/initializers/doorkeeper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if user&.authenticate(params[:password])
1313
user
1414
else
15-
raise Doorkeeper::Errors::DoorkeeperError.new('invalid_user_or_password')
15+
raise Doorkeeper::Errors::DoorkeeperError.new("invalid_user_or_password")
1616
end
1717
end
1818

files/db/seeds.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
User.create!(email: '[email protected]', password: 'password')
1+
User.create!(email: "[email protected]", password: "password")

files/spec/factories/access_token.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FactoryBot.define do
2-
factory :access_token, class: 'Doorkeeper::AccessToken' do
2+
factory :access_token, class: "Doorkeeper::AccessToken" do
33
resource_owner_id { FactoryBot.create(:user).id }
44
end
55
end

files/spec/factories/user.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FactoryBot.define do
22
factory :user do
33
sequence(:email) { |n| "example#{n}@example.com" }
4-
password { 'password' }
4+
password { "password" }
55
end
66
end

files/spec/rails_helper.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This file is copied to spec/ when you run 'rails generate rspec:install'
2-
require 'spec_helper'
3-
ENV['RAILS_ENV'] ||= 'test'
4-
require File.expand_path('../../config/environment', __FILE__)
2+
require "spec_helper"
3+
ENV["RAILS_ENV"] ||= "test"
4+
require File.expand_path("../../config/environment", __FILE__)
55
# Prevent database truncation if the environment is production
66
abort("The Rails environment is running in production mode!") if Rails.env.production?
7-
require 'rspec/rails'
7+
require "rspec/rails"
88
# Add additional requires below this line. Rails is not loaded until this point!
99

1010
# Requires supporting ruby files with custom matchers and macros, etc, in
@@ -20,7 +20,7 @@
2020
# directory. Alternatively, in the individual `*_spec.rb` files, manually
2121
# require only the support files necessary.
2222
#
23-
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
23+
Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f }
2424

2525
# Checks for pending migrations and applies them before tests are run.
2626
# If you are not using ActiveRecord, you can remove these lines.

files/spec/requests/register_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
require "rails_helper"
22

3-
RSpec.describe 'registering', type: :request do
3+
RSpec.describe "registering", type: :request do
44
let(:headers) {
55
{
6-
'Content-Type' => 'application/vnd.api+json',
6+
"Content-Type" => "application/vnd.api+json"
77
}
88
}
99

10-
it 'allows creating a user' do
11-
12-
password = 'mypassword'
10+
it "allows creating a user" do
11+
12+
password = "mypassword"
1313

1414
params = {
1515
data: {
16-
type: 'users',
16+
type: "users",
1717
attributes: {
1818
email: email,
19-
password: password,
20-
},
21-
},
19+
password: password
20+
}
21+
}
2222
}
2323

24-
post '/users', params: params.to_json, headers: headers
24+
post "/users", params: params.to_json, headers: headers
2525

2626
expect(response.status).to eq(201)
2727
expect(User.count).to eq(1)

files/spec/support/with_a_logged_in_user.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
end
66
let(:headers) do
77
{
8-
'Authorization' => "Bearer #{token}",
9-
'Content-Type' => 'application/vnd.api+json',
8+
"Authorization" => "Bearer #{token}",
9+
"Content-Type" => "application/vnd.api+json"
1010
}
1111
end
1212
end

template.rb

+67-67
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
def commit(message)
2-
git add: '.'
2+
git add: "."
33
git commit: "-m '#{message}'"
44
end
55

6-
def copy_file(file_name, directory = '.')
6+
def copy_file(file_name, directory = ".")
77
inside(directory) do
88
puts "CURRENT PATH: #{File.dirname(__FILE__)}"
99
file_path = File.expand_path("files/#{file_name}", File.dirname(__FILE__))
@@ -16,111 +16,111 @@ def remove_file(file_name)
1616
end
1717

1818
git :init
19-
commit 'Create Rails app'
19+
commit "Create Rails app"
2020

21-
copy_file '../files/README.md'
21+
copy_file "../files/README.md"
2222
run %(sed -i '' "s/\\[APP NAME\\]/#{app_path.titleize}/" README.md)
23-
commit 'Use markdown readme'
23+
commit "Use markdown readme"
2424

2525
run "sed -i '' '/^.*#/ d' Gemfile"
26-
commit 'Remove Gemfile comments'
26+
commit "Remove Gemfile comments"
2727

2828
run "sed -i '' '/tzinfo-data/ d' Gemfile"
29-
commit 'Remove unused gems'
29+
commit "Remove unused gems"
3030

31-
gem 'rack-cors'
32-
gem 'jsonapi-resources'
33-
gem 'bcrypt'
34-
gem 'doorkeeper'
31+
gem "rack-cors"
32+
gem "jsonapi-resources"
33+
gem "bcrypt"
34+
gem "doorkeeper"
3535

36-
commit 'Add gems for all environments'
36+
commit "Add gems for all environments"
3737

3838
gem_group :development do
39-
gem 'bullet'
40-
gem 'dotenv-rails'
39+
gem "bullet"
40+
gem "dotenv-rails"
4141
end
4242

4343
gem_group :development, :test do
44-
gem 'rspec-rails'
45-
gem 'coderay'
46-
gem 'standard'
44+
gem "rspec-rails"
45+
gem "coderay"
46+
gem "standard"
4747
end
4848

49-
commit 'Add development gems'
49+
commit "Add development gems"
5050

5151
gem_group :test do
52-
gem 'factory_bot_rails'
53-
gem 'rspec_junit_formatter'
52+
gem "factory_bot_rails"
53+
gem "rspec_junit_formatter"
5454
end
5555

56-
commit 'Add test gems'
56+
commit "Add test gems"
5757

5858
gem_group :production do
59-
gem 'rack-attack'
59+
gem "rack-attack"
6060
end
61-
commit 'Add production gems'
61+
commit "Add production gems"
6262

63-
run 'bundle install'
64-
commit 'Bundle gems'
63+
run "bundle install"
64+
commit "Bundle gems"
6565

6666
# https://github.com/doorkeeper-gem/doorkeeper/issues/1577
67-
copy_file '../files/config/initializers/doorkeeper.rb', 'config/initializers'
68-
run 'rails generate doorkeeper:install -f'
69-
run 'rails generate doorkeeper:migration'
67+
copy_file "../files/config/initializers/doorkeeper.rb", "config/initializers"
68+
run "rails generate doorkeeper:install -f"
69+
run "rails generate doorkeeper:migration"
7070

7171
# TODO: match variable number of spaces
7272
run "sed -i '' 's/t.references :application, null: false/t.references :application/' db/migrate/*_create_doorkeeper_tables.rb"
7373

74-
copy_file '../files/config/initializers/doorkeeper.rb', 'config/initializers'
75-
copy_file '../files/config/locales/doorkeeper.en.yml', 'config/locales'
76-
copy_file '../files/spec/factories/access_token.rb', 'spec/factories'
77-
commit 'Configure doorkeeper'
74+
copy_file "../files/config/initializers/doorkeeper.rb", "config/initializers"
75+
copy_file "../files/config/locales/doorkeeper.en.yml", "config/locales"
76+
copy_file "../files/spec/factories/access_token.rb", "spec/factories"
77+
commit "Configure doorkeeper"
7878

79-
run 'bundle binstubs bundler --force'
80-
run 'bundle binstubs rspec-core'
81-
run 'rails generate rspec:install'
82-
commit 'Set up RSpec'
79+
run "bundle binstubs bundler --force"
80+
run "bundle binstubs rspec-core"
81+
run "rails generate rspec:install"
82+
commit "Set up RSpec"
8383

84-
run 'rails generate model user email:string:uniq password_digest:string'
85-
copy_file '../files/db/seeds.rb', 'db'
86-
copy_file '../files/app/models/user.rb', 'app/models'
87-
copy_file '../files/spec/factories/user.rb', 'spec/factories'
88-
remove_file 'spec/models/user_spec.rb'
89-
commit 'Add user model'
84+
run "rails generate model user email:string:uniq password_digest:string"
85+
copy_file "../files/db/seeds.rb", "db"
86+
copy_file "../files/app/models/user.rb", "app/models"
87+
copy_file "../files/spec/factories/user.rb", "spec/factories"
88+
remove_file "spec/models/user_spec.rb"
89+
commit "Add user model"
9090

91-
copy_file '../files/app/controllers/application_controller.rb', 'app/controllers'
92-
copy_file '../files/app/resources/application_resource.rb', 'app/resources'
93-
commit 'Expose Doorkeeper user to JR'
91+
copy_file "../files/app/controllers/application_controller.rb", "app/controllers"
92+
copy_file "../files/app/resources/application_resource.rb", "app/resources"
93+
commit "Expose Doorkeeper user to JR"
9494

95-
copy_file '../files/app/controllers/users_controller.rb', 'app/controllers'
96-
copy_file '../files/app/resources/user_resource.rb', 'app/resources'
97-
copy_file '../files/config/routes.rb', 'config'
98-
copy_file '../files/spec/requests/register_spec.rb', 'spec/requests'
99-
commit 'Expose user create endpoint'
95+
copy_file "../files/app/controllers/users_controller.rb", "app/controllers"
96+
copy_file "../files/app/resources/user_resource.rb", "app/resources"
97+
copy_file "../files/config/routes.rb", "config"
98+
copy_file "../files/spec/requests/register_spec.rb", "spec/requests"
99+
commit "Expose user create endpoint"
100100

101-
copy_file '../files/spec/rails_helper.rb', 'spec'
102-
copy_file '../files/spec/support/with_a_logged_in_user.rb', 'spec/support'
103-
commit 'Add shared context for setting up a logged in user'
101+
copy_file "../files/spec/rails_helper.rb", "spec"
102+
copy_file "../files/spec/support/with_a_logged_in_user.rb", "spec/support"
103+
commit "Add shared context for setting up a logged in user"
104104

105-
copy_file '../files/config/initializers/cors.rb', 'config/initializers'
106-
commit 'Configure CORS'
105+
copy_file "../files/config/initializers/cors.rb", "config/initializers"
106+
commit "Configure CORS"
107107

108-
copy_file '../files/bin/sample-data', 'bin'
109-
commit 'Add sample data script'
108+
copy_file "../files/bin/sample-data", "bin"
109+
commit "Add sample data script"
110110

111-
copy_file '../files/.circleci/config.yml', '.circleci'
112-
commit 'Configure CircleCI'
111+
copy_file "../files/.circleci/config.yml", ".circleci"
112+
commit "Configure CircleCI"
113113

114-
run 'rails db:create'
115-
run 'rails db:migrate'
116-
run 'rails db:seed'
117-
commit 'Set up database'
114+
run "rails db:create"
115+
run "rails db:migrate"
116+
run "rails db:seed"
117+
commit "Set up database"
118118

119-
copy_file '../files/.irbrc', '.irbrc'
120-
commit 'Disable console autocomplete'
119+
copy_file "../files/.irbrc", ".irbrc"
120+
commit "Disable console autocomplete"
121121

122-
run 'bundle exec standardrb --fix'
123-
commit 'Format to Standard'
122+
run "bundle exec standardrb --fix"
123+
commit "Format to Standard"
124124

125125
# TODO: clean up gem file
126126
# TODO: Ruby version in gemfile?

0 commit comments

Comments
 (0)