Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove polyfills #5

Merged
merged 3 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hawk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'multi_json'
spec.add_dependency 'dalli'
spec.add_dependency 'activemodel'
spec.add_dependency 'activesupport'

spec.add_development_dependency 'bundler', '~> 1.8'
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down
5 changes: 4 additions & 1 deletion lib/hawk.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
##
# Hawk entry point.
#
#

require 'active_support/core_ext/array/wrap'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enough? Or, why is it needed? We are using pluralize but not requiring it explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, that's strange, but without this explicit require I get a
#<NoMethodError: undefined method 'wrap' for Array:Class>. I have the feeling it has to do with ActiveSupport's require-ing and autoloading.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, cool, thanks.


require 'hawk/version'
require 'hawk/polyfills' # DIH

require 'hawk/error'
require 'hawk/http'
Expand Down
1 change: 0 additions & 1 deletion lib/hawk/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Hawk
# Represent an HTTP connector, to be linked to a {Model}.
#
class HTTP
using Hawk::Polyfills # Hash#deep_merge

prepend Caching
include Instrumentation
Expand Down
2 changes: 0 additions & 2 deletions lib/hawk/http/caching.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
require 'dalli'
require 'active_support/core_ext/array/wrap'

module Hawk
class HTTP

module Caching
using Hawk::Polyfills # Hash#deep_merge

DEFAULTS = {
server: 'localhost:11211',
Expand Down
1 change: 0 additions & 1 deletion lib/hawk/model/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Hawk
module Model

module Association
using Hawk::Polyfills # Hash#deep_merge, Module#parent, String#demodulize, String#underscore, String#camelize, String#singularize

# Initialize the associations registry
#
Expand Down
1 change: 0 additions & 1 deletion lib/hawk/model/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Hawk
module Model

module Finder
using Hawk::Polyfills # Hash#deep_merge, String#underscore, String#demodulize, String#pluralize

def self.included(base)
base.extend ClassMethods
Expand Down
1 change: 0 additions & 1 deletion lib/hawk/model/lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Hawk
module Model

module Lookup
using Hawk::Polyfills # Module#parent

def self.included(base)
base.extend ClassMethods
Expand Down
2 changes: 0 additions & 2 deletions lib/hawk/model/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module Model
class Proxy
include Enumerable

using Hawk::Polyfills # Hash#deep_merge, Module#parents

def initialize(klass, params)
@klass = klass
@params = params
Expand Down
1 change: 0 additions & 1 deletion lib/hawk/model/querying.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Hawk
module Model

module Querying
using Hawk::Polyfills # Hash#deep_merge

def self.included(base)
base.extend ClassMethods
Expand Down
48 changes: 0 additions & 48 deletions lib/hawk/polyfills/hash.rb

This file was deleted.

42 changes: 0 additions & 42 deletions lib/hawk/polyfills/module.rb

This file was deleted.

35 changes: 0 additions & 35 deletions lib/hawk/polyfills/string.rb

This file was deleted.

12 changes: 6 additions & 6 deletions spec/basic_operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Person < Hawk::Model::Base

describe '.find(id)' do
specify do
stub_request(:GET, "http://zombo.com/persons/2").
stub_request(:GET, "http://zombo.com/people/2").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(status: 200, body: person_attributes.to_json, headers: {})

Expand All @@ -33,7 +33,7 @@ class Person < Hawk::Model::Base

describe '.first' do
specify do
stub_request(:GET, "http://zombo.com/persons?limit=1").
stub_request(:GET, "http://zombo.com/people?limit=1").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(status: 200, body: [person_attributes].to_json, headers: {})

Expand All @@ -46,7 +46,7 @@ class Person < Hawk::Model::Base

describe '.all' do
specify do
stub_request(:GET, "http://zombo.com/persons").
stub_request(:GET, "http://zombo.com/people").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(status: 200, body: [person_attributes, person_attributes].to_json, headers: {})

Expand All @@ -57,7 +57,7 @@ class Person < Hawk::Model::Base

describe '.where' do
specify do
stub_request(:GET, "http://zombo.com/persons?name=Zelig").
stub_request(:GET, "http://zombo.com/people?name=Zelig").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(status: 200, body: [person_attributes].to_json, headers: {})

Expand All @@ -68,7 +68,7 @@ class Person < Hawk::Model::Base

describe '.order' do
specify do
stub_request(:GET, "http://zombo.com/persons?order=name").
stub_request(:GET, "http://zombo.com/people?order=name").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(status: 200, body: [person_attributes].to_json, headers: {})

Expand All @@ -83,7 +83,7 @@ class Person < Hawk::Model::Base
end

it 'allows active_record-like scopes' do
stub_request(:GET, "http://zombo.com/persons?limit=1&name=pluto").
stub_request(:GET, "http://zombo.com/people?limit=1&name=pluto").
with(:headers => {'User-Agent'=>'Foobar'}).
to_return(:status => 200, :body => [person_attributes].to_json, :headers => {})
person = Person.by_name('pluto').first
Expand Down