one-eye-eater 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15d875cdefe5e55f690d6f0993b5a288e200d062
4
- data.tar.gz: 7de1ff7280e8bbcea30d709ca98e8178822f3777
3
+ metadata.gz: 1bd63393c74c6d9ec51fe0a27d8773ea028e9a9c
4
+ data.tar.gz: 4efd474e011166f6295f35189b1dc8e63abd354d
5
5
  SHA512:
6
- metadata.gz: 535c0bba71f0f4b803a7594609bf6b432982d6a7f23795f71d18d72e3a9e8ddd1639379753f9f99567888a38cf7759947db22b95f987280e66e3d16a5112e124
7
- data.tar.gz: e51c74aff296c00874e317d8ce09bc887d45bee90cc797b294c312874de82ed4858c9cf45d1d36e130b0b4e5d5fbf873b457a39f893f35c0cb2aa3e88d93085c
6
+ metadata.gz: 503a66b8233ca434b6fbf25cb369c62b7c8c486a0db1f13a940c6549c88b03271b08371a91b3b2980ebda19fe80209db570dae93b3669ebe757cac8f7a307e89
7
+ data.tar.gz: 4ecf97a4392e9fe9d33cd6fa868b51df263178ce7bfcb9563abf5cb8e2be9fe631ef99b4e2b2c7b249469f34e504bc7e7a15137e3be0f1ebc992e93a7db1fd6e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
data/lib/api.rb CHANGED
@@ -8,10 +8,16 @@ module OneEye
8
8
  def self.http_methods
9
9
  [:get, :post, :put, :patch, :delete]
10
10
  end
11
+
11
12
  def initialize(api_token=ENV["ONE_EYE_API_KEY"])
12
13
  @options = { query: {api_token: api_token} }
13
14
  end
14
15
 
16
+ def self.debug(options={})
17
+ OneEye::API.debug_output $stdout unless options[:stop]
18
+ OneEye::API.debug_output $stderr if options[:stop]
19
+ end
20
+
15
21
  http_methods.each do |method_name|
16
22
  define_method method_name do |name, options|
17
23
  name, options = standardize_request(method_name, name, options)
@@ -40,9 +46,11 @@ module OneEye
40
46
  if options.class == Fixnum
41
47
  options = {id: options}
42
48
  end
43
- options[:body] = options.to_json
44
- options[:headers] = {"Content-Type"=>"application/json"}
45
- @options.merge(options)
49
+ options.each { |k, v| @options[k] ||= v }
50
+ @options[:query] = @options[:query].merge(options)
51
+ @options[:body] = options.to_json
52
+ @options[:headers] = {"Content-Type"=>"application/json"}
53
+ @options
46
54
  end
47
55
  end
48
56
  end
data/lib/models/base.rb CHANGED
@@ -23,7 +23,8 @@ module OneEye
23
23
  end
24
24
 
25
25
  def attributes
26
- self.class.attributes.inject Hash.new do |attributes, key|
26
+ instance_variables.inject Hash.new do |attributes, key|
27
+ key = key.to_s.gsub(/\@/) { "" }
27
28
  attributes[key] = send key
28
29
  attributes
29
30
  end
@@ -58,7 +59,10 @@ module OneEye
58
59
  end
59
60
 
60
61
  def non_nil_attributes
61
- attributes.reject { |key, value| value.nil? }
62
+ instance_variables.inject Hash.new do |obj, key|
63
+ obj[key.to_s[1..-1].to_sym] = instance_variable_get(key) unless instance_variable_get(key).nil?
64
+ obj
65
+ end
62
66
  end
63
67
 
64
68
  def api
@@ -73,5 +77,15 @@ module OneEye
73
77
  def self.resources_url
74
78
  self.name.gsub(/\w+\:\:/) {}.downcase.pluralize
75
79
  end
80
+
81
+ def method_missing(name, *args, &block)
82
+ if name[-1] == "="
83
+ instance_variable_set "@#{name[0..-2]}", args[0]
84
+ elsif instance_variable_get "@#{name}"
85
+ instance_variable_get "@#{name}"
86
+ else
87
+ super
88
+ end
89
+ end
76
90
  end
77
91
  end
@@ -2,11 +2,5 @@ require_relative "./base"
2
2
 
3
3
  module OneEye
4
4
  class District < OneEye::Base
5
- def self.attributes
6
- [:id, :name, :url, :abbreviated_name, :motto, :lead_title, :address, :zip_code,
7
- :city, :county, :state, :website, :phone_number, :country_id, :avatars, :lead]
8
- end
9
-
10
- attr_accessor *self.attributes
11
5
  end
