me2api-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -5
- data/Gemfile.lock +4 -4
- data/README.md +12 -2
- data/lib/me2api/api.rb +0 -5
- data/lib/me2api/model.rb +5 -13
- data/lib/me2api/version.rb +1 -1
- data/me2api-ruby.gemspec +5 -0
- data/test/model_test.rb +34 -0
- metadata +71 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,6 +2,10 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
me2api-ruby (0.1.0)
|
5
|
+
curb (~> 0.8.0)
|
6
|
+
json (~> 1.7.3)
|
7
|
+
rake (~> 0.8.3)
|
8
|
+
tzinfo (~> 0.3.33)
|
5
9
|
|
6
10
|
GEM
|
7
11
|
remote: http://rubygems.org/
|
@@ -15,8 +19,4 @@ PLATFORMS
|
|
15
19
|
ruby
|
16
20
|
|
17
21
|
DEPENDENCIES
|
18
|
-
curb (~> 0.8.0)
|
19
|
-
json (~> 1.7.3)
|
20
22
|
me2api-ruby!
|
21
|
-
rake (~> 0.8.3)
|
22
|
-
tzinfo (~> 0.3.33)
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ A Ruby wrapper for the Me2day API.
|
|
17
17
|
:apikey => APIKEY
|
18
18
|
)
|
19
19
|
|
20
|
-
post = api.create_post(USER_ID, 'hello world')
|
20
|
+
post = api.create_post(USER_ID, 'hello world', :tag => 'blah blah')
|
21
21
|
|
22
22
|
참고자료
|
23
23
|
=======
|
@@ -45,7 +45,17 @@ For more information, see http://unlicense.org/ or the accompanying UNLICENSE fi
|
|
45
45
|
ChangeLog
|
46
46
|
=========
|
47
47
|
|
48
|
-
## 0.1(2012-06-
|
48
|
+
## 0.1.1 (2012-06-29)
|
49
|
+
|
50
|
+
Features:
|
51
|
+
|
52
|
+
- gemspec 파일에 dependency 추가
|
53
|
+
|
54
|
+
Bugfixes:
|
55
|
+
|
56
|
+
- Model 객체에서 존재하지 않는 속성을 접근할 때 nil이 반환되지 않는 문제 수정
|
57
|
+
|
58
|
+
## 0.1.0 (2012-06-27)
|
49
59
|
|
50
60
|
First release.
|
51
61
|
|
data/lib/me2api/api.rb
CHANGED
data/lib/me2api/model.rb
CHANGED
@@ -1,30 +1,22 @@
|
|
1
1
|
module Me2API
|
2
2
|
class Model < Hash
|
3
3
|
def initialize(hash)
|
4
|
-
super
|
5
4
|
hash.keys.each { |key| self[key] = hash[key] }
|
6
5
|
end
|
7
6
|
|
8
|
-
def wrap(value)
|
7
|
+
def self.wrap(value)
|
9
8
|
if value.is_a?(Hash) && !value.is_a?(Me2API::Model)
|
10
9
|
Model.new(value)
|
10
|
+
elsif value.is_a?(Array)
|
11
|
+
value.map { |v| wrap(v) }
|
11
12
|
else
|
12
13
|
value
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
16
|
-
def [](key)
|
17
|
-
key = underscore(key.to_s)
|
18
|
-
if has_key?(key)
|
19
|
-
super(key)
|
20
|
-
else
|
21
|
-
super(key.to_sym)
|
22
|
-
end
|
23
|
-
end
|
24
16
|
|
25
17
|
def []=(key, value)
|
26
18
|
key = underscore(key.to_s).to_sym
|
27
|
-
super(key, wrap(value))
|
19
|
+
super(key, Model.wrap(value))
|
28
20
|
end
|
29
21
|
|
30
22
|
def id
|
@@ -32,7 +24,7 @@ module Me2API
|
|
32
24
|
end
|
33
25
|
|
34
26
|
def method_missing(name, *args, &block)
|
35
|
-
self[name]
|
27
|
+
self[name.to_sym]
|
36
28
|
end
|
37
29
|
|
38
30
|
FROM_OR_TO_REGEX = /(\d{4}\-\d{1,2}-\d{1,2}[T|\s]\d{1,2}\:\d{1,2}\:\d{1,2})([\+|\s])(\d{2}\:{0,}\d{2})/
|
data/lib/me2api/version.rb
CHANGED
data/me2api-ruby.gemspec
CHANGED
@@ -19,4 +19,9 @@ me2api-ruby is a ruby library for the me2API}
|
|
19
19
|
s.email = ["codian@gmail.com"]
|
20
20
|
|
21
21
|
s.homepage = "https://github.com/me2day/me2api-ruby"
|
22
|
+
|
23
|
+
s.add_runtime_dependency "rake", "~> 0.8.3"
|
24
|
+
s.add_runtime_dependency "tzinfo", "~> 0.3.33"
|
25
|
+
s.add_runtime_dependency "json", "~> 1.7.3"
|
26
|
+
s.add_runtime_dependency "curb", "~> 0.8.0"
|
22
27
|
end
|
data/test/model_test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class ModelTest < Test::Unit::TestCase
|
4
|
+
include Me2APICommon
|
5
|
+
|
6
|
+
def test_wrap_hash
|
7
|
+
hash = Me2API::Model.wrap('KeyOne' => 'value1')
|
8
|
+
|
9
|
+
assert_kind_of(Me2API::Model, hash)
|
10
|
+
assert_equal('value1', hash[:key_one])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_wrap_hash_in_array
|
14
|
+
arr = Me2API::Model.wrap([
|
15
|
+
{ 'KeyOne' => 'value1' },
|
16
|
+
{ 'keyTwo' => 'value2' }
|
17
|
+
])
|
18
|
+
|
19
|
+
assert_kind_of(Array, arr)
|
20
|
+
assert_kind_of(Me2API::Model, arr[0])
|
21
|
+
assert_equal('value1', arr[0][:key_one])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_wrap_simple_value
|
25
|
+
val = Me2API::Model.wrap('hello')
|
26
|
+
assert_kind_of(String, val)
|
27
|
+
assert_equal('hello', val)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_access_not_exist_attribute
|
31
|
+
hash = Me2API::Model.wrap('KeyOne' => 'value1')
|
32
|
+
assert_nil(hash.not_exist_attribute)
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: me2api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Heungseok Do
|
@@ -15,9 +15,72 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
19
|
-
dependencies:
|
20
|
-
|
18
|
+
date: 2012-06-29 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 57
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 8
|
32
|
+
- 3
|
33
|
+
version: 0.8.3
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: tzinfo
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 81
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 3
|
48
|
+
- 33
|
49
|
+
version: 0.3.33
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: json
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 13
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 7
|
64
|
+
- 3
|
65
|
+
version: 1.7.3
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: curb
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 63
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 8
|
80
|
+
- 0
|
81
|
+
version: 0.8.0
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id004
|
21
84
|
description: |-
|
22
85
|
me2API is OpenAPI of me2day.
|
23
86
|
me2api-ruby is a ruby library for the me2API
|
@@ -52,6 +115,7 @@ files:
|
|
52
115
|
- me2api-ruby.gemspec
|
53
116
|
- test/agent_test.rb
|
54
117
|
- test/api_test.rb
|
118
|
+
- test/model_test.rb
|
55
119
|
- test/test.png
|
56
120
|
- test/test_helper.rb
|
57
121
|
homepage: https://github.com/me2day/me2api-ruby
|
@@ -90,4 +154,5 @@ summary: A Ruby wrapper for the Me2day API
|
|
90
154
|
test_files:
|
91
155
|
- test/agent_test.rb
|
92
156
|
- test/api_test.rb
|
157
|
+
- test/model_test.rb
|
93
158
|
has_rdoc:
|