rest-more 1.0.2 → 2.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/.gitignore +0 -5
- data/.travis.yml +4 -6
- data/CHANGES.md +16 -0
- data/Gemfile +6 -3
- data/README.md +43 -129
- data/Rakefile +2 -3
- data/example/multi.rb +12 -23
- data/example/rails3/Gemfile +2 -1
- data/example/rails3/app/controllers/application_controller.rb +9 -4
- data/example/rails3/test/functional/application_controller_test.rb +1 -1
- data/example/rainbows.rb +48 -7
- data/example/simple.rb +3 -3
- data/example/sinatra/config.ru +1 -1
- data/lib/rest-core/client/dropbox.rb +19 -27
- data/lib/rest-core/client/facebook.rb +28 -51
- data/lib/rest-core/client/facebook/rails_util.rb +13 -11
- data/lib/rest-core/client/github.rb +13 -21
- data/lib/rest-core/client/linkedin.rb +19 -27
- data/lib/rest-core/client/twitter.rb +13 -21
- data/lib/rest-more.rb +0 -2
- data/lib/rest-more/test.rb +11 -0
- data/lib/rest-more/version.rb +1 -1
- data/rest-more.gemspec +7 -41
- data/task/.gitignore +1 -0
- data/task/gemgem.rb +267 -0
- data/test/dropbox/test_api.rb +1 -1
- data/test/facebook/config/rest-core.yaml +1 -1
- data/test/facebook/test_api.rb +10 -14
- data/test/facebook/test_error.rb +2 -2
- data/test/facebook/test_handler.rb +6 -6
- data/test/facebook/test_load_config.rb +4 -4
- data/test/facebook/test_misc.rb +3 -3
- data/test/facebook/test_old.rb +2 -37
- data/test/facebook/test_page.rb +26 -24
- data/test/facebook/test_parse.rb +1 -1
- data/test/facebook/test_serialize.rb +3 -19
- data/test/facebook/test_timeout.rb +6 -2
- data/test/twitter/test_api.rb +1 -1
- metadata +6 -40
- data/doc/ToC.md +0 -9
- data/doc/dependency.md +0 -4
- data/doc/design.md +0 -4
- data/doc/rest-graph.md +0 -4
- data/example/async.rb +0 -89
- data/example/facebook.rb +0 -13
- data/example/rails2/Gemfile +0 -22
- data/example/rails2/README +0 -4
- data/example/rails2/Rakefile +0 -11
- data/example/rails2/app/controllers/application_controller.rb +0 -138
- data/example/rails2/app/views/application/helper.html.erb +0 -1
- data/example/rails2/config/boot.rb +0 -130
- data/example/rails2/config/environment.rb +0 -25
- data/example/rails2/config/environments/development.rb +0 -17
- data/example/rails2/config/environments/production.rb +0 -28
- data/example/rails2/config/environments/test.rb +0 -30
- data/example/rails2/config/initializers/cookie_verification_secret.rb +0 -7
- data/example/rails2/config/initializers/new_rails_defaults.rb +0 -21
- data/example/rails2/config/initializers/session_store.rb +0 -15
- data/example/rails2/config/preinitializer.rb +0 -23
- data/example/rails2/config/rest-core.yaml +0 -12
- data/example/rails2/config/routes.rb +0 -43
- data/example/rails2/log +0 -0
- data/example/rails2/test/functional/application_controller_test.rb +0 -259
- data/example/rails2/test/test_helper.rb +0 -18
- data/example/rails2/test/unit/rails_util_test.rb +0 -49
- data/lib/rest-core/client/bing.rb +0 -102
- data/lib/rest-core/client/bing/rails_util.rb +0 -13
- data/lib/rest-core/client/mixi.rb +0 -60
- data/lib/rest-core/client/mixi/rails_util.rb +0 -13
- data/test/bing/test_api.rb +0 -34
- data/test/facebook/test_cache.rb +0 -58
- data/test/mixi/test_api.rb +0 -20
data/lib/rest-more.rb
CHANGED
@@ -4,11 +4,9 @@ require 'rest-core'
|
|
4
4
|
module RestCore
|
5
5
|
autoload :Config , 'rest-core/util/config'
|
6
6
|
|
7
|
-
autoload :Bing , 'rest-core/client/bing'
|
8
7
|
autoload :Dropbox , 'rest-core/client/dropbox'
|
9
8
|
autoload :Facebook, 'rest-core/client/facebook'
|
10
9
|
autoload :Github , 'rest-core/client/github'
|
11
10
|
autoload :Linkedin, 'rest-core/client/linkedin'
|
12
|
-
autoload :Mixi , 'rest-core/client/mixi'
|
13
11
|
autoload :Twitter , 'rest-core/client/twitter'
|
14
12
|
end
|
data/lib/rest-more/test.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
1
|
|
2
2
|
require 'rest-core/test'
|
3
3
|
require 'rest-more'
|
4
|
+
|
5
|
+
module TestHelper
|
6
|
+
module_function
|
7
|
+
def normalize_query query
|
8
|
+
'?' + query[1..-1].split('&').sort.join('&')
|
9
|
+
end
|
10
|
+
|
11
|
+
def normalize_url url
|
12
|
+
url.sub(/\?.+/){ |query| TestHelper.normalize_query(query) }
|
13
|
+
end
|
14
|
+
end
|
data/lib/rest-more/version.rb
CHANGED
data/rest-more.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rest-more"
|
5
|
-
s.version = "
|
5
|
+
s.version = "2.0.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [
|
9
9
|
"Cardinal Blue",
|
10
10
|
"Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2012-
|
11
|
+
s.date = "2012-10-31"
|
12
12
|
s.description = "Various REST clients such as Facebook and Twitter built with [rest-core][]\n\n[rest-core]: https://github.com/cardinalblue/rest-core"
|
13
13
|
s.email = ["dev (XD) cardinalblue.com"]
|
14
14
|
s.executables = ["rib-rest-core"]
|
@@ -23,34 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"TODO.md",
|
25
25
|
"bin/rib-rest-core",
|
26
|
-
"doc/ToC.md",
|
27
|
-
"doc/dependency.md",
|
28
|
-
"doc/design.md",
|
29
|
-
"doc/rest-graph.md",
|
30
26
|
"doc/tutorial/facebook.md",
|
31
|
-
"example/async.rb",
|
32
|
-
"example/facebook.rb",
|
33
27
|
"example/multi.rb",
|
34
|
-
"example/rails2/Gemfile",
|
35
|
-
"example/rails2/README",
|
36
|
-
"example/rails2/Rakefile",
|
37
|
-
"example/rails2/app/controllers/application_controller.rb",
|
38
|
-
"example/rails2/app/views/application/helper.html.erb",
|
39
|
-
"example/rails2/config/boot.rb",
|
40
|
-
"example/rails2/config/environment.rb",
|
41
|
-
"example/rails2/config/environments/development.rb",
|
42
|
-
"example/rails2/config/environments/production.rb",
|
43
|
-
"example/rails2/config/environments/test.rb",
|
44
|
-
"example/rails2/config/initializers/cookie_verification_secret.rb",
|
45
|
-
"example/rails2/config/initializers/new_rails_defaults.rb",
|
46
|
-
"example/rails2/config/initializers/session_store.rb",
|
47
|
-
"example/rails2/config/preinitializer.rb",
|
48
|
-
"example/rails2/config/rest-core.yaml",
|
49
|
-
"example/rails2/config/routes.rb",
|
50
|
-
"example/rails2/log",
|
51
|
-
"example/rails2/test/functional/application_controller_test.rb",
|
52
|
-
"example/rails2/test/test_helper.rb",
|
53
|
-
"example/rails2/test/unit/rails_util_test.rb",
|
54
28
|
"example/rails3/Gemfile",
|
55
29
|
"example/rails3/README",
|
56
30
|
"example/rails3/Rakefile",
|
@@ -73,8 +47,6 @@ Gem::Specification.new do |s|
|
|
73
47
|
"example/rainbows.rb",
|
74
48
|
"example/simple.rb",
|
75
49
|
"example/sinatra/config.ru",
|
76
|
-
"lib/rest-core/client/bing.rb",
|
77
|
-
"lib/rest-core/client/bing/rails_util.rb",
|
78
50
|
"lib/rest-core/client/dropbox.rb",
|
79
51
|
"lib/rest-core/client/facebook.rb",
|
80
52
|
"lib/rest-core/client/facebook/rails_util.rb",
|
@@ -82,8 +54,6 @@ Gem::Specification.new do |s|
|
|
82
54
|
"lib/rest-core/client/github/rails_util.rb",
|
83
55
|
"lib/rest-core/client/linkedin.rb",
|
84
56
|
"lib/rest-core/client/linkedin/rails_util.rb",
|
85
|
-
"lib/rest-core/client/mixi.rb",
|
86
|
-
"lib/rest-core/client/mixi/rails_util.rb",
|
87
57
|
"lib/rest-core/client/twitter.rb",
|
88
58
|
"lib/rest-core/client/twitter/rails_util.rb",
|
89
59
|
"lib/rest-core/util/config.rb",
|
@@ -93,11 +63,11 @@ Gem::Specification.new do |s|
|
|
93
63
|
"lib/rest-more/version.rb",
|
94
64
|
"lib/rib/app/rest-core.rb",
|
95
65
|
"rest-more.gemspec",
|
96
|
-
"
|
66
|
+
"task/.gitignore",
|
67
|
+
"task/gemgem.rb",
|
97
68
|
"test/dropbox/test_api.rb",
|
98
69
|
"test/facebook/config/rest-core.yaml",
|
99
70
|
"test/facebook/test_api.rb",
|
100
|
-
"test/facebook/test_cache.rb",
|
101
71
|
"test/facebook/test_default.rb",
|
102
72
|
"test/facebook/test_error.rb",
|
103
73
|
"test/facebook/test_handler.rb",
|
@@ -109,17 +79,14 @@ Gem::Specification.new do |s|
|
|
109
79
|
"test/facebook/test_parse.rb",
|
110
80
|
"test/facebook/test_serialize.rb",
|
111
81
|
"test/facebook/test_timeout.rb",
|
112
|
-
"test/mixi/test_api.rb",
|
113
82
|
"test/twitter/test_api.rb"]
|
114
83
|
s.homepage = "https://github.com/cardinalblue/rest-more"
|
115
84
|
s.require_paths = ["lib"]
|
116
85
|
s.rubygems_version = "1.8.24"
|
117
86
|
s.summary = "Various REST clients such as Facebook and Twitter built with [rest-core][]"
|
118
87
|
s.test_files = [
|
119
|
-
"test/bing/test_api.rb",
|
120
88
|
"test/dropbox/test_api.rb",
|
121
89
|
"test/facebook/test_api.rb",
|
122
|
-
"test/facebook/test_cache.rb",
|
123
90
|
"test/facebook/test_default.rb",
|
124
91
|
"test/facebook/test_error.rb",
|
125
92
|
"test/facebook/test_handler.rb",
|
@@ -131,18 +98,17 @@ Gem::Specification.new do |s|
|
|
131
98
|
"test/facebook/test_parse.rb",
|
132
99
|
"test/facebook/test_serialize.rb",
|
133
100
|
"test/facebook/test_timeout.rb",
|
134
|
-
"test/mixi/test_api.rb",
|
135
101
|
"test/twitter/test_api.rb"]
|
136
102
|
|
137
103
|
if s.respond_to? :specification_version then
|
138
104
|
s.specification_version = 3
|
139
105
|
|
140
106
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
141
|
-
s.add_runtime_dependency(%q<rest-core>, [">=
|
107
|
+
s.add_runtime_dependency(%q<rest-core>, [">= 2.0.0"])
|
142
108
|
else
|
143
|
-
s.add_dependency(%q<rest-core>, [">=
|
109
|
+
s.add_dependency(%q<rest-core>, [">= 2.0.0"])
|
144
110
|
end
|
145
111
|
else
|
146
|
-
s.add_dependency(%q<rest-core>, [">=
|
112
|
+
s.add_dependency(%q<rest-core>, [">= 2.0.0"])
|
147
113
|
end
|
148
114
|
end
|
data/task/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.rbc
|
data/task/gemgem.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Gemgem
|
5
|
+
class << self
|
6
|
+
attr_accessor :dir, :spec
|
7
|
+
end
|
8
|
+
|
9
|
+
module_function
|
10
|
+
def create
|
11
|
+
yield(spec = Gem::Specification.new{ |s|
|
12
|
+
s.authors = ['Lin Jen-Shin (godfat)']
|
13
|
+
s.email = ['godfat (XD) godfat.org']
|
14
|
+
|
15
|
+
s.description = description.join
|
16
|
+
s.summary = description.first
|
17
|
+
|
18
|
+
s.rubygems_version = Gem::VERSION
|
19
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
20
|
+
s.files = gem_files
|
21
|
+
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
22
|
+
s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = %w[lib]
|
24
|
+
})
|
25
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
26
|
+
spec
|
27
|
+
end
|
28
|
+
|
29
|
+
def readme
|
30
|
+
path = %w[README.md README].find{ |name|
|
31
|
+
File.exist?("#{Gemgem.dir}/#{name}")
|
32
|
+
}
|
33
|
+
@readme ||=
|
34
|
+
if path
|
35
|
+
ps = "##{File.read(path)}".
|
36
|
+
scan(/((#+)[^\n]+\n\n.+?(?=\n\n\2[^#\n]+\n))/m).map(&:first)
|
37
|
+
ps.inject({'HEADER' => ps.first}){ |r, s, i|
|
38
|
+
r[s[/\w+/]] = s
|
39
|
+
r
|
40
|
+
}
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def description
|
47
|
+
@description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
|
48
|
+
end
|
49
|
+
|
50
|
+
def changes
|
51
|
+
path = %w[CHANGES.md CHANGES].find{ |name|
|
52
|
+
File.exist?("#{Gemgem.dir}/#{name}")
|
53
|
+
}
|
54
|
+
@changes ||=
|
55
|
+
if path
|
56
|
+
date = '\d+{4}\-\d+{2}\-\d{2}'
|
57
|
+
File.read(path).match(
|
58
|
+
/([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n|\Z)/m)[1]
|
59
|
+
else
|
60
|
+
''
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def ann_md
|
65
|
+
"#{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
|
66
|
+
"##{readme['DESCRIPTION'][/[^\n]+\n\n[^\n]+/]}\n\n" \
|
67
|
+
"### CHANGES:\n\n" \
|
68
|
+
"###{changes}\n\n" \
|
69
|
+
"##{readme['INSTALLATION']}\n\n" +
|
70
|
+
if readme['SYNOPSIS'] then "##{readme['SYNOPSIS'][/[^\n]+\n\n[^\n]+/]}"
|
71
|
+
else '' end
|
72
|
+
end
|
73
|
+
|
74
|
+
def ann_html
|
75
|
+
gem 'nokogiri'
|
76
|
+
gem 'kramdown'
|
77
|
+
|
78
|
+
IO.popen('kramdown', 'r+') do |md|
|
79
|
+
md.puts Gemgem.ann_md
|
80
|
+
md.close_write
|
81
|
+
require 'nokogiri'
|
82
|
+
html = Nokogiri::XML.parse("<gemgem>#{md.read}</gemgem>")
|
83
|
+
html.css('*').each{ |n| n.delete('id') }
|
84
|
+
html.root.children.to_html
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def ann_email
|
89
|
+
"#{readme['HEADER'].sub(/([\w\-]+)/, "\\1 <#{spec.homepage}>")}\n\n" \
|
90
|
+
"#{readme['DESCRIPTION']}\n\n" \
|
91
|
+
"#{readme['INSTALLATION']}\n\n" +
|
92
|
+
if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}\n\n" else '' end +
|
93
|
+
"## CHANGES:\n\n" \
|
94
|
+
"##{changes}\n\n"
|
95
|
+
end
|
96
|
+
|
97
|
+
def gem_tag
|
98
|
+
"#{spec.name}-#{spec.version}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def write
|
102
|
+
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
|
103
|
+
f << split_lines(spec.to_ruby) }
|
104
|
+
end
|
105
|
+
|
106
|
+
def split_lines ruby
|
107
|
+
ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
|
108
|
+
if $2.index(',')
|
109
|
+
"#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
|
110
|
+
else
|
111
|
+
s
|
112
|
+
end
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def all_files
|
117
|
+
@all_files ||= find_files(Pathname.new(dir)).map{ |file|
|
118
|
+
if file.to_s =~ %r{\.git/|\.git$}
|
119
|
+
nil
|
120
|
+
else
|
121
|
+
file.to_s
|
122
|
+
end
|
123
|
+
}.compact.sort
|
124
|
+
end
|
125
|
+
|
126
|
+
def gem_files
|
127
|
+
@gem_files ||= all_files - ignored_files
|
128
|
+
end
|
129
|
+
|
130
|
+
def ignored_files
|
131
|
+
@ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
|
132
|
+
path =~ ignore && !git_files.include?(path)}}
|
133
|
+
end
|
134
|
+
|
135
|
+
def git_files
|
136
|
+
@git_files ||= if File.exist?("#{dir}/.git")
|
137
|
+
`git ls-files`.split("\n")
|
138
|
+
else
|
139
|
+
[]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# protected
|
144
|
+
def find_files path
|
145
|
+
path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
|
146
|
+
path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
|
147
|
+
end
|
148
|
+
|
149
|
+
def ignore_patterns
|
150
|
+
@ignore_files ||= expand_patterns(
|
151
|
+
gitignore.split("\n").reject{ |pattern|
|
152
|
+
pattern.strip == ''
|
153
|
+
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
154
|
+
end
|
155
|
+
|
156
|
+
def expand_patterns pathes
|
157
|
+
pathes.map{ |path|
|
158
|
+
if path !~ /\*/
|
159
|
+
path
|
160
|
+
else
|
161
|
+
expand_patterns(
|
162
|
+
Dir[path] +
|
163
|
+
Pathname.new(File.dirname(path)).children.select(&:directory?).
|
164
|
+
map{ |prefix| "#{prefix}/#{File.basename(path)}" })
|
165
|
+
end
|
166
|
+
}.flatten
|
167
|
+
end
|
168
|
+
|
169
|
+
def gitignore
|
170
|
+
if File.exist?(path = "#{dir}/.gitignore")
|
171
|
+
File.read(path)
|
172
|
+
else
|
173
|
+
''
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
namespace :gem do
|
179
|
+
|
180
|
+
desc 'Install gem'
|
181
|
+
task :install => [:build] do
|
182
|
+
sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
|
183
|
+
end
|
184
|
+
|
185
|
+
desc 'Build gem'
|
186
|
+
task :build => [:spec] do
|
187
|
+
sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
|
188
|
+
sh("mkdir -p pkg")
|
189
|
+
sh("mv #{Gemgem.gem_tag}.gem pkg/")
|
190
|
+
end
|
191
|
+
|
192
|
+
desc 'Release gem'
|
193
|
+
task :release => [:spec, :check, :build] do
|
194
|
+
sh("git tag #{Gemgem.gem_tag}")
|
195
|
+
sh("git push")
|
196
|
+
sh("git push --tags")
|
197
|
+
sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
|
198
|
+
end
|
199
|
+
|
200
|
+
task :check do
|
201
|
+
ver = Gemgem.spec.version.to_s
|
202
|
+
|
203
|
+
if ENV['VERSION'].nil?
|
204
|
+
puts("\e[35mExpected " \
|
205
|
+
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
206
|
+
exit(1)
|
207
|
+
|
208
|
+
elsif ENV['VERSION'] != ver
|
209
|
+
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
210
|
+
"\e[35mbut got\n " \
|
211
|
+
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
212
|
+
exit(2)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end # of gem namespace
|
217
|
+
|
218
|
+
desc 'Run tests in memory'
|
219
|
+
task :test do
|
220
|
+
require 'bacon'
|
221
|
+
Bacon.extend(Bacon::TestUnitOutput)
|
222
|
+
Bacon.summary_on_exit
|
223
|
+
$LOAD_PATH.unshift('lib')
|
224
|
+
Dir['./test/**/test_*.rb'].each{ |file| require file[0..-4] }
|
225
|
+
end
|
226
|
+
|
227
|
+
desc 'Run tests with shell'
|
228
|
+
task 'test:shell', :RUBY_OPTS do |t, args|
|
229
|
+
files = Dir['test/**/test_*.rb'].join(' ')
|
230
|
+
|
231
|
+
cmd = [Gem.ruby, args[:RUBY_OPTS],
|
232
|
+
'-I', 'lib', '-S', 'bacon', '--quiet', files]
|
233
|
+
|
234
|
+
sh(cmd.compact.join(' '))
|
235
|
+
end
|
236
|
+
|
237
|
+
desc 'Generate ann markdown'
|
238
|
+
task 'ann:md' => ['gem:spec'] do
|
239
|
+
puts Gemgem.ann_md
|
240
|
+
end
|
241
|
+
|
242
|
+
desc 'Generate ann html'
|
243
|
+
task 'ann:html' => ['gem:spec'] do
|
244
|
+
puts Gemgem.ann_html
|
245
|
+
end
|
246
|
+
|
247
|
+
desc 'Generate ann email'
|
248
|
+
task 'ann:email' => ['gem:spec'] do
|
249
|
+
puts Gemgem.ann_email
|
250
|
+
end
|
251
|
+
|
252
|
+
desc 'Generate rdoc'
|
253
|
+
task :doc => ['gem:spec'] do
|
254
|
+
sh("yardoc -o rdoc --main README.md" \
|
255
|
+
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
256
|
+
end
|
257
|
+
|
258
|
+
desc 'Remove ignored files'
|
259
|
+
task :clean => ['gem:spec'] do
|
260
|
+
trash = "~/.Trash/#{Gemgem.spec.name}/"
|
261
|
+
sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
|
262
|
+
Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
|
263
|
+
end
|
264
|
+
|
265
|
+
task :default do
|
266
|
+
puts `#{Gem.ruby} -S #{$PROGRAM_NAME} -T`
|
267
|
+
end
|
data/test/dropbox/test_api.rb
CHANGED
data/test/facebook/test_api.rb
CHANGED
@@ -19,10 +19,8 @@ describe RC::Facebook do
|
|
19
19
|
:headers => {'Accept' => 'text/plain',
|
20
20
|
'Accept-Language' => 'zh-tw',
|
21
21
|
'Accept-Encoding' => 'gzip, deflate', # this is by ruby
|
22
|
-
|
23
|
-
|
24
|
-
{'User-Agent' => 'Ruby'})). # this is by ruby
|
25
|
-
to_return(:body => '{"data": []}')
|
22
|
+
'User-Agent' => 'Ruby' # this is by ruby
|
23
|
+
}).to_return(:body => '{"data": []}')
|
26
24
|
|
27
25
|
RC::Facebook.new(:site => 'http://nothing.godfat.org/',
|
28
26
|
:lang => 'zh-tw',
|
@@ -35,11 +33,9 @@ describe RC::Facebook do
|
|
35
33
|
:headers => {'Accept' => 'application/json',
|
36
34
|
'Accept-Language' => 'en-us',
|
37
35
|
'Accept-Encoding' => 'gzip, deflate', # this is by ruby
|
36
|
+
'User-Agent' => 'Ruby', # this is by ruby
|
38
37
|
'X-Forwarded-For' => '127.0.0.1',
|
39
|
-
}.
|
40
|
-
{} :
|
41
|
-
{'User-Agent' => 'Ruby'})). # this is by ruby
|
42
|
-
to_return(:body => '{"data": []}')
|
38
|
+
}).to_return(:body => '{"data": []}')
|
43
39
|
|
44
40
|
RC::Facebook.new.get('http://example.com', {},
|
45
41
|
{:headers => {'X-Forwarded-For' => '127.0.0.1'}} ).
|
@@ -50,7 +46,7 @@ describe RC::Facebook do
|
|
50
46
|
stub_request(:post, 'https://graph.facebook.com/feed/me').
|
51
47
|
with(:body => 'message=hi%20there').to_return(:body => 'ok')
|
52
48
|
|
53
|
-
RC::Facebook.new(:
|
49
|
+
RC::Facebook.new(:json_response => false).
|
54
50
|
post('feed/me', :message => 'hi there').should == 'ok'
|
55
51
|
end
|
56
52
|
|
@@ -60,7 +56,7 @@ describe RC::Facebook do
|
|
60
56
|
to_return(:body => 'ok')
|
61
57
|
|
62
58
|
rg = RC::Facebook.new(
|
63
|
-
:
|
59
|
+
:json_response => false, :access_token => 'wrong',
|
64
60
|
:app_id => '1', :secret => '2')
|
65
61
|
rg.get('me', {}, :secret => true).should.eq 'ok'
|
66
62
|
rg.url('me', {}, :secret => true).should.eq \
|
@@ -73,9 +69,9 @@ describe RC::Facebook do
|
|
73
69
|
stub_request(:get, 'https://graph.facebook.com/woot').
|
74
70
|
to_return(:body => 'bad json')
|
75
71
|
|
76
|
-
rg = RC::Facebook.new(:
|
77
|
-
rg.get('woot', {}, :
|
78
|
-
rg.
|
72
|
+
rg = RC::Facebook.new(:json_response => true)
|
73
|
+
rg.get('woot', {}, :json_response => false).should.eq 'bad json'
|
74
|
+
rg.json_response.should == true
|
79
75
|
end
|
80
76
|
|
81
77
|
should 'not raise exception when encountering error' do
|
@@ -91,7 +87,7 @@ describe RC::Facebook do
|
|
91
87
|
stub(o = Object.new).to_s{ 'i am mock' }
|
92
88
|
stub_request(:get, "https://graph.facebook.com/search?q=i%20am%20mock").
|
93
89
|
to_return(:body => 'ok')
|
94
|
-
RC::Facebook.new(:
|
90
|
+
RC::Facebook.new(:json_response => false).
|
95
91
|
get('search', :q => o).should.eq 'ok'
|
96
92
|
end
|
97
93
|
end
|