one-eye-eater 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +2 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +137 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +34 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/api.rb +49 -0
- data/lib/models/base.rb +77 -0
- data/lib/models/district.rb +12 -0
- data/lib/models/school.rb +13 -0
- data/lib/models/user.rb +12 -0
- data/lib/one_eye.rb +2 -0
- data/spec/mock_urls.rb +103 -0
- data/spec/models/base_spec.rb +50 -0
- data/spec/one_eye_spec.rb +10 -0
- data/spec/spec_helper.rb +8 -0
- data/test/helper.rb +34 -0
- data/test/test_one_eye.rb +7 -0
- metadata +234 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 87351cdf3ed2bc5c5f54baa6b42a1b1564de1a97
|
|
4
|
+
data.tar.gz: 0a3f6b8e43fa8877d6da97060dc6bd1ebc78c1fe
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6ce55067460f48e5486c438b322eb4ebf6e029c06d3d2cf846e91561ff0d7cb223e746d2f7a9af59d2135241ad05bc6c5b01fb3deb061f4d6303740cf2c1f416
|
|
7
|
+
data.tar.gz: 9510da726918e46f97234c91af5ee1bb324c31aa820e5dba95d9ecc73bd3759592e0504ee0058b4bc975837d90fe1c41c845d316e117a2e44fdc3c8fdb89dba2
|
data/.document
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
group :development do
|
|
4
|
+
gem "shoulda", ">= 0"
|
|
5
|
+
gem "rdoc", "~> 3.12"
|
|
6
|
+
gem "bundler", "~> 1.0"
|
|
7
|
+
gem "jeweler", "~> 2.0.1"
|
|
8
|
+
gem "simplecov", ">= 0"
|
|
9
|
+
gem "fakeweb"
|
|
10
|
+
gem "rspec"
|
|
11
|
+
gem "httparty"
|
|
12
|
+
gem "guard"
|
|
13
|
+
gem "guard-rspec"
|
|
14
|
+
gem "activemodel"
|
|
15
|
+
gem "pry"
|
|
16
|
+
end
|
|
17
|
+
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (4.1.1)
|
|
5
|
+
activesupport (= 4.1.1)
|
|
6
|
+
builder (~> 3.1)
|
|
7
|
+
activesupport (4.1.1)
|
|
8
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
9
|
+
json (~> 1.7, >= 1.7.7)
|
|
10
|
+
minitest (~> 5.1)
|
|
11
|
+
thread_safe (~> 0.1)
|
|
12
|
+
tzinfo (~> 1.1)
|
|
13
|
+
addressable (2.3.6)
|
|
14
|
+
builder (3.2.2)
|
|
15
|
+
celluloid (0.15.2)
|
|
16
|
+
timers (~> 1.1.0)
|
|
17
|
+
coderay (1.1.0)
|
|
18
|
+
descendants_tracker (0.0.4)
|
|
19
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
20
|
+
diff-lcs (1.2.5)
|
|
21
|
+
docile (1.1.4)
|
|
22
|
+
fakeweb (1.3.0)
|
|
23
|
+
faraday (0.9.0)
|
|
24
|
+
multipart-post (>= 1.2, < 3)
|
|
25
|
+
ffi (1.9.3)
|
|
26
|
+
formatador (0.2.5)
|
|
27
|
+
git (1.2.7)
|
|
28
|
+
github_api (0.11.3)
|
|
29
|
+
addressable (~> 2.3)
|
|
30
|
+
descendants_tracker (~> 0.0.1)
|
|
31
|
+
faraday (~> 0.8, < 0.10)
|
|
32
|
+
hashie (>= 1.2)
|
|
33
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
34
|
+
nokogiri (~> 1.6.0)
|
|
35
|
+
oauth2
|
|
36
|
+
guard (2.6.1)
|
|
37
|
+
formatador (>= 0.2.4)
|
|
38
|
+
listen (~> 2.7)
|
|
39
|
+
lumberjack (~> 1.0)
|
|
40
|
+
pry (>= 0.9.12)
|
|
41
|
+
thor (>= 0.18.1)
|
|
42
|
+
guard-rspec (4.2.10)
|
|
43
|
+
guard (~> 2.1)
|
|
44
|
+
rspec (>= 2.14, < 4.0)
|
|
45
|
+
hashie (3.0.0)
|
|
46
|
+
highline (1.6.21)
|
|
47
|
+
httparty (0.13.1)
|
|
48
|
+
json (~> 1.8)
|
|
49
|
+
multi_xml (>= 0.5.2)
|
|
50
|
+
i18n (0.6.9)
|
|
51
|
+
jeweler (2.0.1)
|
|
52
|
+
builder
|
|
53
|
+
bundler (>= 1.0)
|
|
54
|
+
git (>= 1.2.5)
|
|
55
|
+
github_api
|
|
56
|
+
highline (>= 1.6.15)
|
|
57
|
+
nokogiri (>= 1.5.10)
|
|
58
|
+
rake
|
|
59
|
+
rdoc
|
|
60
|
+
json (1.8.1)
|
|
61
|
+
jwt (1.0.0)
|
|
62
|
+
listen (2.7.8)
|
|
63
|
+
celluloid (>= 0.15.2)
|
|
64
|
+
rb-fsevent (>= 0.9.3)
|
|
65
|
+
rb-inotify (>= 0.9)
|
|
66
|
+
lumberjack (1.0.6)
|
|
67
|
+
method_source (0.8.2)
|
|
68
|
+
mini_portile (0.6.0)
|
|
69
|
+
minitest (5.3.4)
|
|
70
|
+
multi_json (1.10.1)
|
|
71
|
+
multi_xml (0.5.5)
|
|
72
|
+
multipart-post (2.0.0)
|
|
73
|
+
nokogiri (1.6.2.1)
|
|
74
|
+
mini_portile (= 0.6.0)
|
|
75
|
+
oauth2 (0.9.4)
|
|
76
|
+
faraday (>= 0.8, < 0.10)
|
|
77
|
+
jwt (~> 1.0)
|
|
78
|
+
multi_json (~> 1.3)
|
|
79
|
+
multi_xml (~> 0.5)
|
|
80
|
+
rack (~> 1.2)
|
|
81
|
+
pry (0.10.0)
|
|
82
|
+
coderay (~> 1.1.0)
|
|
83
|
+
method_source (~> 0.8.1)
|
|
84
|
+
slop (~> 3.4)
|
|
85
|
+
rack (1.5.2)
|
|
86
|
+
rake (10.3.2)
|
|
87
|
+
rb-fsevent (0.9.4)
|
|
88
|
+
rb-inotify (0.9.5)
|
|
89
|
+
ffi (>= 0.5.0)
|
|
90
|
+
rdoc (3.12.2)
|
|
91
|
+
json (~> 1.4)
|
|
92
|
+
rspec (3.0.0)
|
|
93
|
+
rspec-core (~> 3.0.0)
|
|
94
|
+
rspec-expectations (~> 3.0.0)
|
|
95
|
+
rspec-mocks (~> 3.0.0)
|
|
96
|
+
rspec-core (3.0.1)
|
|
97
|
+
rspec-support (~> 3.0.0)
|
|
98
|
+
rspec-expectations (3.0.1)
|
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
100
|
+
rspec-support (~> 3.0.0)
|
|
101
|
+
rspec-mocks (3.0.1)
|
|
102
|
+
rspec-support (~> 3.0.0)
|
|
103
|
+
rspec-support (3.0.0)
|
|
104
|
+
shoulda (3.5.0)
|
|
105
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
|
106
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
|
107
|
+
shoulda-context (1.2.1)
|
|
108
|
+
shoulda-matchers (2.6.1)
|
|
109
|
+
activesupport (>= 3.0.0)
|
|
110
|
+
simplecov (0.8.2)
|
|
111
|
+
docile (~> 1.1.0)
|
|
112
|
+
multi_json
|
|
113
|
+
simplecov-html (~> 0.8.0)
|
|
114
|
+
simplecov-html (0.8.0)
|
|
115
|
+
slop (3.5.0)
|
|
116
|
+
thor (0.19.1)
|
|
117
|
+
thread_safe (0.3.4)
|
|
118
|
+
timers (1.1.0)
|
|
119
|
+
tzinfo (1.2.1)
|
|
120
|
+
thread_safe (~> 0.1)
|
|
121
|
+
|
|
122
|
+
PLATFORMS
|
|
123
|
+
ruby
|
|
124
|
+
|
|
125
|
+
DEPENDENCIES
|
|
126
|
+
activemodel
|
|
127
|
+
bundler (~> 1.0)
|
|
128
|
+
fakeweb
|
|
129
|
+
guard
|
|
130
|
+
guard-rspec
|
|
131
|
+
httparty
|
|
132
|
+
jeweler (~> 2.0.1)
|
|
133
|
+
pry
|
|
134
|
+
rdoc (~> 3.12)
|
|
135
|
+
rspec
|
|
136
|
+
shoulda
|
|
137
|
+
simplecov
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2014 Brett Shollenberger
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
= One Eye Eater
|
|
2
|
+
|
|
3
|
+
Ruby wrapper for One Eye.
|
|
4
|
+
|
|
5
|
+
== Object-oriented wrappers
|
|
6
|
+
|
|
7
|
+
For traditional, RESTful endpoints, use Rails-style CRUD actions:
|
|
8
|
+
|
|
9
|
+
# find
|
|
10
|
+
@school = OneEye::School.find(334517)
|
|
11
|
+
expect(@school.name).to eq("October's Very Own School")
|
|
12
|
+
|
|
13
|
+
# where
|
|
14
|
+
@schools = OneEye::School.where(:district_id => 21417)
|
|
15
|
+
expect(@schools.length).to eq(1)
|
|
16
|
+
|
|
17
|
+
# create
|
|
18
|
+
@user = OneEye::User.create(:first_name => "Drake")
|
|
19
|
+
expect(@user.first_name).to eq("Drake")
|
|
20
|
+
|
|
21
|
+
# update
|
|
22
|
+
@district = OneEye::District.find(1)
|
|
23
|
+
@district.update(:name => "Young Money Cash Money Billionaires District")
|
|
24
|
+
expect(@district.name).to eq("Young Money Cash Money Billionaires District")
|
|
25
|
+
|
|
26
|
+
# destroy
|
|
27
|
+
@district = OneEye::District.find(1)
|
|
28
|
+
@district.destroy
|
|
29
|
+
|
|
30
|
+
== Copyright
|
|
31
|
+
|
|
32
|
+
Copyright (c) 2014 Edmodo. See LICENSE.txt for
|
|
33
|
+
further details.
|
|
34
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
|
17
|
+
gem.name = "one-eye-eater"
|
|
18
|
+
gem.homepage = "http://github.com/brettshollenberger/one-eye-eater"
|
|
19
|
+
gem.license = "MIT"
|
|
20
|
+
gem.summary = %Q{One Eye API client}
|
|
21
|
+
gem.description = %Q{Create, read, update, and destroy Edmodo data via the One Eye API.}
|
|
22
|
+
gem.email = "brett.shollenberger@gmail.com"
|
|
23
|
+
gem.authors = ["Brett Shollenberger"]
|
|
24
|
+
# dependencies defined in Gemfile
|
|
25
|
+
end
|
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
+
|
|
28
|
+
require 'rake/testtask'
|
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
|
30
|
+
test.libs << 'lib' << 'test'
|
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
|
32
|
+
test.verbose = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc "Code coverage detail"
|
|
36
|
+
task :simplecov do
|
|
37
|
+
ENV['COVERAGE'] = "true"
|
|
38
|
+
Rake::Task['test'].execute
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
task :default => :test
|
|
42
|
+
|
|
43
|
+
require 'rdoc/task'
|
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
46
|
+
|
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
48
|
+
rdoc.title = "one-eye-eater"
|
|
49
|
+
rdoc.rdoc_files.include('README*')
|
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
51
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.1
|
data/lib/api.rb
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require "httparty"
|
|
2
|
+
require "pry"
|
|
3
|
+
|
|
4
|
+
module OneEye
|
|
5
|
+
class API
|
|
6
|
+
include HTTParty
|
|
7
|
+
base_uri "https://stg-api.edmodoqabranch.com"
|
|
8
|
+
|
|
9
|
+
def self.http_methods
|
|
10
|
+
[:get, :post, :put, :patch, :delete]
|
|
11
|
+
end
|
|
12
|
+
def initialize(api_token=ENV["ONE_EYE_API_KEY"])
|
|
13
|
+
@options = { query: {api_token: api_token} }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
http_methods.each do |method_name|
|
|
17
|
+
define_method method_name do |name, options|
|
|
18
|
+
name, options = standardize_request(method_name, name, options)
|
|
19
|
+
self.class.send method_name, name, options
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def method_missing(name, options={})
|
|
25
|
+
name, options = standardize_request(:get, name, options)
|
|
26
|
+
self.class.get name, options
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def standardize_request(http_method, name, options)
|
|
30
|
+
name = slash_name(name)
|
|
31
|
+
options = standardize_options(options)
|
|
32
|
+
name += "/#{options[:id]}" if options.keys.include? :id
|
|
33
|
+
[name, options]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def slash_name(name)
|
|
37
|
+
"/#{name.to_s.gsub(/\_/) { "/" }}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def standardize_options(options={})
|
|
41
|
+
if options.class == Fixnum
|
|
42
|
+
options = {id: options}
|
|
43
|
+
end
|
|
44
|
+
options[:body] = options.to_json
|
|
45
|
+
options[:headers] = {"Content-Type"=>"application/json"}
|
|
46
|
+
@options.merge(options)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/models/base.rb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require "active_model"
|
|
2
|
+
require "yaml"
|
|
3
|
+
require_relative "../api"
|
|
4
|
+
|
|
5
|
+
module OneEye
|
|
6
|
+
class Base
|
|
7
|
+
include ActiveModel::Serializers::JSON
|
|
8
|
+
|
|
9
|
+
def self.api
|
|
10
|
+
OneEye::API.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize(attributes = {})
|
|
14
|
+
self.attributes = attributes
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def attributes=(attrs)
|
|
18
|
+
begin
|
|
19
|
+
attrs = YAML.load(attrs)
|
|
20
|
+
rescue
|
|
21
|
+
end
|
|
22
|
+
attrs.each { |k, v| send "#{k}=", v }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def attributes
|
|
26
|
+
self.class.attributes.inject Hash.new do |attributes, key|
|
|
27
|
+
attributes[key] = send key
|
|
28
|
+
attributes
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.find(attributes={})
|
|
33
|
+
new(api.get(resources_url, attributes).parsed_response)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.where(attributes={})
|
|
37
|
+
api.get(resources_url, attributes).map do |model|
|
|
38
|
+
new model
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.create(attributes={})
|
|
43
|
+
new(api.post(resources_url, attributes))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def update(attributes={})
|
|
47
|
+
self.attributes = attributes
|
|
48
|
+
self.attributes = api.put(resources_url, non_nil_attributes)
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def destroy
|
|
53
|
+
api.delete resources_url, non_nil_attributes
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def delete
|
|
57
|
+
destroy
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def non_nil_attributes
|
|
61
|
+
attributes.reject { |key, value| value.nil? }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def api
|
|
65
|
+
self.class.api
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def resources_url
|
|
69
|
+
self.class.resources_url
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
def self.resources_url
|
|
74
|
+
self.name.gsub(/\w+\:\:/) {}.downcase.pluralize
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative "./base"
|
|
2
|
+
|
|
3
|
+
module OneEye
|
|
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
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative "./base"
|
|
2
|
+
|
|
3
|
+
module OneEye
|
|
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]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
attr_accessor *self.attributes
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/models/user.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative "./base"
|
|
2
|
+
|
|
3
|
+
module OneEye
|
|
4
|
+
class User < OneEye::Base
|
|
5
|
+
def self.attributes
|
|
6
|
+
[:id, :url, :type, :username, :user_title, :first_name, :last_name, :locale, :time_zone,
|
|
7
|
+
:email, :avatars, :school, :district, :admin_rights, :utc_offset, :verified_institution_member]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
attr_accessor *self.attributes
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/one_eye.rb
ADDED
data/spec/mock_urls.rb
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require "fakeweb"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
module MockUrls
|
|
5
|
+
@district =
|
|
6
|
+
{
|
|
7
|
+
url: "https://stg-api.edmodoqabranch.com/districts/21417",
|
|
8
|
+
id: 21417,
|
|
9
|
+
name: "Young Money Cash Money Billionaires",
|
|
10
|
+
abbreviated_name: "YMCMB",
|
|
11
|
+
motto: nil,
|
|
12
|
+
lead_title: "Superintendent",
|
|
13
|
+
address: "60 Hard Knocks Ave.",
|
|
14
|
+
zip_code: "94401",
|
|
15
|
+
city: nil,
|
|
16
|
+
county: nil,
|
|
17
|
+
state: "CA",
|
|
18
|
+
website: nil,
|
|
19
|
+
phone_number: nil,
|
|
20
|
+
country_id: nil,
|
|
21
|
+
avatars: {
|
|
22
|
+
small: nil,
|
|
23
|
+
large: "https://u.ph.edim.co/default-avatars/default-icon-district-profile-green.png"
|
|
24
|
+
},
|
|
25
|
+
lead: {
|
|
26
|
+
url: "https://stg-api.edmodoqabranch.com/users/34954895",
|
|
27
|
+
id: 34954895,
|
|
28
|
+
type: "teacher",
|
|
29
|
+
username: "dr_drake",
|
|
30
|
+
user_title: nil,
|
|
31
|
+
first_name: "Aubrey",
|
|
32
|
+
last_name: "Graham",
|
|
33
|
+
avatars: {
|
|
34
|
+
small: "https://u.ph.edim.co/default-avatars/44_42.jpg",
|
|
35
|
+
large: "https://u.ph.edim.co/default-avatars/44_140.jpg"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}.to_json
|
|
39
|
+
|
|
40
|
+
@districts =
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
url: "https://stg-api.edmodoqabranch.com/districts/1",
|
|
44
|
+
id: 1,
|
|
45
|
+
name: "Al Inst Deaf And Blind",
|
|
46
|
+
abbreviated_name: nil,
|
|
47
|
+
motto: "test motto",
|
|
48
|
+
lead_title: "superintendent",
|
|
49
|
+
address: "P O Drawer 698",
|
|
50
|
+
zip_code: "35161",
|
|
51
|
+
city: "Talladega",
|
|
52
|
+
county: "Talladega",
|
|
53
|
+
state: "AL",
|
|
54
|
+
website: nil,
|
|
55
|
+
phone_number: "2567613200",
|
|
56
|
+
country_id: "US",
|
|
57
|
+
avatars: {
|
|
58
|
+
small: nil,
|
|
59
|
+
large: "https://u.ph.edim.co/default-avatars/default-icon-district-profile-green.png"
|
|
60
|
+
},
|
|
61
|
+
lead: {
|
|
62
|
+
url: "https://stg-api.edmodoqabranch.com/users/1",
|
|
63
|
+
id: 1,
|
|
64
|
+
type: "teacher",
|
|
65
|
+
username: "nic",
|
|
66
|
+
user_title: "Mr",
|
|
67
|
+
first_name: "Nic",
|
|
68
|
+
last_name: "Borg",
|
|
69
|
+
avatars: {
|
|
70
|
+
small: "https://u.ph.edim.co/c4ca/1_1_42.png",
|
|
71
|
+
large: "https://u.ph.edim.co/c4ca/1_1_140.png"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
url: "https://stg-api.edmodoqabranch.com/districts/2",
|
|
77
|
+
id: 2,
|
|
78
|
+
name: "Alabama Clinical School",
|
|
79
|
+
abbreviated_name: nil,
|
|
80
|
+
motto: nil,
|
|
81
|
+
lead_title: nil,
|
|
82
|
+
address: "1221 Alton Dr",
|
|
83
|
+
zip_code: "35210",
|
|
84
|
+
city: "Birmingham",
|
|
85
|
+
county: "Jefferson",
|
|
86
|
+
state: "AL",
|
|
87
|
+
website: nil,
|
|
88
|
+
phone_number: "2565466324",
|
|
89
|
+
country_id: "US",
|
|
90
|
+
avatars: {
|
|
91
|
+
small: nil,
|
|
92
|
+
large: "https://u.ph.edim.co/default-avatars/default-icon-district-profile-green.png"
|
|
93
|
+
},
|
|
94
|
+
lead: nil
|
|
95
|
+
}
|
|
96
|
+
].to_json
|
|
97
|
+
|
|
98
|
+
FakeWeb.register_uri(:get, "https://stg-api.edmodoqabranch.com/districts/21417",
|
|
99
|
+
:body => @district)
|
|
100
|
+
|
|
101
|
+
FakeWeb.register_uri(:get, "https://stg-api.edmodoqabranch.com/districts", :body => @districts)
|
|
102
|
+
|
|
103
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OneEye::Base do
|
|
4
|
+
it "finds by id" do
|
|
5
|
+
expect(OneEye::District.find(21417).id).to eq(21417)
|
|
6
|
+
expect(OneEye::School.find(334517).id).to eq(334517)
|
|
7
|
+
expect(OneEye::User.find(34954995).id).to eq(34954995)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "finds with a hash of options" do
|
|
11
|
+
expect(OneEye::District.find(:id => 21417).id).to eq(21417)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "finds a collection of models using where" do
|
|
15
|
+
expect(OneEye::District.where.first.id).to eq(1)
|
|
16
|
+
expect(OneEye::School.where.first.id).to eq(1)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "uses params to query with where" do
|
|
20
|
+
@schools = OneEye::School.where(:district_id => 21417)
|
|
21
|
+
expect(@schools.first.abbreviated_name).to eq("OVOXO")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Commented out to avoid creating a bunch of instances
|
|
25
|
+
# describe "Creating and destroying" do
|
|
26
|
+
# before(:each) do
|
|
27
|
+
# @district = OneEye::District.create(:name => "YMCMB District")
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
# it "creates instance via a backend post" do
|
|
31
|
+
# expect(@district.name).to eq("YMCMB District")
|
|
32
|
+
# @district.destroy
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
# it "destroys instances" do
|
|
36
|
+
# expect(@district.destroy).to eq("")
|
|
37
|
+
# end
|
|
38
|
+
# end
|
|
39
|
+
|
|
40
|
+
it "updates instances" do
|
|
41
|
+
@district = OneEye::District.new(:id => 21417)
|
|
42
|
+
expect(@district.update(:motto => "Get Money Get Paid").motto).to eq("Get Money Get Paid")
|
|
43
|
+
|
|
44
|
+
@school = OneEye::School.new(:id => 334517)
|
|
45
|
+
expect(@school.update(:motto => "Get Money Get Paid").motto).to eq("Get Money Get Paid")
|
|
46
|
+
|
|
47
|
+
@user = OneEye::User.new(:id => 34954995)
|
|
48
|
+
expect(@user.update(:verified_institution_member => true).verified_institution_member).to eq(true)
|
|
49
|
+
end
|
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/test/helper.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
metadata
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: one-eye-eater
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Brett Shollenberger
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: shoulda
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rdoc
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.12'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.12'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: jeweler
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 2.0.1
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 2.0.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: fakeweb
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rspec
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: httparty
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: guard
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: guard-rspec
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: activemodel
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: pry
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
181
|
+
description: Create, read, update, and destroy Edmodo data via the One Eye API.
|
|
182
|
+
email: brett.shollenberger@gmail.com
|
|
183
|
+
executables: []
|
|
184
|
+
extensions: []
|
|
185
|
+
extra_rdoc_files:
|
|
186
|
+
- LICENSE.txt
|
|
187
|
+
- README.rdoc
|
|
188
|
+
files:
|
|
189
|
+
- ".document"
|
|
190
|
+
- ".rspec"
|
|
191
|
+
- Gemfile
|
|
192
|
+
- Gemfile.lock
|
|
193
|
+
- Guardfile
|
|
194
|
+
- LICENSE.txt
|
|
195
|
+
- README.rdoc
|
|
196
|
+
- Rakefile
|
|
197
|
+
- VERSION
|
|
198
|
+
- lib/api.rb
|
|
199
|
+
- lib/models/base.rb
|
|
200
|
+
- lib/models/district.rb
|
|
201
|
+
- lib/models/school.rb
|
|
202
|
+
- lib/models/user.rb
|
|
203
|
+
- lib/one_eye.rb
|
|
204
|
+
- spec/mock_urls.rb
|
|
205
|
+
- spec/models/base_spec.rb
|
|
206
|
+
- spec/one_eye_spec.rb
|
|
207
|
+
- spec/spec_helper.rb
|
|
208
|
+
- test/helper.rb
|
|
209
|
+
- test/test_one_eye.rb
|
|
210
|
+
homepage: http://github.com/brettshollenberger/one-eye-eater
|
|
211
|
+
licenses:
|
|
212
|
+
- MIT
|
|
213
|
+
metadata: {}
|
|
214
|
+
post_install_message:
|
|
215
|
+
rdoc_options: []
|
|
216
|
+
require_paths:
|
|
217
|
+
- lib
|
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
|
+
requirements:
|
|
220
|
+
- - ">="
|
|
221
|
+
- !ruby/object:Gem::Version
|
|
222
|
+
version: '0'
|
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
|
+
requirements:
|
|
225
|
+
- - ">="
|
|
226
|
+
- !ruby/object:Gem::Version
|
|
227
|
+
version: '0'
|
|
228
|
+
requirements: []
|
|
229
|
+
rubyforge_project:
|
|
230
|
+
rubygems_version: 2.2.2
|
|
231
|
+
signing_key:
|
|
232
|
+
specification_version: 4
|
|
233
|
+
summary: One Eye API client
|
|
234
|
+
test_files: []
|