Skip to content

Commit

Permalink
Merge pull request #14 from Shopify/ec-rubocop
Browse files Browse the repository at this point in the history
Use shopify code style
  • Loading branch information
Edouard-chin committed Nov 27, 2018
2 parents 754c6c3 + e36f995 commit 8849eb6
Show file tree
Hide file tree
Showing 12 changed files with 1,241 additions and 31 deletions.
1,179 changes: 1,179 additions & 0 deletions .rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,7 @@
inherit_from:
- https://shopify.github.io/ruby-style-guide/rubocop.yml

AllCops:
TargetRubyVersion: 2.3
Exclude:
- 'vendor/**/*'
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -3,5 +3,8 @@ cache: bundler
language: ruby
before_install:
- gem update bundler
script:
- bundle exec rubocop --config .rubocop.yml
- bundle exec rake test
notifications:
email: false
8 changes: 7 additions & 1 deletion Gemfile
@@ -1,10 +1,16 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gemspec

group :deployment do
gem 'package_cloud'
gem 'rake'
end

group :test do
gem 'rubocop'
end
17 changes: 17 additions & 0 deletions Gemfile.lock
Expand Up @@ -6,11 +6,13 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
highline (1.6.20)
http-cookie (1.0.3)
domain_name (~> 0.5)
jaro_winkler (1.5.1)
json_pure (1.8.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
Expand All @@ -23,17 +25,31 @@ GEM
rainbow (= 2.2.2)
rest-client (~> 2.0)
thor (~> 0.18)
parallel (1.12.1)
parser (2.5.3.0)
ast (~> 2.4.0)
powerpack (0.1.2)
rainbow (2.2.2)
rake
rake (10.5.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rubocop (0.60.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
thor (0.20.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)

PLATFORMS
ruby
Expand All @@ -44,6 +60,7 @@ DEPENDENCIES
minitest (~> 5.0)
package_cloud
rake
rubocop

BUNDLED WITH
1.17.1
4 changes: 3 additions & 1 deletion Rakefile
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"

Expand All @@ -7,4 +9,4 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/*_test.rb"]
end

task :default => :test
task default: :test
14 changes: 0 additions & 14 deletions bin/console

This file was deleted.

12 changes: 7 additions & 5 deletions bootboot.gemspec
@@ -1,12 +1,14 @@
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "bootboot/version"

Gem::Specification.new do |spec|
spec.name = "bootboot"
spec.version = Bootboot::VERSION
spec.authors = ["Shopify"]
spec.email = ["rails@shopify.com"]
spec.authors = %w(Shopify)
spec.email = %w(rails@shopify.com)

spec.summary = "Dualbooting your ruby app made easy."
spec.description = <<-EOM.gsub(/\W+/, ' ')
Expand All @@ -22,10 +24,10 @@ Gem::Specification.new do |spec|
spec.metadata["source_code_uri"] = "https://github.com/shopify/bootboot"
spec.metadata["changelog_uri"] = "https://github.com/Shopify/bootboot/blob/master/CHANGELOG.md"

spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.require_paths = ["lib"]
spec.require_paths = %w(lib)

spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
2 changes: 2 additions & 0 deletions lib/bootboot.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bootboot/version"
require "bootboot/bundler_patch"

Expand Down
2 changes: 2 additions & 0 deletions lib/bootboot/version.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Bootboot
VERSION = "0.1.1"
end
22 changes: 12 additions & 10 deletions test/bootboot_test.rb
@@ -1,11 +1,13 @@
# frozen_string_literal: true

require "test_helper"
require 'tempfile'
require 'open3'
require 'fileutils'

class BootbootTest < Minitest::Test
def test_does_not_sync_the_gemfile_next_lock_when_unexisting
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
File.write(file, 'gem "warning"', mode: 'a')

run_bundler_command('bundle install', file.path)
Expand All @@ -15,7 +17,7 @@ def test_does_not_sync_the_gemfile_next_lock_when_unexisting
end

def test_does_not_sync_the_gemfile_next_lock_when_nothing_changed
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, 'gem "warning"', mode: 'a')

Expand All @@ -28,7 +30,7 @@ def test_does_not_sync_the_gemfile_next_lock_when_nothing_changed
end

def test_sync_the_gemfile_next_after_installation_of_new_gem
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, 'gem "warning"', mode: 'a')

Expand All @@ -40,7 +42,7 @@ def test_sync_the_gemfile_next_after_installation_of_new_gem
end

def test_sync_the_gemfile_next_after_removal_of_gem
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, 'gem "warning"', mode: 'a')

Expand All @@ -59,7 +61,7 @@ def test_sync_the_gemfile_next_after_removal_of_gem
end

def test_sync_the_gemfile_next_after_update_of_gem
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, 'gem "warning", "0.10.1"', mode: 'a')

Expand Down Expand Up @@ -100,7 +102,7 @@ def test_sync_the_gemfile_next_after_update_of_gem
end

def test_sync_the_gemfile_next_when_gemfile_contain_if_else_statement
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, <<-EOM, mode: 'a')
if ENV['DEPENDENCIES_NEXT']
Expand Down Expand Up @@ -139,7 +141,7 @@ def test_sync_the_lock_when_the_next_lock_gets_updated_rak
end
EOM

write_gemfile(gemfile_content) do |file, dir|
write_gemfile(gemfile_content) do |file, _dir|
FileUtils.cp(gemfile_next(file), "#{file.path}.lock")
File.write(file, 'gem "warning"', mode: 'a')

Expand All @@ -151,7 +153,7 @@ def test_sync_the_lock_when_the_next_lock_gets_updated_rak
end

def test_does_not_sync_the_gemfile_next_lock_when_installing_env_is_set
write_gemfile do |file, dir|
write_gemfile do |file, _dir|
FileUtils.cp("#{file.path}.lock", gemfile_next(file))
File.write(file, 'gem "warning"', mode: 'a')

Expand All @@ -161,7 +163,7 @@ def test_does_not_sync_the_gemfile_next_lock_when_installing_env_is_set
end

def test_bootboot_command_initialize_the_next_lock_and_update_the_gemfile
write_gemfile("source 'https://rubygems.org'\n#{plugin}\n") do |file, dir|
write_gemfile("source 'https://rubygems.org'\n#{plugin}\n") do |file, _dir|
run_bundler_command('bundle bootboot', file.path)

assert File.exist?(gemfile_next(file))
Expand Down Expand Up @@ -214,7 +216,7 @@ def write_gemfile(content = nil)
end

def plugin
branch = `git rev-parse --abbrev-ref HEAD`.strip
branch = %x(git rev-parse --abbrev-ref HEAD).strip

"plugin 'bootboot', git: '#{Bundler.root}', branch: '#{branch}'"
end
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "bootboot"

Expand Down

0 comments on commit 8849eb6

Please sign in to comment.