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.
Files changed (41) hide show
  1. data/.project +18 -0
  2. data/README.md +219 -0
  3. data/Rakefile +0 -0
  4. data/curate_tumblr.gemspec +12 -0
  5. data/example/kubricklove/kubricklove_config.yaml +20 -0
  6. data/example/kubricklove/links/kubricklove_links +4 -0
  7. data/example/kubricklove_follow.rb +6 -0
  8. data/example/kubricklove_reblog.rb +6 -0
  9. data/example/readme +9 -0
  10. data/lib/curate_tumblr.rb +25 -0
  11. data/lib/curate_tumblr/curator.rb +200 -0
  12. data/lib/curate_tumblr/publish/follow.rb +62 -0
  13. data/lib/curate_tumblr/publish/post.rb +21 -0
  14. data/lib/curate_tumblr/publish/reblog.rb +86 -0
  15. data/lib/curate_tumblr/render/render_follow.rb +29 -0
  16. data/lib/curate_tumblr/render/render_links.rb +132 -0
  17. data/lib/curate_tumblr/render/render_reblog.rb +36 -0
  18. data/lib/curate_tumblr/tumblr/client.rb +347 -0
  19. data/lib/curate_tumblr/tumblr/extract_links.rb +190 -0
  20. data/lib/curate_tumblr/tumblr/infos.rb +102 -0
  21. data/lib/curate_tumblr/utilities/monkey.rb +5 -0
  22. data/lib/curate_tumblr/utilities/utilities.rb +4 -0
  23. data/lib/curate_tumblr/utilities/utilities_client.rb +103 -0
  24. data/lib/curate_tumblr/utilities/utilities_file.rb +50 -0
  25. data/lib/curate_tumblr/utilities/utilities_format.rb +91 -0
  26. data/lib/curate_tumblr/utilities/utilities_validate.rb +54 -0
  27. data/lib/curate_tumblr/values.rb +22 -0
  28. data/spec/curate_tumblr/curator_spec.rb +36 -0
  29. data/spec/curate_tumblr/publish/follow_spec.rb +183 -0
  30. data/spec/curate_tumblr/publish/post_spec.rb +45 -0
  31. data/spec/curate_tumblr/publish/reblog_spec.rb +118 -0
  32. data/spec/curate_tumblr/render/render_follow_spec.rb +36 -0
  33. data/spec/curate_tumblr/render/render_reblog_spec.rb +73 -0
  34. data/spec/curate_tumblr/tumblr/client_spec.rb +69 -0
  35. data/spec/curate_tumblr/tumblr/extract_links_spec.rb +204 -0
  36. data/spec/curate_tumblr/utilities/utilities_validate_spec.rb +27 -0
  37. data/spec/factories.rb +24 -0
  38. data/spec/shared_examples.rb +2 -0
  39. data/spec/shared_values.rb +203 -0
  40. data/spec/spec_helper.rb +95 -0
  41. metadata +116 -0
