-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
201 changed files
with
3,697 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
PreCommit: | ||
RuboCop: | ||
enabled: true | ||
required: false | ||
on_warn: fail | ||
|
||
HardTabs: | ||
enabled: true | ||
required: false | ||
|
||
CommitMsg: | ||
TrailingPeriod: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--format documentation | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
inherit_gem: | ||
salsify_rubocop: conf/rubocop_rails.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
sudo: false | ||
language: ruby | ||
sudo: false | ||
|
||
bundler_args: --without test --jobs 3 --retry 3 | ||
before_install: | ||
- gem install bundler | ||
|
||
script: | ||
- bundle exec rubocop | ||
- bundle exec rspec | ||
|
||
rvm: | ||
- 2.2.7 | ||
- 2.3.4 | ||
before_install: gem install bundler -v 1.15.0 | ||
- 2.4.1 | ||
|
||
gemfile: | ||
- gemfiles/4.1.gemfile | ||
- gemfiles/4.2.gemfile | ||
- gemfiles/5.0.gemfile | ||
- gemfiles/5.1.gemfile | ||
|
||
matrix: | ||
allow_failures: | ||
- gemfile: gemfiles/4.1.gemfile | ||
rvm: 2.4.1 | ||
- gemfile: gemfiles/5.1.gemfile | ||
|
||
fast_finish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
appraise '4.1' do | ||
gem 'rails', '~> 4.1.0' | ||
end | ||
|
||
appraise '4.2' do | ||
gem 'rails', '~> 4.2.0' | ||
end | ||
|
||
appraise '5.0' do | ||
gem 'rails', '~> 5.0.0' | ||
end | ||
|
||
appraise '5.1' do | ||
gem 'rails', '~> 5.1.0' | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in safer_rails_console.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
require 'rails' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 4.1.0" | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 4.2.0" | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 5.0.0" | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 5.1.0" | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,61 @@ | ||
require "safer_rails_console/version" | ||
require 'safer_rails_console/version' | ||
require 'safer_rails_console/railtie' | ||
require 'safer_rails_console/colors' | ||
require 'safer_rails_console/rails_version' | ||
require 'safer_rails_console/console' | ||
|
||
module SaferRailsConsole | ||
# Your code goes here... | ||
class << self | ||
def environment_name | ||
config.environment_names.key?(::Rails.env.downcase) ? config.environment_names[::Rails.env.downcase] : 'unknown env' | ||
end | ||
|
||
def prompt_color | ||
config.environment_prompt_colors.key?(::Rails.env.downcase) ? config.environment_prompt_colors[::Rails.env.downcase] : SaferRailsConsole::Colors::NONE | ||
end | ||
|
||
def sandbox_environment? | ||
config.sandbox_environments.include?(::Rails.env.downcase) | ||
end | ||
|
||
def warn_environment? | ||
config.warn_environments.include?(::Rails.env.downcase) | ||
end | ||
|
||
def config | ||
@config ||= Configuration.new | ||
end | ||
end | ||
|
||
class Configuration | ||
include ActiveSupport::Configurable | ||
|
||
CONFIG_DEFAULTS = { | ||
console: 'irb', | ||
environment_names: { | ||
'development' => 'dev', | ||
'staging' => 'staging', | ||
'production' => 'prod' | ||
}, | ||
environment_prompt_colors: { | ||
'development' => SaferRailsConsole::Colors::GREEN, | ||
'staging' => SaferRailsConsole::Colors::YELLOW, | ||
'production' => SaferRailsConsole::Colors::RED | ||
}, | ||
sandbox_environments: %w{production}, | ||
sandbox_prompt: false, | ||
warn_environments: %w{production}, | ||
warn_text: "WARNING: YOU ARE USING RAILS CONSOLE IN PRODUCTION!\n" \ | ||
'Changing data can cause serious data loss. ' \ | ||
'Make sure you know what you\'re doing.' | ||
}.freeze | ||
|
||
CONFIG_DEFAULTS.each do |name, value| | ||
config_accessor(name) { value } | ||
end | ||
|
||
def set(**new_config) | ||
config.merge!(new_config.select { |k, _v| CONFIG_DEFAULTS.key?(k) }) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module SaferRailsConsole | ||
module Colors | ||
NONE = 0 | ||
BLACK = 30 | ||
RED = 31 | ||
GREEN = 32 | ||
YELLOW = 33 | ||
BLUE = 34 | ||
PINK = 35 | ||
CYAN = 36 | ||
WHITE = 37 | ||
|
||
def color_text(text, color_code) | ||
"\e[#{color_code}m#{text}\e[0m" | ||
end | ||
end | ||
end |
Oops, something went wrong.