rme2day 1.0.0

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.
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ == 1.0.0 / 2007-08-28
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/rme2day.rb
6
+ spec/api_spec.rb
7
+ spec/person_spec.rb
8
+ spec/post_spec.rb
9
+ spec/post_xml.rb
10
+ spec/settings_spec.rb
11
+ spec/settings_xml.rb
12
+ spec/setup.rb.sample
data/README.txt ADDED
@@ -0,0 +1,65 @@
1
+ rme2day
2
+ by Junghyun Kim
3
+ http://ikspres.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ ME2DAY(http://me2day.net) open-api library
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * read/write posts
12
+ * read/write comments for posts
13
+ * read/write user info
14
+
15
+ == SYNOPSIS:
16
+
17
+ With this library, you can to this.
18
+
19
+ Person.get('codian').recent_posts.first.comments.last.person.friends.size
20
+
21
+ Or,
22
+
23
+ codian = Person.get('codian')
24
+ newest = codian.newest_post
25
+ newest.print
26
+ newest.add_comment('Wonderful~~')
27
+
28
+ ( 10 minutes later, hmm.. you may be a big fan, or stalker, of codian )
29
+
30
+ codian.reload
31
+ codian.newest_post.print
32
+
33
+ == REQUIREMENTS:
34
+
35
+ * hpricot gem >= 0.6
36
+ * open-uri gem
37
+
38
+ == INSTALL:
39
+
40
+ * sudo gem install
41
+
42
+ == LICENSE:
43
+
44
+ (The MIT License)
45
+
46
+ Copyright (c) 2007 FIX
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ 'Software'), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/rme2day.rb'
6
+
7
+ Hoe.new('rme2day', Rme2day::VERSION) do |p|
8
+ p.rubyforge_name = 'ikspres'
9
+ # p.author = 'ikspres'
10
+ # p.email = 'dev@ikspres.com'
11
+ # p.summary = 'me2day(http://me2day.net) service api libraray'
12
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ end
16
+
17
+ # vim: syntax=Ruby
data/lib/rme2day.rb ADDED
@@ -0,0 +1,86 @@
1
+ # Me2day API Libraray (ver 0.1)
2
+ #
3
+ # http://me2day.net/
4
+ #
5
+ # Author: ikspres (mail@ikspres.com)
6
+ # Modified: 2007.06.30
7
+ # License: Same as Ruby License
8
+ #
9
+ #
10
+ #= Usage
11
+ #
12
+ #== Setup (not needed if used only for reading posts and comments)
13
+ #
14
+ # Rme2day::API.setup('your id', 'user key', 'app key')
15
+ # or
16
+ # Rme2day::API.setup('your id', 'user key', 'app key', 'euckr') # if you want to print in EUC-KR
17
+ #
18
+ # (Notice! Rme2day::set_credential() is deprecated)
19
+ #
20
+ #== Get lastest posts of a user, and comments for each post
21
+ #
22
+ # posts = Rme2day::Post.find_latests('codian')
23
+ # posts.each do |post|
24
+ # puts post.body
25
+ # puts post.kind
26
+ # puts post.datetime
27
+ # puts post.permalink
28
+ # puts post.person_id
29
+ #
30
+ # (or, to be simple)
31
+ # puts post
32
+ #
33
+ # (or, to be greedy)
34
+ # post.print
35
+ #
36
+ # post.comments.each do |comment|
37
+ # puts comment.body
38
+ # puts comment.datetime
39
+ # puts comment.person_id
40
+ #
41
+ # (or, to be simple)
42
+ # puts comment
43
+ # end
44
+ #
45
+ # author_id = post.person_id
46
+ # author = post.person # see below for Person
47
+ # end
48
+ #
49
+ #== Write a Post (set_credential needed before this)
50
+ # post = Rme2day::Post.create ('hello world', 'greetings test', 1)
51
+ #
52
+ #
53
+ #== Get Person and friends
54
+ # codian = Rme2day::Person.get('codian') # get user directly with id, or
55
+ # puts codian.id
56
+ # puts codian.nickname
57
+ # ... # see me2day api document for more attributes
58
+ #
59
+ # codian.friends.each do |friend| # each friend is also an object of Person
60
+ # puts firends.id
61
+ # puts firends.nickname
62
+ # ...
63
+ # end
64
+ #
65
+ #
66
+ #== Get Settings (set_credential needed before this)
67
+ #
68
+ # my_settings = Rme2day::Settings.get
69
+ #
70
+
71
+
72
+ module Rme2day
73
+ VERSION = '1.0.0'
74
+ end
75
+
76
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
77
+
78
+ require 'rme2day/util'
79
+ require 'rme2day/api'
80
+ require 'rme2day/tag'
81
+ require 'rme2day/record'
82
+ require 'rme2day/post'
83
+ require 'rme2day/comment'
84
+ require 'rme2day/person'
85
+ require 'rme2day/settings'
86
+
data/spec/api_spec.rb ADDED
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../lib/rme2day'
2
+ require File.dirname(__FILE__) + '/post_xml'
3
+
4
+ module CheckResult
5
+ def check_result(result, options)
6
+ doc = Hpricot result
7
+ doc.should be_an_instance_of(Hpricot::Doc)
8
+
9
+ options.each do |k, v|
10
+ doc.at(k.to_s).inner_html.should == v if v.class == String
11
+ doc.at(k.to_s).inner_html.should =~ v if v.class == Regexp
12
+ end
13
+ return doc
14
+ end
15
+ end
16
+
17
+ describe Rme2day::API, "with get_lastest" do
18
+ include PostXml
19
+ include CheckResult
20
+
21
+ it "should build a appropriate url for get" do
22
+ url = Rme2day::API.latests_post_url 'codian'
23
+ url.should == 'http://me2day.net/api/get_latests/codian.xml'
24
+ end
25
+
26
+ it "should get real xml" do
27
+ result = Rme2day::API.do_open('http://me2day.net/api/get_latests/codian.xml')
28
+ check_result(result, {:id => 'codian'})
29
+ end
30
+
31
+ it "should get a latest posts of a user" do
32
+ Rme2day::API.should_receive(:do_open).and_return(generate_simple_posts_xml)
33
+ result = Rme2day::API.get_latests 'codian'
34
+ end
35
+ end
36
+
37
+
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../lib/rme2day'
2
+
3
+ describe Rme2day::Person, "with get" do
4
+ it "should create and read person info" do
5
+ me = Rme2day::Person.get('ikspres')
6
+ me.should be_an_instance_of(Rme2day::Person)
7
+ end
8
+ end
9
+
10
+ describe Rme2day::Person, "with friends" do
11
+ it "should return right get url" do
12
+ url = Rme2day::API.get_friends_url('ikspres', 'all')
13
+ url.should == 'http://me2day.net/api/get_friends/ikspres.xml?scope=all'
14
+ end
15
+
16
+
17
+ it "should get array of Person objects" do
18
+ me = Rme2day::Person.get('ikspres')
19
+ friends = me.friends
20
+ friends.should be_an_instance_of(Array)
21
+ friends[0].should be_an_instance_of(Rme2day::Person)
22
+ end
23
+ end
data/spec/post_spec.rb ADDED
@@ -0,0 +1,89 @@
1
+ require File.dirname(__FILE__) + '/../lib/rme2day'
2
+ require File.dirname(__FILE__) + '/post_xml'
3
+
4
+ require File.dirname(__FILE__) + '/setup' # make your own setup.rb
5
+
6
+
7
+ describe Rme2day::Post, "with find_latests" do
8
+ include PostXml
9
+
10
+ before(:each) do
11
+ Rme2day::API.should_receive(:do_open).and_return(generate_simple_posts_xml)
12
+ @posts = Rme2day::Post.find_latests('codian')
13
+ @post = @posts[0]
14
+ end
15
+
16
+ it "should return Post objects" do
17
+ @post.should be_an_instance_of(Rme2day::Post)
18
+ end
19
+
20
+ it "should get attributes thorouth special parsing : person_id, datetime " do
21
+ @post.person_id.should == 'codian'
22
+ @post.datetime.should == Time.gm(2007, 6, 30, 13, 3, 34)
23
+ end
24
+
25
+ it "should get attributes through method_missing : kind, body, permalink" do
26
+ @post.body.should =~ /body1/
27
+ @post.kind.should == 'think'
28
+ @post.permalink.should =~ /me2day.net/
29
+ end
30
+
31
+ it "should raise error for unknown tag element" do
32
+ lambda{@post.xyz.should == 'there is no tag xyz'}.should raise_error(NoMethodError)
33
+ end
34
+ end
35
+
36
+
37
+ describe Rme2day::Post, "with comments" do
38
+ before(:each) do
39
+ @post = Rme2day::Post.new
40
+ @post.stub!(:permalink).and_return("http://me2day.net/ruby2day/2007/05/16#21:34:48")
41
+ @comments = @post.comments
42
+ @comment = @comments[0]
43
+ end
44
+
45
+ it "should get comments" do
46
+ @comment.should be_an_instance_of(Rme2day::Comment)
47
+ end
48
+
49
+ it "should get comment attributes" do
50
+ @comment.body.should =~ /devil/
51
+ @comment.person_id.should == 'zendy'
52
+ end
53
+
54
+ end
55
+
56
+ describe Rme2day::Post, "with Person" do
57
+ before(:each) do
58
+ @post = Rme2day::Post.new
59
+ @post.stub!(:person_id).and_return("ikspres")
60
+ @person = @post.person
61
+ end
62
+
63
+ it "should get Person object" do
64
+ @person.should be_an_instance_of(Rme2day::Person)
65
+ end
66
+ end
67
+
68
+
69
+
70
+ describe Rme2day::Post, "with create" do
71
+ include PostXml
72
+
73
+ before(:each) do
74
+ @body = 'body1'
75
+ @tags = 'tag1 tag2'
76
+ @icon = 1
77
+ end
78
+
79
+ it "should make right url and parameters" do
80
+ params = Rme2day::API.create_post_params(@body, @tags, @icon)
81
+ params.should == '?post[body]=body1&post[tags]=tag1%20tag2&post[icon]=1'
82
+ end
83
+ it "should create and return result Post object" do
84
+ Rme2day::API.should_receive(:do_open).and_return(create_post_result_xml)
85
+ post = Rme2day::Post.create(@body, @tags, @icon)
86
+ post.should be_an_instance_of(Rme2day::Post)
87
+ end
88
+
89
+ end
data/spec/post_xml.rb ADDED
@@ -0,0 +1,97 @@
1
+ module PostXml
2
+ def generate_simple_posts_xml
3
+ xml = %{
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <posts>
6
+ <post>
7
+ <permalink>http://me2day.net/codian/2007/06/30#13:03:34</permalink>
8
+ <body>post body1</body>
9
+ <kind>think</kind>
10
+ <icon>http://me2day.net/images/post_think.gif</icon>
11
+ <tags>
12
+ <tag>
13
+ <name>tag1</name>
14
+ <url>http://me2day.net/codian/tag/tag1</url>
15
+ </tag>
16
+ </tags>
17
+ <me2dayPage>http://me2day.net/codian</me2dayPage>
18
+ <pubDate>2007-06-30T13:03:34Z</pubDate>
19
+ <commentsCount>30</commentsCount>
20
+ <metooCount>1</metooCount>
21
+ <author>
22
+ <id>codian</id>
23
+ <nickname>nick1</nickname>
24
+ <face>http://me2day.net/images/user/codian/profile.png</face>
25
+ <homepage>http://codian.net</homepage>
26
+ <me2dayHome>http://me2day.net/codian</me2dayHome>
27
+ </author>
28
+ </post>
29
+ <post>
30
+ <permalink>http://me2day.net/codian/2007/06/28#09:58:10</permalink>
31
+ <body>post body2</body>
32
+ <kind>think</kind>
33
+ <icon>http://me2day.net/images/post_think.gif</icon>
34
+ <tags>
35
+ <tag>
36
+ <name>tag1</name>
37
+ <url>http://me2day.net/codian/tag/tag1</url>
38
+ </tag>
39
+ <tag>
40
+ <name>tag2</name>
41
+ <url>http://me2day.net/codian/tag/tag2</url>
42
+ </tag>
43
+ </tags>
44
+ <me2dayPage>http://me2day.net/codian</me2dayPage>
45
+ <pubDate>2007-06-28T09:58:10Z</pubDate>
46
+ <commentsCount>18</commentsCount>
47
+ <metooCount>15</metooCount>
48
+ <author>
49
+ <id>codian</id>
50
+ <nickname>nick1</nickname>
51
+ <face>http://me2day.net/images/user/codian/profile.png</face>
52
+ <homepage>http://codian.net</homepage>
53
+ <me2dayHome>http://me2day.net/codian</me2dayHome>
54
+ </author>
55
+ </post>
56
+ </posts>
57
+ }
58
+ end
59
+
60
+ def create_post_result_xml
61
+ xml = %{
62
+ <?xml version="1.0" encoding="UTF-8"?>
63
+ <post>
64
+ <permalink>http://me2day.net/me2daytest/2007/04/22#01:17:16</permalink>
65
+ <body>&lt;a href="http://me2day.net"&gt;&#48120;&#53804;&#45936;&#51060;&lt;/a&gt;&#50640; &#44544;&#51012; &#50732;&#47549;&#45768;&#45796;.</body>
66
+ <kind>think</kind>
67
+ <icon>http://me2day.net/images/post_think.gif</icon>
68
+ <tags>
69
+ <tag>
70
+ <name>me2api</name>
71
+ <url>http://localhost:3000/me2daytest/tag/me2api</url>
72
+ </tag>
73
+ <tag>
74
+ <name>create_post</name>
75
+ <url>http://localhost:3000/me2daytest/tag/create_post</url>
76
+ </tag>
77
+ <tag>
78
+ <name>&#44544;&#50416;&#44592;</name>
79
+ <url>http://localhost:3000/me2daytest/tag/&#44544;&#50416;&#44592;</url>
80
+ </tag>
81
+ </tags>
82
+ <me2dayPage>http://me2day.net/me2daytest</me2dayPage>
83
+ <pubDate>2007-04-22T01:17:16Z</pubDate>
84
+ <commentsCount>0</commentsCount>
85
+ <metooCount>0</metooCount>
86
+ <author>
87
+ <id>me2daytest</id>
88
+ <nickname>&#48120;&#53804;&#45936;&#51060;</nickname>
89
+ <face>http://me2day.net/images/user/codian/&#54620;&#44544;&#51060;&#47492;.jpg</face>
90
+
91
+ <homepage>http://me2day.net</homepage>
92
+ <me2dayHome>http://me2day.net/me2daytest</me2dayHome>
93
+ </author>
94
+ </post>
95
+ }
96
+ end
97
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../lib/rme2day'
2
+ require File.dirname(__FILE__) + '/settings_xml'
3
+
4
+ require File.dirname(__FILE__) + '/setup' # make your own setup.rb
5
+
6
+
7
+
8
+
9
+ describe Rme2day::Settings, "with get" do
10
+ include SettingsXml
11
+
12
+ before(:each) do
13
+ Rme2day::API.should_receive(:do_open).and_return(simple_settings_xml)
14
+ @me = Rme2day::Settings.get('ikspres')
15
+
16
+ end
17
+
18
+ it "should get a Settings object" do
19
+ @me.should be_an_instance_of(Rme2day::Settings)
20
+ end
21
+
22
+ it "should have attributes mytags and decription" do
23
+ @me.mytags.should == 'tag1 tag2'
24
+ @me.description.should == 'description1'
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,12 @@
1
+ module SettingsXml
2
+ def simple_settings_xml
3
+ xml = %{
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <settings settingsOf="codian">
6
+ <mytags>tag1 tag2</mytags>
7
+ <mytagsInTab>&#53076;&#46356;&#50504; &#44396;&#44544;</mytags>
8
+ <description>description1</description>
9
+ </settings>
10
+ }
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ #
2
+ # !! YOU NEED TO EDIT THIS and rename as setup.rb !!
3
+ # To use your own user id, user key and application key
4
+ # See user profile page for these values in me2day.
5
+ #
6
+ #
7
+ # DEPRECATED
8
+ #Rme2day::API.set_credential('codian', 'ed870d2b', '4713d502f12345d8e25322b65335d35c') # deprecated
9
+ #
10
+ # utf8
11
+ #Rme2day::API.setup('codian', 'ed870d2b', '4713d502f12345d8e25322b65335d35c')
12
+ #
13
+ # euckr
14
+ Rme2day::API.setup('codian', 'ed870d2b', '4713d502f12345d8e25322b65335d35c', 'euckr')
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: rme2day
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-08-28 00:00:00 +09:00
8
+ summary: The author was too lazy to write a summary
9
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: http://www.zenspider.com/ZSS/Products/rme2day/
13
+ rubyforge_project: ikspres
14
+ description: The author was too lazy to write a description
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Ryan Davis
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - lib/rme2day.rb
37
+ - spec/api_spec.rb
38
+ - spec/person_spec.rb
39
+ - spec/post_spec.rb
40
+ - spec/post_xml.rb
41
+ - spec/settings_spec.rb
42
+ - spec/settings_xml.rb
43
+ - spec/setup.rb.sample
44
+ test_files: []
45
+
46
+ rdoc_options:
47
+ - --main
48
+ - README.txt
49
+ extra_rdoc_files:
50
+ - History.txt
51
+ - Manifest.txt
52
+ - README.txt
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ requirements: []
58
+
59
+ dependencies:
60
+ - !ruby/object:Gem::Dependency
61
+ name: hoe
62
+ version_requirement:
63
+ version_requirements: !ruby/object:Gem::Version::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.2.2
68
+ version: