timelog4r 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +30 -0
- data/README.txt +43 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/example/create_refollow_list.rb +14 -0
- data/example/hello_world.rb +10 -0
- data/lib/timelog4r/utils.rb +115 -0
- data/lib/timelog4r/version.rb +9 -0
- data/lib/timelog4r/xml_parser.rb +366 -0
- data/lib/timelog4r.rb +513 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/timelog4r_spec.rb +412 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +72 -0
- data/website/index.txt +60 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +97 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
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/Manifest.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
config/hoe.rb
|
7
|
+
config/requirements.rb
|
8
|
+
example/create_refollow_list.rb
|
9
|
+
example/hello_world.rb
|
10
|
+
lib/timelog4r.rb
|
11
|
+
lib/timelog4r/utils.rb
|
12
|
+
lib/timelog4r/version.rb
|
13
|
+
lib/timelog4r/xml_parser.rb
|
14
|
+
script/console
|
15
|
+
script/destroy
|
16
|
+
script/generate
|
17
|
+
script/txt2html
|
18
|
+
setup.rb
|
19
|
+
spec/spec.opts
|
20
|
+
spec/spec_helper.rb
|
21
|
+
spec/timelog4r_spec.rb
|
22
|
+
tasks/deployment.rake
|
23
|
+
tasks/environment.rake
|
24
|
+
tasks/rspec.rake
|
25
|
+
tasks/website.rake
|
26
|
+
website/index.html
|
27
|
+
website/index.txt
|
28
|
+
website/javascripts/rounded_corners_lite.inc.js
|
29
|
+
website/stylesheets/screen.css
|
30
|
+
website/template.html.erb
|
data/README.txt
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
= timelog4r
|
2
|
+
|
3
|
+
http://timelog4r.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Timelog4r is TimelogAPI for ruby.
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
t = Timelog4r.new
|
12
|
+
t.user_id = 'your timelog id'
|
13
|
+
t.password = 'your timelog password'
|
14
|
+
t.update 'Hello Timelog.'
|
15
|
+
|
16
|
+
== INSTALL:
|
17
|
+
|
18
|
+
sudo gem install timelog4r
|
19
|
+
|
20
|
+
== LICENSE:
|
21
|
+
|
22
|
+
(The MIT License)
|
23
|
+
|
24
|
+
Copyright (c) 2008 FIXME saronpasu
|
25
|
+
|
26
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
27
|
+
a copy of this software and associated documentation files (the
|
28
|
+
'Software'), to deal in the Software without restriction, including
|
29
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
30
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
31
|
+
permit persons to whom the Software is furnished to do so, subject to
|
32
|
+
the following conditions:
|
33
|
+
|
34
|
+
The above copyright notice and this permission notice shall be
|
35
|
+
included in all copies or substantial portions of the Software.
|
36
|
+
|
37
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
38
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
39
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
40
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
41
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
42
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
43
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'timelog4r/version'
|
2
|
+
|
3
|
+
AUTHOR = 'saronpasu' # can also be an array of Authors
|
4
|
+
EMAIL = "jamneco@gmail.com"
|
5
|
+
DESCRIPTION = "TimelogAPI for ruby."
|
6
|
+
GEM_NAME = 'timelog4r' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'timelog4r' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
] # An array of rubygem dependencies [name, version]
|
13
|
+
|
14
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
+
@config = nil
|
16
|
+
RUBYFORGE_USERNAME = "saronpasu"
|
17
|
+
def rubyforge_username
|
18
|
+
unless @config
|
19
|
+
begin
|
20
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
+
EOS
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
37
|
+
VERS = Timelog4r::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
+
RDOC_OPTS = ['--quiet', '--title', 'timelog4r documentation',
|
39
|
+
"--opname", "index.html",
|
40
|
+
"--line-numbers",
|
41
|
+
"--main", "README",
|
42
|
+
"--inline-source"]
|
43
|
+
|
44
|
+
class Hoe
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
+
@extra_deps
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generate all the Rake tasks
|
52
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
+
p.developer(AUTHOR, EMAIL)
|
55
|
+
p.description = DESCRIPTION
|
56
|
+
p.summary = DESCRIPTION
|
57
|
+
p.url = HOMEPATH
|
58
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
59
|
+
p.test_globs = ["test/**/test_*.rb"]
|
60
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
61
|
+
|
62
|
+
# == Optional
|
63
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
64
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
+
|
66
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
+
end
|
68
|
+
|
69
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
73
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!ruby -Ku
|
2
|
+
require 'timelog4r'
|
3
|
+
|
4
|
+
t = Timelog4r.new
|
5
|
+
t.user_id = 'your Timelog ID'
|
6
|
+
t.password = 'your Password'
|
7
|
+
|
8
|
+
friends = t.get_friend_list({:cnt => 'all'})
|
9
|
+
fan = t.get_fan_list({:cnt => 'all'})
|
10
|
+
|
11
|
+
not_yet_followings = fan[:entries].map{|i|i[:id]} - friends[:entries].map{|j|j[:id]}
|
12
|
+
|
13
|
+
return not_yet_followings
|
14
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!ruby
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
class Timelog4r
|
7
|
+
=begin rdoc
|
8
|
+
Description::
|
9
|
+
Utility Module.
|
10
|
+
there in 'http', 'uri', 'parser', etc...
|
11
|
+
|
12
|
+
=end
|
13
|
+
module Utils
|
14
|
+
|
15
|
+
=begin rdoc
|
16
|
+
Description::
|
17
|
+
parse for uri queries.
|
18
|
+
|
19
|
+
Params::
|
20
|
+
options {
|
21
|
+
:key => :value
|
22
|
+
} [Hash]
|
23
|
+
|
24
|
+
Return::
|
25
|
+
'?key=value&key2=value2'
|
26
|
+
|
27
|
+
=end
|
28
|
+
def parse_options(options)
|
29
|
+
if options.has_key?(:since)
|
30
|
+
options[:since] = options[:since].strftime '%Y%m%d%H%M'
|
31
|
+
end
|
32
|
+
options = options.find_all{|option|
|
33
|
+
option.last
|
34
|
+
}
|
35
|
+
if options.empty?
|
36
|
+
result = nil
|
37
|
+
else
|
38
|
+
result = URI.escape(
|
39
|
+
'?' + options.collect{|option|
|
40
|
+
option.join('=')
|
41
|
+
}.join('&')
|
42
|
+
)
|
43
|
+
end
|
44
|
+
return result
|
45
|
+
end
|
46
|
+
|
47
|
+
=begin rdoc
|
48
|
+
Description::
|
49
|
+
url_string to URI-Instance.
|
50
|
+
|
51
|
+
Params::
|
52
|
+
:url_string url_string [String]
|
53
|
+
|
54
|
+
Return::
|
55
|
+
URI-Instance
|
56
|
+
|
57
|
+
=end
|
58
|
+
def create_uri(url_string)
|
59
|
+
return URI.parse(url_string)
|
60
|
+
end
|
61
|
+
|
62
|
+
=begin rdoc
|
63
|
+
Description::
|
64
|
+
create of Net::HTTP::Request-Instance.
|
65
|
+
|
66
|
+
Params::
|
67
|
+
|
68
|
+
:type http-method (:get|:post) [String]
|
69
|
+
:uri request-uri [URI]
|
70
|
+
:use_basic_auth basic_auth flag [Boolean] default false
|
71
|
+
|
72
|
+
Return::
|
73
|
+
Net::HTTP::Request-Instance
|
74
|
+
|
75
|
+
=end
|
76
|
+
def create_request(type, uri, use_basic_auth = false)
|
77
|
+
case type
|
78
|
+
when :get
|
79
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
80
|
+
when :post
|
81
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
82
|
+
end
|
83
|
+
request['User-Agent'] = @user_agent
|
84
|
+
request.basic_auth(@user_id, @password) if use_basic_auth
|
85
|
+
return request
|
86
|
+
end
|
87
|
+
|
88
|
+
=begin rdoc
|
89
|
+
Description::
|
90
|
+
access to TimelogAPI.
|
91
|
+
|
92
|
+
Params::
|
93
|
+
|
94
|
+
:uri request-uri [URI]
|
95
|
+
:request http-request [Net::HTTP::Request]
|
96
|
+
|
97
|
+
Return::
|
98
|
+
|
99
|
+
REXML::Document-Instance (case of 'success')
|
100
|
+
false (case of 'failed')
|
101
|
+
|
102
|
+
=end
|
103
|
+
def http_access(uri, request)
|
104
|
+
Net::HTTP.start(uri.host, uri.port){|http|
|
105
|
+
response = http.request(request)
|
106
|
+
if response.code == '200'
|
107
|
+
return REXML::Document.new(response.body)
|
108
|
+
else
|
109
|
+
return false
|
110
|
+
end
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|