Skip to content

Commit 0e640f9

Browse files
authored
Merge pull request #56 from blocknotes/switch-to-double-quotes-for-strings
Switch to double quotes for strings
2 parents 4dad7be + a8aa6bf commit 0e640f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+412
-408
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ Style/ExplicitBlockArgument:
3333
Style/GuardClause:
3434
Exclude:
3535
- lib/tiny_admin/router.rb
36+
37+
Style/StringLiterals:
38+
Enabled: true
39+
EnforcedStyle: double_quotes

Gemfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
source "https://rubygems.org"
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
gemspec
77

88
group :development, :test do
9-
gem 'rails', '~> 7.1'
9+
gem "rails", "~> 7.1"
1010

11-
gem 'sqlite3', '< 2.0'
12-
gem 'tilt'
13-
gem 'warden'
14-
gem 'webrick'
11+
gem "sqlite3", "< 2.0"
12+
gem "tilt"
13+
gem "warden"
14+
gem "webrick"
1515

16-
gem 'rbs'
16+
gem "rbs"
1717

1818
# Testing
19-
gem 'capybara'
20-
gem 'capybara-screenshot'
21-
gem 'rspec-rails'
22-
gem 'simplecov', require: false
19+
gem "capybara"
20+
gem "capybara-screenshot"
21+
gem "rspec-rails"
22+
gem "simplecov", require: false
2323

2424
# Linters
2525
# gem 'fasterer'
26-
gem 'rubocop'
27-
gem 'rubocop-packaging'
28-
gem 'rubocop-performance'
29-
gem 'rubocop-rspec'
26+
gem "rubocop"
27+
gem "rubocop-packaging"
28+
gem "rubocop-performance"
29+
gem "rubocop-rspec"
3030

3131
# Tools
3232
# gem 'overcommit', '~> 0.59'
33-
gem 'pry-rails'
33+
gem "pry-rails"
3434
end

lib/tiny_admin.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

3-
require 'phlex'
4-
require 'roda'
5-
require 'zeitwerk'
3+
require "phlex"
4+
require "roda"
5+
require "zeitwerk"
66

7-
require 'forwardable'
8-
require 'singleton'
9-
require 'yaml'
7+
require "forwardable"
8+
require "singleton"
9+
require "yaml"
1010

1111
loader = Zeitwerk::Loader.for_gem
1212
loader.setup
@@ -25,10 +25,10 @@ def configure_from_file(file)
2525
end
2626

2727
def route_for(section, reference: nil, action: nil, query: nil)
28-
root_path = settings.root_path == '/' ? nil : settings.root_path
28+
root_path = settings.root_path == "/" ? nil : settings.root_path
2929
route = [root_path, section, reference, action].compact.join("/")
3030
route << "?#{query}" if query
31-
route[0] == '/' ? route : route.prepend('/')
31+
route[0] == "/" ? route : route.prepend("/")
3232
end
3333

3434
def settings

lib/tiny_admin/actions/index.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def evaluate_options(options)
4545
@params = context.request.params
4646
@repository = context.repository
4747
@pagination = options[:pagination] || 10
48-
@current_page = (params['p'] || 1).to_i
49-
@query_string = params_to_s(params.except('p'))
48+
@current_page = (params["p"] || 1).to_i
49+
@query_string = params_to_s(params.except("p"))
5050
end
5151

5252
def prepare_filters(fields)
5353
filters = (options[:filters] || []).map { _1.is_a?(Hash) ? _1 : { field: _1 } }
5454
filters = filters.to_h { |filter| [filter[:field], filter] }
55-
values = params['q'] || {}
55+
values = params["q"] || {}
5656
fields.each_with_object({}) do |(name, field), result|
5757
result[field] = { value: values[name], filter: filters[name] } if filters.key?(name)
5858
end

lib/tiny_admin/authentication.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
module TinyAdmin
44
class Authentication < BasicApp
55
route do |r|
6-
r.get 'unauthenticated' do
6+
r.get "unauthenticated" do
77
if current_user
88
r.redirect TinyAdmin.settings.root_path
99
else
1010
render_login
1111
end
1212
end
1313

14-
r.post 'unauthenticated' do
14+
r.post "unauthenticated" do
1515
warning = TinyAdmin.settings.helper_class.label_for(
16-
'Failed to authenticate',
17-
options: ['authentication.unauthenticated']
16+
"Failed to authenticate",
17+
options: ["authentication.unauthenticated"]
1818
)
1919
render_login(warnings: [warning])
2020
end
2121

