curate_tumblr 1.0.3
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/.project +18 -0
- data/README.md +219 -0
- data/Rakefile +0 -0
- data/curate_tumblr.gemspec +12 -0
- data/example/kubricklove/kubricklove_config.yaml +20 -0
- data/example/kubricklove/links/kubricklove_links +4 -0
- data/example/kubricklove_follow.rb +6 -0
- data/example/kubricklove_reblog.rb +6 -0
- data/example/readme +9 -0
- data/lib/curate_tumblr.rb +25 -0
- data/lib/curate_tumblr/curator.rb +200 -0
- data/lib/curate_tumblr/publish/follow.rb +62 -0
- data/lib/curate_tumblr/publish/post.rb +21 -0
- data/lib/curate_tumblr/publish/reblog.rb +86 -0
- data/lib/curate_tumblr/render/render_follow.rb +29 -0
- data/lib/curate_tumblr/render/render_links.rb +132 -0
- data/lib/curate_tumblr/render/render_reblog.rb +36 -0
- data/lib/curate_tumblr/tumblr/client.rb +347 -0
- data/lib/curate_tumblr/tumblr/extract_links.rb +190 -0
- data/lib/curate_tumblr/tumblr/infos.rb +102 -0
- data/lib/curate_tumblr/utilities/monkey.rb +5 -0
- data/lib/curate_tumblr/utilities/utilities.rb +4 -0
- data/lib/curate_tumblr/utilities/utilities_client.rb +103 -0
- data/lib/curate_tumblr/utilities/utilities_file.rb +50 -0
- data/lib/curate_tumblr/utilities/utilities_format.rb +91 -0
- data/lib/curate_tumblr/utilities/utilities_validate.rb +54 -0
- data/lib/curate_tumblr/values.rb +22 -0
- data/spec/curate_tumblr/curator_spec.rb +36 -0
- data/spec/curate_tumblr/publish/follow_spec.rb +183 -0
- data/spec/curate_tumblr/publish/post_spec.rb +45 -0
- data/spec/curate_tumblr/publish/reblog_spec.rb +118 -0
- data/spec/curate_tumblr/render/render_follow_spec.rb +36 -0
- data/spec/curate_tumblr/render/render_reblog_spec.rb +73 -0
- data/spec/curate_tumblr/tumblr/client_spec.rb +69 -0
- data/spec/curate_tumblr/tumblr/extract_links_spec.rb +204 -0
- data/spec/curate_tumblr/utilities/utilities_validate_spec.rb +27 -0
- data/spec/factories.rb +24 -0
- data/spec/shared_examples.rb +2 -0
- data/spec/shared_values.rb +203 -0
- data/spec/spec_helper.rb +95 -0
- metadata +116 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurateTumblr::Render::RenderFollow do
|
4
|
+
let(:render_follow) { FactoryGirl.build( :render_follow ) }
|
5
|
+
include_context "shared tumblrs"
|
6
|
+
|
7
|
+
before do
|
8
|
+
files_before( render_follow, tumblrs )
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
files_after( render_follow )
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "initialize" do
|
16
|
+
it "filename links" do
|
17
|
+
File.exist?( render_follow.filename_links ).should be_true
|
18
|
+
render_follow.get_links_torender_from_file.count.should eq( count_followed )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "render" do
|
23
|
+
it "all tumblrs" do
|
24
|
+
render_follow.render_links_from_file.should be_true
|
25
|
+
render_follow.get_count.should eq( count_followed )
|
26
|
+
tumblrs_file = render_follow.get_links_torender_from_file
|
27
|
+
tumblrs_file.empty?.should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "direct follow" do
|
31
|
+
render = CurateTumblr.follow( get_tumblr_name, get_tumblr_directory, false )
|
32
|
+
render.get_count.should eq( count_followed )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurateTumblr::Render::RenderLinks do
|
4
|
+
let(:render_reblog) { FactoryGirl.build( :render_reblog ) }
|
5
|
+
include_context "shared links"
|
6
|
+
|
7
|
+
before do
|
8
|
+
files_before( render_reblog, links )
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
files_after( render_reblog )
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "initialize" do
|
16
|
+
it "filename links" do
|
17
|
+
File.exist?( render_reblog.filename_links ).should be_true
|
18
|
+
render_reblog.get_links_torender_from_file.count.should eq( count_reblogs )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "get reblog links from file" do
|
23
|
+
it "read links" do
|
24
|
+
ar_file = render_reblog.get_links_torender_from_file
|
25
|
+
ar_file.should_not be_nil
|
26
|
+
ar_file.class.should eq( Array )
|
27
|
+
ar_file.count.should eq( links.lines.count )
|
28
|
+
end
|
29
|
+
|
30
|
+
context "add links in random" do
|
31
|
+
let(:links) { Set.new [ "1.tumblr.com", "2.tumblr.com", "3.tumblr.com", "4.tumblr.com", "5.tumblr.com", "6.tumblr.com" ] }
|
32
|
+
|
33
|
+
it "order must be in random" do
|
34
|
+
render_reblog.reboot!
|
35
|
+
render_reblog.add_links_to_render( links.to_a )
|
36
|
+
test1 = render_reblog.links_to_render
|
37
|
+
test1.count.should eq ( links.count )
|
38
|
+
test1.to_a.should_not eq( links.to_a )
|
39
|
+
|
40
|
+
render_reblog.reboot!
|
41
|
+
render_reblog.add_links_to_render( links.to_a )
|
42
|
+
test2 = render_reblog.links_to_render
|
43
|
+
test2.count.should eq ( links.count )
|
44
|
+
test2.should_not eq( links.to_a )
|
45
|
+
test2.to_a.should_not eq( test1.to_a )
|
46
|
+
end
|
47
|
+
|
48
|
+
it "each link must be uniq" do
|
49
|
+
render_reblog.reboot!
|
50
|
+
render_reblog.add_links_to_render( links )
|
51
|
+
render_reblog.add_links_to_render( links )
|
52
|
+
render_reblog.links_to_render.count.should eq( links.count )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "render" do
|
58
|
+
|
59
|
+
it "all links" do
|
60
|
+
render_reblog.render_links_from_file.should be_true
|
61
|
+
render_reblog.get_count.should eq( count_reblogs )
|
62
|
+
render_reblog.get_all_published_id.count.should eq( count_reblogs )
|
63
|
+
links_file = render_reblog.get_links_torender_from_file
|
64
|
+
links_file.empty?.should be_true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "direct reblog" do
|
68
|
+
render = CurateTumblr.reblog( get_tumblr_name, get_tumblr_directory, false )
|
69
|
+
render.get_count.should eq( count_reblogs )
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurateTumblr::Tumblr::Client do
|
4
|
+
let(:curator) { FactoryGirl.build( :curator ) }
|
5
|
+
subject { tumblr }
|
6
|
+
include_context "shared targets"
|
7
|
+
include_context "shared links"
|
8
|
+
|
9
|
+
describe "status" do
|
10
|
+
it "when rate exceed" do
|
11
|
+
hash_status = get_status_rate_exceed
|
12
|
+
curator.is_stop.should be_false
|
13
|
+
curator.send( :status_result, hash_status, false, false )
|
14
|
+
curator.is_stop.should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "when status ok" do
|
18
|
+
hash_status = get_status_ok
|
19
|
+
curator.send( :status_result, hash_status, false, false).should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "when rate limit" do
|
23
|
+
hash_status = get_status_rate_exceed
|
24
|
+
CurateTumblr.hash_status_rate_limit?( hash_status ).should be_true
|
25
|
+
curator.send( :status_result, hash_status, false, false).should be_false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "post" do
|
30
|
+
it "post a text" do
|
31
|
+
id = curator.client_post_text( get_post_title, get_post_text )
|
32
|
+
id.should_not be_nil
|
33
|
+
id.should be_true
|
34
|
+
id.is_a?( Integer ).should be_true
|
35
|
+
curator.count_posted.should eq( 1 )
|
36
|
+
curator.count_all_requests_and_posts.should eq( 1 )
|
37
|
+
end
|
38
|
+
|
39
|
+
it "stop all post" do
|
40
|
+
curator.stop_it!
|
41
|
+
curator.client_post_text( get_post_title, get_post_text ).should be_false
|
42
|
+
curator.count_posted.should eq( 0 )
|
43
|
+
curator.count_all_requests_and_posts.should eq( 0 )
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "get infos post" do
|
48
|
+
it "hash post from tumblr and id post" do
|
49
|
+
hash_post = curator.send( :get_hash_post, target_tumblr, target_post_id )
|
50
|
+
hash_post.should_not be_false
|
51
|
+
hash_post.is_a?( Hash ).should be_true
|
52
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
53
|
+
hash_post["blog_name"].should eq( target_name )
|
54
|
+
hash_post["id"].to_s.should eq( target_post_id )
|
55
|
+
end
|
56
|
+
|
57
|
+
it "extract hash url from post url" do
|
58
|
+
hash_url = CurateTumblr.get_hash_url_from_post_url( target_post_url )
|
59
|
+
hash_url.should be_true
|
60
|
+
hash_url[:tumblr_url].should eq( target_tumblr )
|
61
|
+
hash_url[:post_id].should eq( target_post_id )
|
62
|
+
end
|
63
|
+
|
64
|
+
it "no hash url from bad post url" do
|
65
|
+
hash_url = CurateTumblr.get_hash_url_from_post_url( bad_target_post_url )
|
66
|
+
hash_url.should be_false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Extract" do
|
5
|
+
let(:curator) { FactoryGirl.build( :curator ) }
|
6
|
+
|
7
|
+
include_context "shared targets"
|
8
|
+
|
9
|
+
describe "from post url" do
|
10
|
+
it "is tumblr from post url" do
|
11
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( target_post_url ).should be_true
|
12
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( target_post_url2 ).should be_true
|
13
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( target_post_url3 ).should be_true
|
14
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( target_post_url4 ).should be_true
|
15
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( target_post_url5 ).should be_true
|
16
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( bad_target_post_url ).should be_false
|
17
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( bad_target_post_url2 ).should be_false
|
18
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_url?( bad_target_post_url3 ).should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "get tumblr url from post url" do
|
22
|
+
CurateTumblr::Tumblr::ExtractLinks.get_tumblr_url( target_post_url ).should eq( target_tumblr )
|
23
|
+
CurateTumblr::Tumblr::ExtractLinks.get_tumblr_url( target_post_url2 ).should eq( target_tumblr )
|
24
|
+
CurateTumblr::Tumblr::ExtractLinks.get_tumblr_url( target_post_url3 ).should eq( target_tumblr )
|
25
|
+
CurateTumblr::Tumblr::ExtractLinks.get_tumblr_url( target_post_url4 ).should eq( target_tumblr )
|
26
|
+
CurateTumblr::Tumblr::ExtractLinks.get_tumblr_url( target_post_url5 ).should eq( target_tumblr )
|
27
|
+
end
|
28
|
+
|
29
|
+
it "get post id from post url" do
|
30
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( target_post_url ).should eq( target_post_id )
|
31
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( target_post_url2 ).should eq( target_post_id )
|
32
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( target_post_url3 ).should eq( target_post_id )
|
33
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( target_post_url4 ).should eq( target_post_id )
|
34
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( target_post_url5 ).should eq( target_post_id )
|
35
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( bad_target_post_url ).should be_false
|
36
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( bad_target_post_url2 ).should be_false
|
37
|
+
CurateTumblr::Tumblr::ExtractLinks.get_post_id_from_post_url( bad_target_post_url3 ).should be_false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "get source from hash" do
|
41
|
+
tumblr_url = "disorder.tumblr.com"
|
42
|
+
post_url = "http://disorder.tumblr.com/post/54774163481"
|
43
|
+
post_id = 54774163481
|
44
|
+
source_url = "http://c-isnenegro.tumblr.com/"
|
45
|
+
|
46
|
+
hash_post = curator.get_hash_post( tumblr_url, 54774163481 )
|
47
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
48
|
+
CurateTumblr.get_source_from_hash_post( hash_post ).should eq( source_url )
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "external links" do
|
53
|
+
it "get flickr link from caption1" do
|
54
|
+
caption = %Q{
|
55
|
+
<div class="caption">
|
56
|
+
<p>
|
57
|
+
<strong>
|
58
|
+
Trapped by
|
59
|
+
<a href="http://www.flickr.com/photos/dioneanu/9283622790/sizes/l/in/photostream/">Ioneanu</a>
|
60
|
+
</strong>
|
61
|
+
</p>
|
62
|
+
<p>
|
63
|
+
<a href="http://scalesofperception.tumblr.com/">SoP</a>
|
64
|
+
- Scale of Environments
|
65
|
+
</p>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
}
|
69
|
+
link_captions = [ "www.flickr.com/photos/dioneanu/9283622790/sizes/l/in/photostream/" ]
|
70
|
+
found_external_links = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( caption )
|
71
|
+
found_external_links.count.should eq( link_captions.count )
|
72
|
+
link_captions.each { |link| found_external_links.include?( link.chomp ).should be_true }
|
73
|
+
end
|
74
|
+
|
75
|
+
it "get site link from caption2" do
|
76
|
+
caption = %Q{
|
77
|
+
<div class="caption">
|
78
|
+
<p>
|
79
|
+
<a class="tumblr_blog" href="http://onsomething.tumblr.com/post/51007662938" target="_blank">onsomething</a>
|
80
|
+
:
|
81
|
+
</p>
|
82
|
+
<blockquote>
|
83
|
+
<p>
|
84
|
+
<br/>
|
85
|
+
<a href="http://onsomething.tumblr.com/" title="onsomething" target="_blank">onsomething</a>
|
86
|
+
</p>
|
87
|
+
<blockquote>
|
88
|
+
<p>
|
89
|
+
<span class="st">
|
90
|
+
<strong>
|
91
|
+
<a href="http://www.nurilo.com/" target="_blank">Nuno Ribeiro Lopes</a>
|
92
|
+
</strong>
|
93
|
+
|
|
94
|
+
</span>
|
95
|
+
Volcano Interpretation Centre,
|
96
|
+
<span class="st">2003-08</span>
|
97
|
+
Capelinhos
|
98
|
+
</p>
|
99
|
+
</blockquote>
|
100
|
+
</blockquote>
|
101
|
+
</div>
|
102
|
+
}
|
103
|
+
link_captions = [ "www.nurilo.com/" ]
|
104
|
+
found_external_links = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( caption )
|
105
|
+
found_external_links.count.should eq( link_captions.count )
|
106
|
+
link_captions.each { |link| found_external_links.include?( link.chomp ).should be_true }
|
107
|
+
end
|
108
|
+
|
109
|
+
it "get site link from formatted caption2" do
|
110
|
+
caption = %Q{<p><a class=\"tumblr_blog\" href=\"http://onsomething.tumblr.com/post/51007662938\" target=\"_blank\">onsomething</a>:</p>\n<blockquote>\n<p><br/><a href=\"http://onsomething.tumblr.com/\" title=\"onsomething\" target=\"_blank\">onsomething</a></p>\n<blockquote>\n<p><span class=\"st\"><strong><a href=\"http://www.nurilo.com/\" target=\"_blank\">Nuno Ribeiro Lopes</a></strong> | </span>Volcano Interpretation Centre,
|
111
|
+
<span class=\"st\">2003-08 </span>Capelinhos</p>\n</blockquote>\n</blockquote>}
|
112
|
+
link_captions = [ "www.nurilo.com/" ]
|
113
|
+
found_external_links = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( caption )
|
114
|
+
found_external_links.count.should eq( link_captions.count )
|
115
|
+
link_captions.each { |link| found_external_links.include?( link.chomp ).should be_true }
|
116
|
+
end
|
117
|
+
|
118
|
+
it "get external links from true post1" do
|
119
|
+
ar_links_caption = [ "abandonedography.com/post/55211207965/the-boiler-room-by-sebastian-niedlich",
|
120
|
+
"www.flickr.com/photos/42311564@N00/9196902084/sizes/l/in/set-72157634452675984/" ]
|
121
|
+
hash_post = curator.get_hash_post( "shhhgrrrl.tumblr.com", 55227142636 )
|
122
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
123
|
+
|
124
|
+
ar_tofollow = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( hash_post["caption"] )
|
125
|
+
ar_tofollow.count.should eq( ar_links_caption.count )
|
126
|
+
ar_links_caption.each { |link| ar_tofollow.include?( link ).should be_true }
|
127
|
+
|
128
|
+
curator.all_external_links.count.should eq( 0 )
|
129
|
+
curator.extract_links_caption_from_post( hash_post ).should be_true
|
130
|
+
curator.all_external_links.count.should eq( ar_links_caption.count )
|
131
|
+
ar_links_caption.each { |link| curator.all_external_links.include?( link ).should be_true }
|
132
|
+
end
|
133
|
+
|
134
|
+
it "get external links from true target_post_url2" do
|
135
|
+
ar_links_caption = [ "www.flickr.com/photos/signsign86523/3842128766/in/photostream/lightbox/" ]
|
136
|
+
hash_post = curator.get_hash_post( "photonotdead.tumblr.com", 55109966565 )
|
137
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
138
|
+
|
139
|
+
ar_tofollow = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( hash_post["caption"] )
|
140
|
+
ar_tofollow.count.should eq( ar_links_caption.count )
|
141
|
+
ar_links_caption.each { |link| ar_tofollow.include?( link ).should be_true }
|
142
|
+
|
143
|
+
curator.all_external_links.count.should eq( 0 )
|
144
|
+
curator.extract_links_caption_from_post( hash_post ).should be_true
|
145
|
+
curator.all_external_links.count.should eq( ar_links_caption.count )
|
146
|
+
ar_links_caption.each { |link| curator.all_external_links.include?( link ).should be_true }
|
147
|
+
end
|
148
|
+
|
149
|
+
it "get tumblr and external links from true target_post_url1" do
|
150
|
+
ar_tumblr_links_caption = [ "solitaria.tumblr.com" ]
|
151
|
+
ar_external_links_caption = [ "www.flickr.com/photos/websterk3/7217711884/" ]
|
152
|
+
|
153
|
+
hash_post = curator.get_hash_post( "boob-shark.tumblr.com", 55272431819 )
|
154
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
155
|
+
|
156
|
+
ar_external = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( hash_post["caption"] )
|
157
|
+
ar_external.count.should eq( ar_external_links_caption.count )
|
158
|
+
ar_external_links_caption.each { |link| ar_external.include?( link ).should be_true }
|
159
|
+
|
160
|
+
ar_tumblr = CurateTumblr::Tumblr::ExtractLinks.get_tumblr_urls_from_text( hash_post["caption"] )
|
161
|
+
curator.all_external_links.count.should eq( 0 )
|
162
|
+
curator.all_tofollow_urls.count.should eq( 0 )
|
163
|
+
curator.extract_links_caption_from_post( hash_post ).should be_true
|
164
|
+
curator.all_external_links.count.should eq( ar_external_links_caption.count )
|
165
|
+
ar_external_links_caption.each { |link| curator.all_external_links.include?( link ).should be_true }
|
166
|
+
curator.all_tofollow_urls.count.should eq( ar_tumblr_links_caption.count )
|
167
|
+
ar_tumblr_links_caption.each { |link| curator.all_tofollow_urls.include?( link ).should be_true }
|
168
|
+
end
|
169
|
+
|
170
|
+
it "get tumblr and external links from true target_post_url2" do
|
171
|
+
File.delete( curator.get_filename_links ) if File.exists?( curator.get_filename_links )
|
172
|
+
File.delete( curator.get_filename_tofollow ) if File.exists?( curator.get_filename_tofollow )
|
173
|
+
File.delete( curator.get_filename_external_links ) if File.exists?( curator.get_filename_external_links )
|
174
|
+
ar_tumblr_links_caption = [ "autopsi-art.tumblr.com" ]
|
175
|
+
ar_external_links_caption = [ "fredblas.500px.com/home" ]
|
176
|
+
|
177
|
+
hash_post = curator.get_hash_post( "shhhgrrrl.tumblr.com", 55467043185 )
|
178
|
+
CurateTumblr.hash_post_valid?( hash_post ).should be_true
|
179
|
+
|
180
|
+
ar_external = CurateTumblr::Tumblr::ExtractLinks.get_external_urls_from_text( hash_post["caption"] )
|
181
|
+
ar_external.count.should eq( ar_external_links_caption.count )
|
182
|
+
ar_external_links_caption.each { |link| ar_external.include?( link ).should be_true }
|
183
|
+
|
184
|
+
ar_tumblr = CurateTumblr::Tumblr::ExtractLinks.get_tumblr_urls_from_text( hash_post["caption"] )
|
185
|
+
curator.all_external_links.count.should eq( 0 )
|
186
|
+
curator.all_tofollow_urls.count.should eq( 0 )
|
187
|
+
curator.extract_links_caption_from_post( hash_post ).should be_true
|
188
|
+
curator.all_external_links.count.should eq( ar_external_links_caption.count )
|
189
|
+
ar_external_links_caption.each { |link| curator.all_external_links.include?( link ).should be_true }
|
190
|
+
curator.all_tofollow_urls.count.should eq( ar_tumblr_links_caption.count )
|
191
|
+
ar_tumblr_links_caption.each { |link| curator.all_tofollow_urls.include?( link ).should be_true }
|
192
|
+
|
193
|
+
curator.add_tofollow_tofile.should be_true
|
194
|
+
ar_tofollow = CurateTumblr.get_ar_from_file( curator.get_filename_tofollow )
|
195
|
+
ar_tofollow.count.should eq( ar_tumblr_links_caption.count )
|
196
|
+
ar_tumblr_links_caption.each { |link| ar_tofollow.include?( link + "\n" ).should be_true }
|
197
|
+
|
198
|
+
curator.add_externallinks_tofile.should be_true
|
199
|
+
ar_external = CurateTumblr.get_ar_from_file( curator.get_filename_external_links )
|
200
|
+
ar_external.count.should eq( ar_external_links_caption.count )
|
201
|
+
ar_external_links_caption.each { |link| ar_external.include?( link + "\n" ).should be_true }
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Utilities Validate" do
|
4
|
+
include_context "shared targets"
|
5
|
+
|
6
|
+
describe "hash url" do
|
7
|
+
it "must be valid" do
|
8
|
+
hash_url = {:tumblr_url=>"terryrichardson.tumblr.com", :post_id=>"331417553"}
|
9
|
+
|
10
|
+
CurateTumblr.post_id_valid?( hash_url[:post_id] ).should be_true
|
11
|
+
CurateTumblr.hash_url_valid?( hash_url ).should be_true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "post" do
|
16
|
+
it "is post url" do
|
17
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( target_post_url ).should be_true
|
18
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( target_post_url2 ).should be_true
|
19
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( target_post_url3 ).should be_true
|
20
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( target_post_url4 ).should be_true
|
21
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( target_post_url5 ).should be_true
|
22
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( bad_target_post_url ).should be_false
|
23
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( bad_target_post_url2 ).should be_false
|
24
|
+
CurateTumblr::Tumblr::ExtractLinks.tumblr_post_url?( bad_target_post_url3 ).should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/factories.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'factory_girl'
|
2
|
+
|
3
|
+
def get_tumblr_name
|
4
|
+
"testitnowyeah13"
|
5
|
+
end
|
6
|
+
|
7
|
+
def get_tumblr_directory
|
8
|
+
"/home/david/Dropbox/curate_tumblr"
|
9
|
+
end
|
10
|
+
|
11
|
+
FactoryGirl.define do
|
12
|
+
factory :curator, class: CurateTumblr::Curator do
|
13
|
+
initialize_with { CurateTumblr::Curator.new( get_tumblr_name, get_tumblr_directory ) }
|
14
|
+
end
|
15
|
+
|
16
|
+
factory :render_reblog, class: CurateTumblr::Render::RenderReblog do
|
17
|
+
initialize_with { CurateTumblr::Render::RenderReblog.new( get_tumblr_name, get_tumblr_directory ) }
|
18
|
+
end
|
19
|
+
|
20
|
+
factory :render_follow, class: CurateTumblr::Render::RenderFollow do
|
21
|
+
initialize_with { CurateTumblr::Render::RenderFollow.new( get_tumblr_name, get_tumblr_directory ) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,203 @@
|
|
1
|
+
shared_context "shared targets" do
|
2
|
+
let(:target_name) { "terryrichardson" }
|
3
|
+
let(:target_tumblr) { target_name + ".tumblr.com" }
|
4
|
+
let(:target_post_id) { "331417553" }
|
5
|
+
let(:target_post_url) { "http://terryrichardson.tumblr.com/post/331417553/peekasso" }
|
6
|
+
let(:target_post_url2) { "terryrichardson.tumblr.com/post/331417553/peekasso" }
|
7
|
+
let(:target_post_url3) { "terryrichardson.tumblr.com/post/331417553" }
|
8
|
+
let(:target_post_url4) { "www.terryrichardson.tumblr.com/post/331417553" }
|
9
|
+
let(:target_post_url5) { "terryrichardson.tumblr.com/post/331417553" }
|
10
|
+
let(:bad_target_post_url) { "http://terryrichardson.tfumblr.com/post/331417553/peekasso" }
|
11
|
+
let(:bad_target_post_url2) { "terryrichardson.tumrblr.com/post/331417553/peekasso" }
|
12
|
+
let(:bad_target_post_url3) { "terryrichardson.tumbelr.com/post/331417553" }
|
13
|
+
let(:target_reblog_id) { "221532252" }
|
14
|
+
let(:target_reblog_key) { "xjqLOsiL" }
|
15
|
+
let(:target_reblog_url) { "http://www.tumblr.com/reblog/221532252/xjqLOsiL?redirect_to=http%3A%2F%2Fterryrichardson.tumblr.com%2Fpost%2F221532252&source=iframe" }
|
16
|
+
let(:target_reblog_id2) { "54773937436" }
|
17
|
+
let(:target_reblog_key2) { "x59hPgR7" }
|
18
|
+
let(:target_reblog_url2) { "http://www.tumblr.com/reblog/54773937436/x59hPgR7?redirect_to=%2Fdashboard" }
|
19
|
+
let(:target_reblog_id3) { "54774163481" }
|
20
|
+
let(:target_reblog_key3) { "2Ss9tBmk" }
|
21
|
+
let(:target_reblog_url3) { "http://www.tumblr.com/reblog/54774163481/2Ss9tBmk" }
|
22
|
+
|
23
|
+
let(:tofollow_target_url) { ["terryrichardson.tumblr.com"] }
|
24
|
+
end
|
25
|
+
|
26
|
+
shared_context "shared links" do
|
27
|
+
let(:links) { "http://terryrichardson.tumblr.com/post/332715869/terrysdiary-me-and-amy
|
28
|
+
http://terryrichardson.tumblr.com/post/237460623/via-journal-du-design
|
29
|
+
http://www.tumblr.com/reblog/54774163481/2Ss9tBmk
|
30
|
+
http://terryrichardson.tumblr.com/post/237446983/via-dosomething-studio
|
31
|
+
http://terryrichardson.tumblr.com/post/217269945
|
32
|
+
http://suicide-muse.tumblr.com/post/54616176043
|
33
|
+
http://www.tumblr.com/reblog/54773810226/HXKbdnPG
|
34
|
+
http://www.tumblr.com/reblog/221532252/xjqLOsiL?redirect_to=http%3A%2F%2Fterryrichardson.tumblr.com%2Fpost%2F221532252&source=iframe
|
35
|
+
http://terryrichardson.tumblr.com/post/236187313/douglasmartini-january-jones-by-terry
|
36
|
+
http://www.tumblr.com/reblog/54773937436/x59hPgR7?redirect_to=%2Fdashboard
|
37
|
+
http://terryrichardson.tumblr.com/post/231095946/suicideblonde-amy-winehouse-photographed-by" }
|
38
|
+
let(:ar_links) { links.lines( "\n" ) }
|
39
|
+
let(:count_reblogs) { ar_links.count }
|
40
|
+
let(:ar_tofollow) { ["terryrichardson.tumblr.com", "suicide-muse.tumblr.com", "c-isnenegro.tumblr.com", "douglasmartini.tumblr.com", "suicideblonde.tumblr.com"] }
|
41
|
+
end
|
42
|
+
|
43
|
+
shared_context "shared tumblrs" do
|
44
|
+
let(:tumblrs) { "terryrichardson.tumblr.com
|
45
|
+
suicide-muse.tumblr.com
|
46
|
+
trendgraphy.tumblr.com" }
|
47
|
+
let(:ar_tumblrs) { tumblrs.lines( "\n" ) }
|
48
|
+
let(:count_followed) { ar_tumblrs.count }
|
49
|
+
end
|
50
|
+
|
51
|
+
shared_context "shared caption post" do
|
52
|
+
let(:caption) { %Q{
|
53
|
+
The Boiler Room by
|
54
|
+
<em>
|
55
|
+
<a href="http://www.flickr.com/photos/42311564N00/9196902084/sizes/l/in/set-72157634452675984/" target="_blank">Sebastian Niedlich</a>
|
56
|
+
</em>
|
57
|
+
</p>
|
58
|
+
</blockquote>
|
59
|
+
|
60
|
+
<blockquote><p><a class="tumblr_blog" href="http://crystvllized.tumblr.com/post/52628833334/vintage-photography">crystvllized</a>:</p>
|
61
|
+
<blockquote>
|
62
|
+
|
63
|
+
<a href="https://secure.flickr.com/photos/71775774N00/138779654/in/photolist-dghmE-h35Rn-nD5A9-xmoXV-FJbbv-GMTgN-2rmHys-2tbDBU-4MxR5p-4MUsSe-4NSuTs-4Pg5Wc-4PNs3z-4UhLFj-51KCxw-51KCxA-51KCxE-51KFWf-54HwbA-58GXkV-5inow2-5DNPcu-5JgJG4-5T52Ct-5UcTXy-61EuXc-61EuXe-61EuXi-61EuXk-61EuXx-66EUqZ-6ieXBN-6oerp6-6v8CDX-6A84ud-6B6JRS-6J9keq-6Voa5Y-6VPsm3-6X4U6S-739VYC-739VYJ-739VYN-77B4i6-78bChk-7bFV9E-7e3pgC-7e3pgG-7efbRr-7ej5gG-7ej5qf">photo moon</a>
|
64
|
+
|
65
|
+
<a href="https://secure.flickr.com/photos/enchantedgarden/">Enchanted</a>
|
66
|
+
|
67
|
+
<p>
|
68
|
+
<span>(via</span>
|
69
|
+
<a href="http://www.sallyscott.com/catalogue/12autumn/">2012 Autumn Collection from Nikukyu Issue #11 | Sally Scott</a>
|
70
|
+
<span>)</span>
|
71
|
+
</p>
|
72
|
+
|
73
|
+
<blockquote>
|
74
|
+
<p>
|
75
|
+
The Boiler Room by
|
76
|
+
<em>
|
77
|
+
<a href="http://www.flickr.com/photos/42311564N00/9196902084/sizes/l/in/set-72157634452675984/" target="_blank">Sebastian Niedlich</a>
|
78
|
+
</em>
|
79
|
+
</p>
|
80
|
+
</blockquote>
|
81
|
+
|
82
|
+
<blockquote>
|
83
|
+
<p>
|
84
|
+
<a href="http://www.matthias-heiderich.com">Matthias Heiderich,</a>
|
85
|
+
Bilbao 2013
|
86
|
+
</p>
|
87
|
+
</blockquote>
|
88
|
+
|
89
|
+
<blockquote>
|
90
|
+
<p>
|
91
|
+
<a href="http://www.flickr.com/photos/signsign86523/3842128766/in/photostream/lightbox/">
|
92
|
+
<em>blue memories</em>
|
93
|
+
</a>
|
94
|
+
</p>
|
95
|
+
</blockquote>
|
96
|
+
|
97
|
+
<p><a href="http://ohshesolovely.tumblr.com/post/54988912158/marine-vacth-by-paolo-roversi" class="tumblr_blog">ohshesolovely</a>:</p>
|
98
|
+
|
99
|
+
<blockquote><p>Marine Vacth by Paolo Roversi</p></blockquote>
|
100
|
+
|
101
|
+
<p>
|
102
|
+
<a href="http://visualoptimism.blogspot.jp/2013/07/cache-and-carry-bette-franke-by-paul.html" target="_blank">Cache and CARRY - VOGUE UK August 2013 | Bette Franke By Paul Wetherell</a>
|
103
|
+
</p>
|
104
|
+
|
105
|
+
<small>
|
106
|
+
<a target="_blank" href="http://www.polyvore.com/ignore_me_im_dying_x_x/set?.embedder=2689265&.svc=tumblr&id=88758056">Ignore me Im dying x_x</a>
|
107
|
+
by
|
108
|
+
<a target="_blank" href="http://mich-0524.polyvore.com/?.embedder=2689265&.svc=tumblr">mich-0524</a>
|
109
|
+
featuring
|
110
|
+
<a target="_blank" href="http://www.polyvore.com/juicy_couture/shop?brand=Juicy+Couture">juicy couture</a>
|
111
|
+
liked on Polyvore
|
112
|
+
</small>
|
113
|
+
|
114
|
+
<p>
|
115
|
+
Carrie Bradshaw on We Heart It.
|
116
|
+
<a href="http://weheartit.com/entry/66354019/via/keepallmysecret" target="_blank">http://weheartit.com/entry/66354019/via/keepallmysecret</a>
|
117
|
+
</p>
|
118
|
+
|
119
|
+
<p>
|
120
|
+
<a href="http://overblackwaterpark.tumblr.com">http://overblackwaterpark.tumblr.com</a>
|
121
|
+
</p>
|
122
|
+
<p>
|
123
|
+
<a href="http://goodit.tumblr.com/">goodit</a>
|
124
|
+
</p>
|
125
|
+
<p>
|
126
|
+
<a href="http://www.tumblr.com/follow/overblackwaterpark">http://www.tumblr.com/follow/overblackwaterpark</a>
|
127
|
+
</p>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<p>
|
132
|
+
<a href="http://romanticnaturalism.tumblr.com/post/54923390988/let-it-rain-valeria-dmitrienko-in-alexander" class="tumblr_blog" target="_blank">romanticnaturalism</a>
|
133
|
+
:
|
134
|
+
</p>
|
135
|
+
<blockquote>
|
136
|
+
<p>
|
137
|
+
<em>Let It Rain</em>
|
138
|
+
- Valeria Dmitrienko in Alexander McQueen photographed by Nisian Hughes for Harper s Bazaar US August 2013
|
139
|
+
</p>
|
140
|
+
</blockquote>
|
141
|
+
|
142
|
+
|
143
|
+
<div class="post_body">
|
144
|
+
<p>
|
145
|
+
<a href="http://afleshfesten.tumblr.com/post/49434925020/damned" target="_blank" draggable="false">afleshfesten</a>
|
146
|
+
:
|
147
|
+
</p>
|
148
|
+
<blockquote>
|
149
|
+
<p>Damned !</p>
|
150
|
+
</blockquote>
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
<p>
|
155
|
+
<a class="tumblr_blog" href="http://abandonedography.com/post/55211207965/the-boiler-room-by-sebastian-niedlich" target="_blank">abandonedography</a>
|
156
|
+
:
|
157
|
+
</p>
|
158
|
+
<blockquote>
|
159
|
+
<p>
|
160
|
+
The Boiler Room by
|
161
|
+
<em>
|
162
|
+
<a href="http://www.flickr.com/photos/42311564N00/9196902084/sizes/l/in/set-72157634452675984/" target="_blank">Sebastian Niedlich</a>
|
163
|
+
</em>
|
164
|
+
</p>
|
165
|
+
</blockquote>
|
166
|
+
|
167
|
+
<blockquote><p><a class="tumblr_blog" href="http://crystvllized.tumblr.com/post/52628833334/vintage-photography">crystvllized</a>:</p>
|
168
|
+
<blockquote>
|
169
|
+
|
170
|
+
<p>
|
171
|
+
<span>(via</span>
|
172
|
+
<a href="http://www.sallyscott.com/catalogue/12autumn/">2012 Autumn Collection from Nikukyu Issue #11 | Sally Scott</a>
|
173
|
+
<span>)</span>
|
174
|
+
</p>
|
175
|
+
|
176
|
+
<blockquote>
|
177
|
+
<p>
|
178
|
+
<a href="http://www.matthias-heiderich.com">Matthias Heiderich,</a>
|
179
|
+
Bilbao 2013
|
180
|
+
</p>
|
181
|
+
</blockquote>
|
182
|
+
|
183
|
+
<blockquote>
|
184
|
+
<p>
|
185
|
+
<a href="http://www.flickr.com/photos/signsign86523/3842128766/in/photostream/lightbox/">
|
186
|
+
<em>blue memories</em>
|
187
|
+
</a>
|
188
|
+
</p>
|
189
|
+
</blockquote>
|
190
|
+
|
191
|
+
} }
|
192
|
+
let(:ar_links_caption_tumblrs) { [ "ohshesolovely.tumblr.com", "overblackwaterpark.tumblr.com", "goodit.tumblr.com", "romanticnaturalism.tumblr.com", "afleshfesten.tumblr.com", "crystvllized.tumblr.com" ] }
|
193
|
+
let(:source) { "goodit.tumblr.com" }
|
194
|
+
|
195
|
+
let(:link_follow) { "http://ze-aesthete.tumblr.com/post/54992829267/romanticnaturalism-let-it-rain-valeria" }
|
196
|
+
let(:count_caption_links_to_follow) { 1 }
|
197
|
+
end
|
198
|
+
|
199
|
+
shared_context "shared tags" do
|
200
|
+
let(:tags) { [ "test it !" ] }
|
201
|
+
let(:str_all_tags) { get_tumblr_test_tags + ", " + tags.join(", ") }
|
202
|
+
let(:all_tags) { str_all_tags.split(", ") }
|
203
|
+
end
|