schoolfinder 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/schoolfinder.gemspec +84 -0
- metadata +13 -5
- data/lib/rash.rb +0 -67
- data/spec/rash_spec.rb +0 -63
data/Rakefile
CHANGED
@@ -12,6 +12,7 @@ begin
|
|
12
12
|
gem.authors = ["tcocca"]
|
13
13
|
gem.add_dependency "httparty", ">= 0.6.1"
|
14
14
|
gem.add_dependency "hashie", ">= 0.3.1"
|
15
|
+
gem.add_dependency "rash", ">= 0.1.1"
|
15
16
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
16
17
|
gem.add_development_dependency "webmock", ">= 1.3.4"
|
17
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{schoolfinder}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["tcocca"]
|
12
|
+
s.date = %q{2010-08-26}
|
13
|
+
s.description = %q{api wrapper for the education.com schoolfinder}
|
14
|
+
s.email = %q{tom.cocca@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/schoolfinder.rb",
|
27
|
+
"lib/schoolfinder/client.rb",
|
28
|
+
"lib/schoolfinder/error.rb",
|
29
|
+
"lib/schoolfinder/response.rb",
|
30
|
+
"schoolfinder.gemspec",
|
31
|
+
"spec/responses/branding_data.json",
|
32
|
+
"spec/responses/district_search.json",
|
33
|
+
"spec/responses/failure.json",
|
34
|
+
"spec/responses/number_of.json",
|
35
|
+
"spec/responses/reviews.json",
|
36
|
+
"spec/responses/school_search.json",
|
37
|
+
"spec/responses/student_diversity.json",
|
38
|
+
"spec/responses/student_stats.json",
|
39
|
+
"spec/responses/teacher_stats.json",
|
40
|
+
"spec/responses/test_rating.json",
|
41
|
+
"spec/responses/test_scores.json",
|
42
|
+
"spec/schoolfinder/client_spec.rb",
|
43
|
+
"spec/schoolfinder/error_spec.rb",
|
44
|
+
"spec/schoolfinder_api_key.example.yml",
|
45
|
+
"spec/spec.opts",
|
46
|
+
"spec/spec_helper.rb"
|
47
|
+
]
|
48
|
+
s.homepage = %q{http://github.com/tcocca/schoolfinder}
|
49
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
50
|
+
s.require_paths = ["lib"]
|
51
|
+
s.rubygems_version = %q{1.3.5}
|
52
|
+
s.summary = %q{api wrapper for the education.com schoolfinder}
|
53
|
+
s.test_files = [
|
54
|
+
"spec/schoolfinder/client_spec.rb",
|
55
|
+
"spec/schoolfinder/error_spec.rb",
|
56
|
+
"spec/spec_helper.rb"
|
57
|
+
]
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
+
s.specification_version = 3
|
62
|
+
|
63
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
65
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0.3.1"])
|
66
|
+
s.add_runtime_dependency(%q<rash>, [">= 0.1.1"])
|
67
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
68
|
+
s.add_development_dependency(%q<webmock>, [">= 1.3.4"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
71
|
+
s.add_dependency(%q<hashie>, [">= 0.3.1"])
|
72
|
+
s.add_dependency(%q<rash>, [">= 0.1.1"])
|
73
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
74
|
+
s.add_dependency(%q<webmock>, [">= 1.3.4"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
78
|
+
s.add_dependency(%q<hashie>, [">= 0.3.1"])
|
79
|
+
s.add_dependency(%q<rash>, [">= 0.1.1"])
|
80
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
81
|
+
s.add_dependency(%q<webmock>, [">= 1.3.4"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schoolfinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tcocca
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-08-
|
12
|
+
date: 2010-08-26 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.3.1
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rash
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.1
|
44
|
+
version:
|
35
45
|
- !ruby/object:Gem::Dependency
|
36
46
|
name: rspec
|
37
47
|
type: :development
|
@@ -68,12 +78,11 @@ files:
|
|
68
78
|
- README.rdoc
|
69
79
|
- Rakefile
|
70
80
|
- VERSION
|
71
|
-
- lib/rash.rb
|
72
81
|
- lib/schoolfinder.rb
|
73
82
|
- lib/schoolfinder/client.rb
|
74
83
|
- lib/schoolfinder/error.rb
|
75
84
|
- lib/schoolfinder/response.rb
|
76
|
-
-
|
85
|
+
- schoolfinder.gemspec
|
77
86
|
- spec/responses/branding_data.json
|
78
87
|
- spec/responses/district_search.json
|
79
88
|
- spec/responses/failure.json
|
@@ -119,7 +128,6 @@ signing_key:
|
|
119
128
|
specification_version: 3
|
120
129
|
summary: api wrapper for the education.com schoolfinder
|
121
130
|
test_files:
|
122
|
-
- spec/rash_spec.rb
|
123
131
|
- spec/schoolfinder/client_spec.rb
|
124
132
|
- spec/schoolfinder/error_spec.rb
|
125
133
|
- spec/spec_helper.rb
|
data/lib/rash.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
# Converts all of the keys to strings, optionally formatting key name
|
4
|
-
def rubyify_keys!
|
5
|
-
keys.each{ |k|
|
6
|
-
v = delete(k)
|
7
|
-
new_key = k.to_s.to_underscore!
|
8
|
-
self[new_key] = v
|
9
|
-
v.rubyify_keys! if v.is_a?(Hash)
|
10
|
-
v.each{|p| p.rubyify_keys! if p.is_a?(Hash)} if v.is_a?(Array)
|
11
|
-
}
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
class String
|
18
|
-
|
19
|
-
# converts a camel_cased string to a underscore string
|
20
|
-
# Same way ActiveSupport does string.underscore
|
21
|
-
def to_underscore!
|
22
|
-
self.to_s.gsub(/::/, '/').
|
23
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
24
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
25
|
-
tr("-", "_").
|
26
|
-
downcase
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
module Hashie
|
32
|
-
|
33
|
-
class Rash < Mash
|
34
|
-
|
35
|
-
def initialize(source_hash = nil, default = nil, &blk)
|
36
|
-
if source_hash
|
37
|
-
source_hash.rubyify_keys!
|
38
|
-
deep_update(source_hash)
|
39
|
-
end
|
40
|
-
default ? super(default) : super(&blk)
|
41
|
-
end
|
42
|
-
|
43
|
-
def initializing_reader(key)
|
44
|
-
ck = convert_key(key)
|
45
|
-
regular_writer(ck, Hashie::Rash.new) unless key?(ck)
|
46
|
-
regular_reader(ck)
|
47
|
-
end
|
48
|
-
|
49
|
-
protected
|
50
|
-
|
51
|
-
def convert_value(val, duping=false) #:nodoc:
|
52
|
-
case val
|
53
|
-
when ::Hashie::Rash
|
54
|
-
val.dup
|
55
|
-
when ::Hash
|
56
|
-
val = val.dup if duping
|
57
|
-
self.class.new(val)
|
58
|
-
when Array
|
59
|
-
val.collect{ |e| convert_value(e) }
|
60
|
-
else
|
61
|
-
val
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
data/spec/rash_spec.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Rash" do
|
4
|
-
|
5
|
-
context "string extensions" do
|
6
|
-
before do
|
7
|
-
@camel_case_strings = ["camelCase", "CamelCase", "stringTwoHumps", "StringHasThreeHumps"]
|
8
|
-
@underscore_strings = ["camel_case", "camel_case", "string_two_humps", "string_has_three_humps"]
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should convert camelcase strings to underscored strings" do
|
12
|
-
@camel_case_strings.collect{|s| s.to_underscore!}.should == @underscore_strings
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "hash extensions" do
|
17
|
-
before do
|
18
|
-
@hash1 = {"testOne" => "1", "TestTwo" => "2", :testThree => 3, :TestFour => 4, :testFiveSix => 56}
|
19
|
-
@hash1.rubyify_keys!
|
20
|
-
@hash2 = {"test_one" => "1", "test_two" => "2", "test_three" => 3, "test_four" => 4, "test_five_six" => 56}
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should convert camel case-ed keys to underscore-ed keys" do
|
24
|
-
@hash1.should == @hash2
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "rash" do
|
29
|
-
before do
|
30
|
-
@original_hash = {
|
31
|
-
"varOne" => 1,
|
32
|
-
"two" => 2,
|
33
|
-
:three => 3,
|
34
|
-
:varFour => 4,
|
35
|
-
"fiveHumpHumps" => 5,
|
36
|
-
:nested => {
|
37
|
-
"NestedOne" => "One",
|
38
|
-
:two => "two",
|
39
|
-
"nested_three" => "three"
|
40
|
-
},
|
41
|
-
"nestedTwo" => {
|
42
|
-
"nested_two" => 22,
|
43
|
-
:nestedThree => 23
|
44
|
-
}
|
45
|
-
}
|
46
|
-
@rash = Hashie::Rash.new(@original_hash)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should create a new rash where all the keys are underscored instead of camelcased" do
|
50
|
-
@rash.var_one.should == 1
|
51
|
-
@rash.two.should == 2
|
52
|
-
@rash.three.should == 3
|
53
|
-
@rash.var_four.should == 4
|
54
|
-
@rash.five_hump_humps.should == 5
|
55
|
-
@rash.nested.nested_one.should == "One"
|
56
|
-
@rash.nested.two.should == "two"
|
57
|
-
@rash.nested.nested_three.should == "three"
|
58
|
-
@rash.nested_two.nested_two.should == 22
|
59
|
-
@rash.nested_two.nested_three.should == 23
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|