22-
r.get 'logout' do
22+
r.get "logout" do
2323
logout_user
2424
r.redirect TinyAdmin.settings.root_path
2525
end
@@ -33,9 +33,9 @@ def render_login(notices: nil, warnings: nil, errors: nil)
3333

3434
page = prepare_page(login, options: %i[no_menu compact_layout])
3535
page.messages = {
36-
notices: notices || flash['notices'],
37-
warnings: warnings || flash['warnings'],
38-
errors: errors || flash['errors']
36+
notices: notices || flash["notices"],
37+
warnings: warnings || flash["warnings"],
38+
errors: errors || flash["errors"]
3939
}
4040
render(inline: page.call)
4141
end

lib/tiny_admin/basic_app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def authentication_plugin
1414

1515
plugin :flash
1616
plugin :not_found
17-
plugin :render, engine: 'html'
17+
plugin :render, engine: "html"
1818
plugin :sessions, secret: SecureRandom.hex(64)
1919

2020
plugin authentication_plugin, TinyAdmin.settings.authentication

lib/tiny_admin/field.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def initialize(name:, title:, type:, options: {})
1212
end
1313

1414
def apply_call_option(target)
15-
messages = (options[:call] || '').split(',').map(&:strip)
15+
messages = (options[:call] || "").split(",").map(&:strip)
1616
messages.inject(target) { |result, msg| result&.send(msg) } if messages.any?
1717
end
1818

1919
def translate_value(value)
2020
if options && options[:method]
21-
method, *args = options[:method].split(',').map(&:strip)
21+
method, *args = options[:method].split(",").map(&:strip)
2222
if options[:converter]
2323
Object.const_get(options[:converter]).send(method, value, options: args || [])
2424
else
@@ -32,7 +32,7 @@ def translate_value(value)
3232
class << self
3333
def create_field(name:, title: nil, type: nil, options: {})
3434
field_name = name.to_s
35-
field_title = field_name.respond_to?(:humanize) ? field_name.humanize : field_name.tr('_', ' ').capitalize
35+
field_title = field_name.respond_to?(:humanize) ? field_name.humanize : field_name.tr("_", " ").capitalize
3636
new(name: field_name, title: title || field_title, type: type || :string, options: options || {})
3737
end
3838
end

lib/tiny_admin/plugins/active_record_repository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def list(page: 1, limit: 10, sort: nil, filters: nil)
5454
def apply_filters(query, filters)
5555
filters.each do |field, filter|
5656
value = filter&.dig(:value)
57-
next if value.nil? || value == ''
57+
next if value.nil? || value == ""
5858

5959
query =
6060
case field.type

lib/tiny_admin/plugins/no_auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def authenticate_user! # rubocop:disable Naming/PredicateMethod
1313
end
1414

1515
def current_user
16-
'admin'
16+
"admin"
1717
end
1818

1919
def logout_user

lib/tiny_admin/plugins/simple_auth.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# frozen_string_literal: true
22

3-
require 'digest'
3+
require "digest"
44

55
module TinyAdmin
66
module Plugins
77
module SimpleAuth
88
class << self
99
def configure(app, opts = {})
1010
@@opts = opts || {} # rubocop:disable Style/ClassVars
11-
@@opts[:password] ||= ENV.fetch('ADMIN_PASSWORD_HASH', nil) # NOTE: fallback value
11+
@@opts[:password] ||= ENV.fetch("ADMIN_PASSWORD_HASH", nil) # NOTE: fallback value
1212

1313
Warden::Strategies.add(:secret) do
1414
def authenticate!
15-
secret = params['secret'] || ''
15+
secret = params["secret"] || ""
1616
return fail(:invalid_credentials) if Digest::SHA512.hexdigest(secret) != @@opts[:password]
1717

18-
success!(app: 'TinyAdmin')
18+
success!(app: "TinyAdmin")
1919
end
2020
end
2121

@@ -29,15 +29,15 @@ def authenticate!
2929

3030
module InstanceMethods
3131
def authenticate_user!
32-
env['warden'].authenticate!
32+
env["warden"].authenticate!
3333
end
3434

3535
def current_user
36-
env['warden'].user
36+
env["warden"].user
3737
end
3838

3939
def logout_user
40-
env['warden'].logout
40+
env["warden"].logout
4141
end
4242
end
4343
end

0 commit comments

Comments
 (0)