12
6
  end
data/lib/models/school.rb CHANGED
@@ -2,12 +2,5 @@ require_relative "./base"
2
2
 
3
3
  module OneEye
4
4
  class School < OneEye::Base
5
- def self.attributes
6
- [:id, :name, :url, :abbreviated_name, :motto, :start_level, :end_level, :lead_title,
7
- :lead, :district_id, :address, :zip_code, :city, :county, :state, :website, :phone_number,
8
- :code_contact, :code_email, :code_phone_number, :join_code, :avatars, :country_id, :latitude, :longitude]
9
- end
10
-
11
- attr_accessor *self.attributes
12
5
  end
13
6
  end
data/lib/models/user.rb CHANGED
@@ -2,11 +2,5 @@ require_relative "./base"
2
2
 
3
3
  module OneEye
4
4
  class User < OneEye::Base
5
- def self.attributes
6
- [:id, :url, :type, :username, :user_title, :first_name, :last_name, :locale, :time_zone, :email, :avatars, :school, :school_id, :district, :district_id,
7
- :admin_rights, :utc_offset, :verified_institution_member, :status_code]
8
- end
9
-
10
- attr_accessor *self.attributes
11
5
  end
12
6
  end
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: one-eye-eater 0.1.10 ruby lib
5
+ # stub: one-eye-eater 0.1.11 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "one-eye-eater"
9
- s.version = "0.1.10"
9
+ s.version = "0.1.11"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -38,9 +38,7 @@ Gem::Specification.new do |s|
38
38
  "spec/mock_urls.rb",
39
39
  "spec/models/base_spec.rb",
40
40
  "spec/one_eye_spec.rb",
41
- "spec/spec_helper.rb",
42
- "test/helper.rb",
43
- "test/test_one_eye.rb"
41
+ "spec/spec_helper.rb"
44
42
  ]
45
43
  s.homepage = "http://github.com/brettshollenberger/one-eye-eater"
46
44
  s.licenses = ["MIT"]
@@ -21,6 +21,11 @@ describe OneEye::Base do
21
21
  expect(@schools.first.abbreviated_name).to eq("OVOXO")
22
22
  end
23
23
 
24
+ it "appropriately sets query key to where" do
25
+ @schools = OneEye::School.where(:district_id => 21417, :query => "october")
26
+ expect(@schools.first.name).to eq("October's Very Own School")
27
+ end
28
+
24
29
  # Commented out to avoid creating a bunch of instances
25
30
  # describe "Creating and destroying" do
26
31
  # before(:each) do
@@ -37,7 +42,7 @@ describe OneEye::Base do
37
42
  # end
38
43
  # end
39
44
 
40
- it "updates instances" do
45
+ it "updates instances", :create => true do
41
46
  @district = OneEye::District.new(:id => 21417)
42
47
  expect(@district.update(:motto => "Get Money Get Paid").motto).to eq("Get Money Get Paid")
43
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one-eye-eater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Shollenberger
@@ -206,8 +206,6 @@ files:
206
206
  - spec/models/base_spec.rb
207
207
  - spec/one_eye_spec.rb
208
208
  - spec/spec_helper.rb
209
- - test/helper.rb
210
- - test/test_one_eye.rb
211
209
  homepage: http://github.com/brettshollenberger/one-eye-eater
212
210
  licenses:
213
211
  - MIT
data/test/helper.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'simplecov'
2
-
3
- module SimpleCov::Configuration
4
- def clean_filters
5
- @filters = []
6
- end
7
- end
8
-
9
- SimpleCov.configure do
10
- clean_filters
11
- load_adapter 'test_frameworks'
12
- end
13
-
14
- ENV["COVERAGE"] && SimpleCov.start do
15
- add_filter "/.rvm/"
16
- end
17
- require 'rubygems'
18
- require 'bundler'
19
- begin
20
- Bundler.setup(:default, :development)
21
- rescue Bundler::BundlerError => e
22
- $stderr.puts e.message
23
- $stderr.puts "Run `bundle install` to install missing gems"
24
- exit e.status_code
25
- end
26
- require 'test/unit'
27
- require 'shoulda'
28
-
29
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
- $LOAD_PATH.unshift(File.dirname(__FILE__))
31
- require 'one_eye'
32
-
33
- class Test::Unit::TestCase
34
- end
data/test/test_one_eye.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestOneEye < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end