Skip to content

Commit

Permalink
Removed old hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Boerger committed Oct 8, 2013
1 parent 2085949 commit 10b4340
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new

task :default => :spec
task :test => :spec
task default: :spec
task test: :spec
2 changes: 1 addition & 1 deletion bin/git-review
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end

desc 'Checkout a request\'s changes to local repo'
command :checkout do |c|
c.switch [:b, :branch], :default_value => true
c.switch [:b, :branch], default_value: true
c.action do |global, opts, args|
help_now!('Request number is required.') if args.empty?
::GitReview::Commands.checkout(args.shift, opts[:branch])
Expand Down
2 changes: 0 additions & 2 deletions lib/git-review.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
### Dependencies


## External Dependencies

# Provide access to GitHub's API.
Expand All @@ -12,7 +11,6 @@
# Use temporary files to allow editing a request's title and body.
require 'tempfile'


## Internal dependencies

# Include helper functions to make GitReview work as expected.
Expand Down
11 changes: 5 additions & 6 deletions lib/git-review/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# Used to retrieve hostname
require 'socket'


module GitReview

class Github
Expand All @@ -35,9 +34,9 @@ def configure_access
settings = ::GitReview::Settings.instance
if settings.oauth_token && settings.username
@github = Octokit::Client.new(
:login => settings.username,
:access_token => settings.oauth_token,
:auto_traversal => true
login: settings.username,
access_token: settings.oauth_token,
auto_traversal: true
)
@github.login
else
Expand Down Expand Up @@ -256,8 +255,8 @@ def authorize
req.basic_auth(@username, @password)
req.body = Yajl::Encoder.encode(
{
:scopes => %w(repo),
:note => @description
scopes: %w(repo),
note: @description
}
)
response = http.request(req)
Expand Down
1 change: 0 additions & 1 deletion lib/mixins/colorizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end


# A couple of presets to keep the code clean.

def red
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/nestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module Nestable
def nests(mapping)
# Setup an accessor for all nested instances.
attr_accessor *mapping.keys

# Create a nested instance automatically on initialize.
define_method(:initialize) do |arguments = nil|
mapping.each do |attribute, klass|
self.instance_variable_set "@#{attribute}".to_sym, klass.new
end
super arguments if arguments
end

end

end
4 changes: 2 additions & 2 deletions lib/models/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class Commit
include Accessible
extend Nestable

nests :user => User,
:repository => Repository
nests user: User,
repository: Repository

attr_accessor :sha,
:ref,
Expand Down
2 changes: 1 addition & 1 deletion lib/models/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Request
include Accessible
extend Nestable

nests :head => Commit
nests head: Commit

attr_accessor :number,
:title,
Expand Down
6 changes: 3 additions & 3 deletions spec/git-review/commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
comment = 'Reviewed and approved.'
github.should_receive(:add_comment).
with('some_source', request_number, 'Reviewed and approved.').
and_return(:body => comment)
and_return(body: comment)
subject.should_receive(:puts).with(/Successfully approved request./)
subject.approve(1)
end
Expand All @@ -207,7 +207,7 @@
message = 'fail'
github.should_receive(:add_comment).
with('some_source', request_number, 'Reviewed and approved.').
and_return(:body => nil, :message => message)
and_return(body: nil, message: message)
subject.should_receive(:puts).with(message)
subject.approve(1)
end
Expand Down Expand Up @@ -377,7 +377,7 @@
context 'when sending pull request to upstream repo' do

let(:upstream) {
Hashie::Mash.new(:parent => {:full_name => 'upstream'})
Hashie::Mash.new(parent: {full_name: 'upstream'})
}

before(:each) do
Expand Down
3 changes: 1 addition & 2 deletions spec/git-review/github_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
it 'from insteadof url' do
url = 'git@github.com:foo/bar.git'
config = {
'url.git@github.com:a/b.git.insteadof' =>
'git@github.com:foo/bar.git'
'url.git@github.com:a/b.git.insteadof' => 'git@github.com:foo/bar.git'
}
subject.send(:insteadof_matching, config, url).
should == %w(git@github.com:foo/bar.git git@github.com:a/b.git)
Expand Down
15 changes: 8 additions & 7 deletions spec/git-review/local_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

