one-eye-eater 0.1.15 → 0.1.16
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 +4 -4
- data/README.rdoc +11 -0
- data/VERSION +1 -1
- data/lib/api.rb +0 -5
- data/lib/models/base.rb +24 -14
- data/lib/models/insights/insights.rb +4 -0
- data/lib/models/insights/snapshot_performance.rb +8 -0
- data/lib/models/insights/snapshot_suggested_group.rb +8 -0
- data/lib/models/insights/snapshot_usage.rb +8 -0
- data/one-eye-eater.gemspec +6 -2
- data/spec/models/base_spec.rb +17 -15
- data/spec/one_eye_spec.rb +3 -3
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 558d9909a9a19fd930477d0137809fd1f11ae8c5
|
|
4
|
+
data.tar.gz: 41687a9806bec3099fff52e72d4403cbb53fa5cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa5e819f78446938e5f2c5d545f5021ef7133d5eff7fab98ddf02b7ec9d7e9dd58be5c6e0418814539d2b5d1cac219992ae9ecf933bba78b6512657bb3ce385f
|
|
7
|
+
data.tar.gz: c0644a620b026830a392803c866ab8644e45a41278c8f370fe36cf21f179f68998dad95b2fefdff17c10c54d046005fc2e54e89dded0e1878a7eb3aff2ccfd9b
|
data/README.rdoc
CHANGED
|
@@ -27,6 +27,17 @@ For traditional, RESTful endpoints, use Rails-style CRUD actions:
|
|
|
27
27
|
@district = OneEye::District.find(1)
|
|
28
28
|
@district.destroy
|
|
29
29
|
|
|
30
|
+
== Dynamic Dispatch
|
|
31
|
+
|
|
32
|
+
For endpoints with custom aggregation options, One Eye Eater classes will dynamically dispatch
|
|
33
|
+
methods called on them as custom finders:
|
|
34
|
+
|
|
35
|
+
# GET /insights/snapshot_performance/schools
|
|
36
|
+
OneEye::Insights::SnapshotPerformance.schools(:district_id => 1)
|
|
37
|
+
|
|
38
|
+
# GET /insights/snapshot_usage/districts
|
|
39
|
+
OneEye::Insights::SnapshotUsage.districts(:assessment_area => "CCSS.ELA", :district_id => 1)
|
|
40
|
+
|
|
30
41
|
== Copyright
|
|
31
42
|
|
|
32
43
|
Copyright (c) 2014 Edmodo. See LICENSE.txt for
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.16
|
data/lib/api.rb
CHANGED
|
@@ -46,16 +46,11 @@ module OneEye
|
|
|
46
46
|
|
|
47
47
|
def standardize_request(http_method, name, options)
|
|
48
48
|
name = "/#{name}"
|
|
49
|
-
# name = slash_name(name)
|
|
50
49
|
options = standardize_options(options)
|
|
51
50
|
name += "/#{options[:id]}" if options.keys.include? :id
|
|
52
51
|
[name, options]
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
def slash_name(name)
|
|
56
|
-
"/#{name.to_s.gsub(/\_/) { "/" }}"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
54
|
def standardize_options(options={})
|
|
60
55
|
if options.class == Fixnum
|
|
61
56
|
options = {id: options}
|
data/lib/models/base.rb
CHANGED
|
@@ -23,12 +23,6 @@ module OneEye
|
|
|
23
23
|
eos
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def make_array_convertable(attrs)
|
|
27
|
-
def attrs.to_hash
|
|
28
|
-
Hash[self.each_slice(2).to_a]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
26
|
def attributes=(attrs)
|
|
33
27
|
make_array_convertable attrs if attrs.is_a? Array
|
|
34
28
|
attrs.to_hash.each { |k, v| send "#{k}=", v }
|
|
@@ -70,6 +64,23 @@ module OneEye
|
|
|
70
64
|
destroy
|
|
71
65
|
end
|
|
72
66
|
|
|
67
|
+
private
|
|
68
|
+
def self.resources_url
|
|
69
|
+
self.name.gsub(/\w+\:\:/) {}.underscore.downcase.pluralize
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.method_missing(name, *args, &block)
|
|
73
|
+
missing_finder name, *args, &block
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def method_missing(name, *args, &block)
|
|
77
|
+
if name[-1] == "="
|
|
78
|
+
return instance_variable_set "@#{name[0..-2]}", args[0]
|
|
79
|
+
else
|
|
80
|
+
instance_variable_get "@#{name}"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
73
84
|
def non_nil_attributes
|
|
74
85
|
instance_variables.inject Hash.new do |obj, key|
|
|
75
86
|
obj[key.to_s[1..-1].to_sym] = instance_variable_get(key) unless instance_variable_get(key).nil?
|
|
@@ -85,16 +96,15 @@ module OneEye
|
|
|
85
96
|
self.class.resources_url
|
|
86
97
|
end
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
def self.missing_finder(name, *args, &block)
|
|
100
|
+
@models = api.get("#{self.name.gsub(/OneEye\:\:/) {}.underscore}/#{name.to_s.underscore}", *args)
|
|
101
|
+
return @models.map { |model| new model } if @models.map
|
|
102
|
+
new @models
|
|
91
103
|
end
|
|
92
104
|
|
|
93
|
-
def
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
else
|
|
97
|
-
instance_variable_get "@#{name}"
|
|
105
|
+
def make_array_convertable(attrs)
|
|
106
|
+
def attrs.to_hash
|
|
107
|
+
Hash[self.each_slice(2).to_a]
|
|
98
108
|
end
|
|
99
109
|
end
|
|
100
110
|
end
|
data/one-eye-eater.gemspec
CHANGED
|
@@ -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.
|
|
5
|
+
# stub: one-eye-eater 0.1.16 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "one-eye-eater"
|
|
9
|
-
s.version = "0.1.
|
|
9
|
+
s.version = "0.1.16"
|
|
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"]
|
|
@@ -33,6 +33,10 @@ Gem::Specification.new do |s|
|
|
|
33
33
|
"lib/models/district.rb",
|
|
34
34
|
"lib/models/group.rb",
|
|
35
35
|
"lib/models/group_membership.rb",
|
|
36
|
+
"lib/models/insights/insights.rb",
|
|
37
|
+
"lib/models/insights/snapshot_performance.rb",
|
|
38
|
+
"lib/models/insights/snapshot_suggested_group.rb",
|
|
39
|
+
"lib/models/insights/snapshot_usage.rb",
|
|
36
40
|
"lib/models/school.rb",
|
|
37
41
|
"lib/models/user.rb",
|
|
38
42
|
"lib/one-eye-eater.rb",
|
data/spec/models/base_spec.rb
CHANGED
|
@@ -32,26 +32,28 @@ describe OneEye::Base do
|
|
|
32
32
|
expect(@schools.first.name).to eq("October's Very Own Academy")
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
it "dynamically dispatches custom finders", :finders do
|
|
36
|
+
expect(OneEye::Insights::SnapshotUsage.districts(:district_id => 22037).first.num_teachers).to eq(5)
|
|
37
|
+
expect(OneEye::Insights::SnapshotPerformance.schools(:district_id => 22037,
|
|
38
|
+
:assessment_area => "CCSS.ELA")
|
|
39
|
+
.first.progress_percent).to eq(2.7)
|
|
40
|
+
end
|
|
41
|
+
|
|
35
42
|
it "sets attributes", :attributes do
|
|
36
43
|
@school = OneEye::School.new :city => "Philly", :state => "PA"
|
|
37
44
|
expect(@school.attributes).to eq({"city" => "Philly", "state" => "PA"})
|
|
38
45
|
end
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# it "destroys instances" do
|
|
52
|
-
# expect(@district.destroy).to eq("")
|
|
53
|
-
# end
|
|
54
|
-
# end
|
|
47
|
+
describe "Creating and destroying" do
|
|
48
|
+
before(:each) do
|
|
49
|
+
@district = OneEye::District.create(:name => "YMCMB District")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "creates instance via a backend post" do
|
|
53
|
+
expect(@district.name).to eq("YMCMB District")
|
|
54
|
+
@district.destroy
|
|
55
|
+
end
|
|
56
|
+
end
|
|
55
57
|
|
|
56
58
|
it "updates instances", :create do
|
|
57
59
|
@district = OneEye::District.new(:id => 22037)
|
data/spec/one_eye_spec.rb
CHANGED
|
@@ -4,7 +4,7 @@ describe OneEye do
|
|
|
4
4
|
|
|
5
5
|
StagingAPI = OneEye::API.new
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
it "translates method calls into urls", :dynamic_method do
|
|
8
|
+
expect(StagingAPI.districts(21417).parsed_response["id"]).to eq(21417)
|
|
9
|
+
end
|
|
10
10
|
end
|
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.
|
|
4
|
+
version: 0.1.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Shollenberger
|
|
@@ -200,6 +200,10 @@ files:
|
|
|
200
200
|
- lib/models/district.rb
|
|
201
201
|
- lib/models/group.rb
|
|
202
202
|
- lib/models/group_membership.rb
|
|
203
|
+
- lib/models/insights/insights.rb
|
|
204
|
+
- lib/models/insights/snapshot_performance.rb
|
|
205
|
+
- lib/models/insights/snapshot_suggested_group.rb
|
|
206
|
+
- lib/models/insights/snapshot_usage.rb
|
|
203
207
|
- lib/models/school.rb
|
|
204
208
|
- lib/models/user.rb
|
|
205
209
|
- lib/one-eye-eater.rb
|