@@ -0,0 +1,95 @@
1
+ require 'rspec'
2
+ require 'set'
3
+ require 'random-word'
4
+
5
+ require './lib/curate_tumblr'
6
+ require 'factories'
7
+ require 'shared_values'
8
+ require 'shared_examples'
9
+
10
+ def get_tumblr_test_tags
11
+ "photo, test"
12
+ end
13
+
14
+ def get_tumblr_test_title
15
+ "<b>*" + RandomWord.adjs.next + " " + RandomWord.nouns.next + "*</b> " + Time.now.localtime.strftime("%H:%m")
16
+ end
17
+
18
+ def get_post_title
19
+ "Post " + Time.now.localtime.strftime("%H:%m")
20
+ end
21
+
22
+ def get_post_text
23
+ RandomWord.nouns.next + " " + RandomWord.nouns.next + " " + RandomWord.nouns.next
24
+ end
25
+
26
+ def get_config_filename
27
+ "test_config.yaml"
28
+ end
29
+
30
+ def get_random_config_hash
31
+ hash_config = {}
32
+ hash_config.merge!( CurateTumblr::Tumblr::Client::get_client_config_hash( RandomWord.nouns.next, RandomWord.nouns.next, RandomWord.nouns.next, RandomWord.nouns.next ) )
33
+ hash_config.merge!( CurateTumblr::Tumblr::Infos::get_infos_config_hash )
34
+ hash_config
35
+ end
36
+
37
+ def get_random_ar_tumblrs( count )
38
+ ar_tumblrs = []
39
+ count.times do
40
+ ar_tumblrs << RandomWord.nouns.next + ".tumblr.com"
41
+ end
42
+ ar_tumblrs
43
+ end
44
+
45
+ def get_random_id_post
46
+ id = ""
47
+ 6.times { id += rand(9).to_s }
48
+ id
49
+ end
50
+
51
+ def get_random_ar_posts_from_tumblrs( ar_tumblrs )
52
+ ar_tumblrs_posts = []
53
+ ar_tumblrs.each { |link| ar_tumblrs_posts << link + "/post/" + get_random_id_post }
54
+ ar_tumblrs_posts
55
+ end
56
+
57
+ def display_infos( curator )
58
+ if curator.sandbox?
59
+ puts "\n*** SANDBOX : no post will be sent to tumblr (nothing will be published) ***"
60
+ else
61
+ if curator.state.match( CurateTumblr::POST_STATE_QUEUE )
62
+ str_state = 'IN QUEUE (not visible in blog, please CHECK queue will not be full !)'
63
+ warning = "if all tests fail, please check there is enough space in #{curator.domain} queue"
64
+ else
65
+ str_state = 'published'
66
+ warning = "if all tests fail, please check you have not published 100 posts today in #{curator.domain}"
67
+ end
68
+ puts "\nTests from post will be #{str_state} in #{curator.domain}\n(wait #{curator.sleep_before_post_sec}sec before each post) (links in #{curator.filename_links})"
69
+ end
70
+ end
71
+
72
+ def files_before( render, links='' )
73
+ File.delete( render.filename_links ) if File.exists?( render.filename_links )
74
+ File.open( render.filename_links, 'w' ) { |file| file.puts links }
75
+ end
76
+
77
+ def files_after( render )
78
+ File.delete( render.filename_links ) if File.exists?( render.filename_links )
79
+ end
80
+
81
+ def get_status_rate_exceed
82
+ { "status" => 429, "msg" => "Rate Limit Exceeded" }
83
+ end
84
+
85
+ def get_status_ok
86
+ {"status"=>200, "msg"=>"Ok"} # in real when ok receive hash of post, not a status
87
+ end
88
+
89
+ def test_post_hash_contains_tags( hash_post, ar_tags )
90
+ CurateTumblr::Utils.hash_post_valid?( hash_post ).should be_true
91
+ hash_post.has_key?("tags").should be_true
92
+ hash_post["tags"].is_a?( Array ).should be_true
93
+ hash_post["tags"].count.should eq( ar_tags.count )
94
+ ar_tags.each { |tag| hash_post["tags"].include?( tag ).should be_true }
95
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: curate_tumblr
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Tysman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tumblr_client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: logger
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: CurateTumblr - reblog and follow Tumblr links
47
+ email: web@davidtysman.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - .project
53
+ - README.md
54
+ - Rakefile
55
+ - curate_tumblr.gemspec
56
+ - example/kubricklove/kubricklove_config.yaml
57
+ - example/kubricklove/links/kubricklove_links
58
+ - example/kubricklove_follow.rb
59
+ - example/kubricklove_reblog.rb
60
+ - example/readme
61
+ - lib/curate_tumblr.rb
62
+ - lib/curate_tumblr/curator.rb
63
+ - lib/curate_tumblr/publish/follow.rb
64
+ - lib/curate_tumblr/publish/post.rb
65
+ - lib/curate_tumblr/publish/reblog.rb
66
+ - lib/curate_tumblr/render/render_follow.rb
67
+ - lib/curate_tumblr/render/render_links.rb
68
+ - lib/curate_tumblr/render/render_reblog.rb
69
+ - lib/curate_tumblr/tumblr/client.rb
70
+ - lib/curate_tumblr/tumblr/extract_links.rb
71
+ - lib/curate_tumblr/tumblr/infos.rb
72
+ - lib/curate_tumblr/utilities/monkey.rb
73
+ - lib/curate_tumblr/utilities/utilities.rb
74
+ - lib/curate_tumblr/utilities/utilities_client.rb
75
+ - lib/curate_tumblr/utilities/utilities_file.rb
76
+ - lib/curate_tumblr/utilities/utilities_format.rb
77
+ - lib/curate_tumblr/utilities/utilities_validate.rb
78
+ - lib/curate_tumblr/values.rb
79
+ - spec/curate_tumblr/curator_spec.rb
80
+ - spec/curate_tumblr/publish/follow_spec.rb
81
+ - spec/curate_tumblr/publish/post_spec.rb
82
+ - spec/curate_tumblr/publish/reblog_spec.rb
83
+ - spec/curate_tumblr/render/render_follow_spec.rb
84
+ - spec/curate_tumblr/render/render_reblog_spec.rb
85
+ - spec/curate_tumblr/tumblr/client_spec.rb
86
+ - spec/curate_tumblr/tumblr/extract_links_spec.rb
87
+ - spec/curate_tumblr/utilities/utilities_validate_spec.rb
88
+ - spec/factories.rb
89
+ - spec/shared_examples.rb
90
+ - spec/shared_values.rb
91
+ - spec/spec_helper.rb
92
+ homepage: https://github.com/davidtysman/curate_tumblr
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.24
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Reblog and follow Tumblr
116
+ test_files: []