end


describe '#load_config' do

it 'reads config into hash' do
Expand Down Expand Up @@ -131,8 +132,8 @@

it 'does not delete the branch if request is not closed' do
open_request_number = 123
request = Hashie::Mash.new({:state => 'open',
:number => open_request_number})
request = Hashie::Mash.new({state: 'open',
number: open_request_number})
gh.stub(:pull_request).and_return(request)
subject.should_not_receive(:delete_branch)
subject.clean_single(open_request_number)
Expand All @@ -141,8 +142,8 @@
it 'deletes branch if request is found and no unmerged commits' do
subject.stub(:unmerged_commits?).and_return(false)
request_number = 1
request = Hashie::Mash.new({:head => {:ref => 'some_branch'},
:state => 'closed'})
request = Hashie::Mash.new({head: {ref: 'some_branch'},
state: 'closed'})
gh.stub(:pull_request).and_return(request)
subject.should_receive(:delete_branch).with('some_branch')
subject.clean_single(request_number)
Expand All @@ -151,7 +152,7 @@
it 'does not delete branch if there is unmerged commits' do
subject.stub(:unmerged_commits?).and_return(true)
request_number = 1
request = Hashie::Mash.new({:number => request_number})
request = Hashie::Mash.new({number: request_number})
gh.stub(:pull_request).and_return(request)
subject.should_not_receive(:delete_branch)
subject.clean_single(request_number)
Expand All @@ -160,8 +161,8 @@
it 'ignores unmerged commits if force deletion is set' do
subject.stub(:unmerged_commits?).and_return(true)
request_number = 1
request = Hashie::Mash.new({:head => {:ref => 'some_branch'},
:state => 'closed'})
request = Hashie::Mash.new({head: {ref: 'some_branch'},
state: 'closed'})
gh.stub(:pull_request).and_return(request)
subject.should_receive(:delete_branch)
subject.clean_single(request_number, force=true)
Expand Down
8 changes: 4 additions & 4 deletions spec/mixins/accessible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Baz
end

it 'initializes instances variables with provided defaults' do
subject = Foo.new(:bar => test_string,)
subject = Foo.new(bar: test_string,)
subject.bar.should == test_string
end

Expand All @@ -45,16 +45,16 @@ class Baz
end

it 'sets attributes from a hash' do
subject.update_attributes :bar => test_string, :baz => test_string
subject.update_attributes bar: test_string, baz: test_string
subject.bar.should == test_string
subject.baz.should == test_string
end

it 'recursively sets nested accessible attributes' do
subject.baz = Baz.new
subject.update_attributes(
:bar => test_string,
:baz => { :berk => test_string }
bar: test_string,
baz: { berk: test_string }
)
subject.baz.class.should == Baz
subject.baz.berk.should == test_string
Expand Down
2 changes: 1 addition & 1 deletion spec/mixins/nestable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Foo

class Baz
extend Nestable
nests :foo => Foo
nests foo: Foo
end

subject { Baz.new }
Expand Down
28 changes: 14 additions & 14 deletions spec/support/request_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

let(:request) {
Hashie::Mash.new(
:html_url => html_url,
:number => request_number,
:state => 'open',
:title => title,
:body => body,
:updated_at => Time.now.to_s,
:head => {
:sha => head_sha,
:ref => head_ref,
:label => head_label,
:repo => head_repo,
:user => { :login => 'user' }
html_url: html_url,
number: request_number,
state: 'open',
title: title,
body: body,
updated_at: Time.now.to_s,
head: {
sha: head_sha,
ref: head_ref,
label: head_label,
repo: head_repo,
user: { login: 'user' }
},
:comments => 0,
:review_comments => 0
comments: 0,
review_comments: 0
)
}

Expand Down

0 comments on commit 10b4340

Please sign in to comment.