tumblr_draftking 0.7.0.4

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 (39) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +7 -0
  3. data/CHANGELOG.md +80 -0
  4. data/LICENSE +67 -0
  5. data/README.md +293 -0
  6. data/Rakefile +22 -0
  7. data/bin/dk +7 -0
  8. data/lib/draftking/cli/cli_helpers.rb +61 -0
  9. data/lib/draftking/cli/cli_options.rb +31 -0
  10. data/lib/draftking/cli/commands/_template.rb +4 -0
  11. data/lib/draftking/cli/commands/accounts.rb +66 -0
  12. data/lib/draftking/cli/commands/blogs.rb +26 -0
  13. data/lib/draftking/cli/commands/comment.rb +34 -0
  14. data/lib/draftking/cli/commands/console.rb +18 -0
  15. data/lib/draftking/cli/commands/movedrafts.rb +33 -0
  16. data/lib/draftking/cli/commands/status.rb +24 -0
  17. data/lib/draftking/cli/commands/strip.rb +19 -0
  18. data/lib/draftking/cli/commands/tag.rb +21 -0
  19. data/lib/draftking/cli/commands/user_command.rb +45 -0
  20. data/lib/draftking/cli.rb +62 -0
  21. data/lib/draftking/client.rb +80 -0
  22. data/lib/draftking/config/config_setup.rb +56 -0
  23. data/lib/draftking/config.rb +151 -0
  24. data/lib/draftking/constants.rb +25 -0
  25. data/lib/draftking/dependency_patches.rb +2 -0
  26. data/lib/draftking/drafts.rb +53 -0
  27. data/lib/draftking/patches/thor.rb +12 -0
  28. data/lib/draftking/patches/tumblr_client.rb +10 -0
  29. data/lib/draftking/posts/post.rb +150 -0
  30. data/lib/draftking/posts/posts_helpers.rb +55 -0
  31. data/lib/draftking/posts.rb +173 -0
  32. data/lib/draftking/queue.rb +17 -0
  33. data/lib/draftking/reporter.rb +62 -0
  34. data/lib/draftking/tqueue/future_queue_methods.rb +97 -0
  35. data/lib/draftking/version.rb +3 -0
  36. data/lib/tasks/build.rake +33 -0
  37. data/lib/tasks/rubo.rake +36 -0
  38. data/lib/tumblr_draftking.rb +18 -0
  39. metadata +170 -0
@@ -0,0 +1,10 @@
1
+ module Tumblr
2
+ # Tumblr::Blog patch
3
+ module Blog
4
+ # Patch for a bug in the tumblr_client 0.8.5 gem
5
+ def draft(blog_name, options = {})
6
+ validate_options([:limit, :before_id], options)
7
+ get(blog_path(blog_name, 'posts/draft'), options)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,150 @@
1
+ require_relative 'posts_helpers'
2
+ include DK::Posts
3
+
4
+ module DK
5
+ # Tumblr Post
6
+ class Post
7
+ attr_accessor :id, :state, :tags, :comment, :summary, :reblog_key
8
+ attr_accessor :keep_tree, :changed, :saved, :blog_url
9
+ attr_accessor :image
10
+ attr_reader :data
11
+
12
+ # @param hash [Hash] Post Data
13
+ # @param keep_tree [Bool] Attach Reblog Tree?
14
+ def initialize(hash, keep_tree: nil)
15
+ return if hash.nil?
16
+ @data = JSON.parse(hash.to_json, object_class: OpenStruct)
17
+ @id = @data.id # hash['id']
18
+ @state = process_state(@data.state) # hash['state'])
19
+ @tags = @data.tags # hash['tags']
20
+ @comment = @data.reblog.comment # hash['reblog']['comment']
21
+ @summary = @data.summary # hash['summary']
22
+ @blog_url = tumblr_url(@data.blog_name) # hash['blog_name'])
23
+ @reblog_key = @data.reblog_key # hash['reblog_key']
24
+ @image = begin
25
+ @data.photos.first.original_size.url
26
+ rescue
27
+ nil
28
+ end
29
+ @keep_tree = keep_tree.nil? ? false : keep_tree
30
+ @changed = false
31
+ @saved = 0
32
+ end
33
+
34
+ # String of post data
35
+ def to_s
36
+ "id = #{@id}\n" \
37
+ "state = #{@state}\n" \
38
+ "tags = #{@tags}\n" \
39
+ "comment = #{@comment}\n" \
40
+ "summary = #{@summary}\n" \
41
+ "blog_url = #{@blog_url}\n" \
42
+ "reblog_key = #{@reblog_key}\n" \
43
+ "keep_tree = #{@keep_tree}\n" \
44
+ "changed = #{@changed}\n"
45
+ end
46
+
47
+ # Change the state of a post
48
+ # @param state [String] New State
49
+ def change_state(state)
50
+ return false unless VALID_STATE.include?(state)
51
+ return false if @state == state
52
+ @state = state
53
+ @changed = true
54
+ end
55
+
56
+ # Add a comment to a post
57
+ # @param comment [String] New Comment
58
+ def replace_comment_with(comment)
59
+ return false if comment.nil? || @comment.include?(comment)
60
+ @comment = comment
61
+ @changed = true
62
+ end
63
+
64
+ # Check if a post needs to be modified
65
+ # @param key_text [String] key_text
66
+ def has_key_text?(key_text)
67
+ return true if key_text.nil?
68
+ @comment.include?(key_text)
69
+ end
70
+
71
+ # Delete a Post
72
+ # @param client [Tumblr::Client] Instance of Tumblr Client
73
+ # @param simulate [Bool] Simulate Action?
74
+ def delete(client:, simulate: nil)
75
+ return 1 if simulate
76
+ res = client.delete @blog_url, @id
77
+ @changed = true if res['id']
78
+ res['id'] ? 1 : 0
79
+ end
80
+
81
+ # Reblog a Post
82
+ # @param client [Tumblr::Client] Instance of Tumblr Client
83
+ # @param simulate [Bool] Simulate Action?
84
+ def reblog(client:, simulate: nil)
85
+ return 1 if simulate
86
+ client.reblog @blog_url,
87
+ id: @id,
88
+ reblog_key: @reblog_key,
89
+ comment: @comment
90
+ end
91
+
92
+ # Save a post
93
+ # @param client [Tumblr::Client] Instance of Tumblr Client
94
+ # @param simulate [Bool] Simulate Action?
95
+ def save(client:, simulate: nil)
96
+ return 0 unless @changed
97
+ return @saved = 1 if simulate
98
+ res = client.edit @blog_url,
99
+ id: @id,
100
+ reblog_key: @reblog_key,
101
+ state: @state,
102
+ attach_reblog_tree: @keep_tree,
103
+ tags: @tags.join(','),
104
+ caption: @comment
105
+ return 0 unless res && res['id']
106
+ @changed = false
107
+ @saved = 1
108
+ end
109
+
110
+ # Generate post tags from post comment
111
+ # @param keep_tags [Bool] Preserve Existing Tags?
112
+ # @param add_tags [String] New tags
113
+ # @param exclude [String] Tags to exclude
114
+ # @param credit [Bool] Give draftking a tag credit
115
+ def generate_tags(keep_tags: nil, add_tags: nil, exclude: nil, credit: false)
116
+ tags = comment_to_tags(@comment)
117
+ tags += csv_to_a(add_tags) if add_tags
118
+ tags += @tags if keep_tags
119
+ tags << DK::CREDIT_TAG if credit
120
+ tags -= csv_to_a(exclude) if exclude
121
+ @changed = true unless @tags.sort.uniq == tags.sort.uniq
122
+ @tags = tags
123
+ end
124
+
125
+ # Remove existing Post tags
126
+ def clear_tags
127
+ @changed = true unless @tags.empty?
128
+ @tags = []
129
+ end
130
+
131
+ private
132
+
133
+ def process_state(state)
134
+ return DK::DRAFT unless state
135
+ return DK::QUEUE if state == 'queued'
136
+ state
137
+ end
138
+
139
+ def comment_to_tags(comment)
140
+ comment.gsub(HTML_TAG_PATTERN, '') # Remove HTML Tags
141
+ .gsub(%r{[\/\\|]}, ',') # Convert Separators
142
+ .gsub(' , ', ',') # Clean up tags
143
+ .split(',') # Return array
144
+ end
145
+
146
+ def csv_to_a(csv)
147
+ csv.split(',')
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,55 @@
1
+ module DK
2
+ # Helper Methods
3
+ module Posts
4
+ # Display progress percentage
5
+ # @param current [Int] Progress Counter
6
+ # @param total [Int] # Items to be processed
7
+ # @param message [String] Display message for process
8
+ # @param done [Bool] Processing Complete?
9
+ # @param modified [Int] # of items modified
10
+ def show_progress(current: 0, total: 0, message: '', done: false, modified: 0)
11
+ indicator, newline, progress = setup_done(modified) if done
12
+ indicator, newline, progress = setup_undone(current, total) unless done
13
+ print "#{indicator}#{message}#{progress}#{' ' * 30}\r#{newline}"
14
+ $stdout.flush unless done
15
+ end
16
+
17
+ # Values for displaying completed process
18
+ def setup_done(modified)
19
+ indicator = '√ '
20
+ newline = "\n"
21
+ progress = "(#{modified} modified)"
22
+ [indicator, newline, progress]
23
+ end
24
+
25
+ # Values for displaying in-progress process
26
+ def setup_undone(current, total)
27
+ tildes = current.to_i % 4
28
+ indicator = "~#{'~' * tildes}#{' ' * (3 - tildes)}> "
29
+ newline = nil
30
+ percentage = total > 0 ? ((current.to_f / total.to_f) * 100).round : 0
31
+ progress = "#{current} / #{total} [#{percentage}\%] "
32
+ [indicator, newline, progress]
33
+ end
34
+
35
+ # Construct Tumblr URL string
36
+ # @param blog_name [String] Blog Name
37
+ def tumblr_url(blog_name)
38
+ blog_name += '.tumblr.com' unless blog_name.include?('.')
39
+ blog_name
40
+ end
41
+
42
+ # Convert source symbol to string
43
+ # @param symbol [Symbol] Source Symbol
44
+ def source_string(symbol)
45
+ return 'draft' unless symbol
46
+ symbol.to_s
47
+ end
48
+
49
+ # index < limit
50
+ def index_within_limit?(index, limit)
51
+ return true if limit.nil? || limit.zero?
52
+ index < limit
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,173 @@
1
+ require_relative 'posts/posts_helpers'
2
+ require_relative 'posts/post'
3
+ require 'thread'
4
+
5
+ module DK
6
+ # Post operations common to queue/draft
7
+ module Posts
8
+ # Common code for Post operations
9
+ # @param options[:limit] [Int] Maximum number of posts to process
10
+ # @param options[:message] [String] Message to display during processing
11
+ # @param options[:shuffle] [Bool] Randomize order of posts
12
+ # @param options[:blog_name] [String] Name of blog to target
13
+ # @param options[:mute] [String] Suppress progress indicator
14
+ # @param options[:test_data] [[Hash]] Array of post hash data
15
+ # @param options[:simulate] [bool] Simulation?
16
+ # @return [int] Number of modified posts
17
+ def post_operation(options, &block)
18
+ work, total, results, reporter = setup_operation(options)
19
+ workers = (0...DK::MAX_THREADS).map { Thread.new { generate_worker(work, results, total, block) } }
20
+ workers.map(&:join)
21
+ mod_count, mod_posts = calculate_result(results)
22
+ show_progress(message: message, done: true, modified: mod_count) unless @mute
23
+ reporter.new(objects: mod_posts, title: REPORT_TITLE, fields: REPORT_FIELDS, simulate: @simulate).show unless @mute
24
+ act_on_blog(name: @blog_name) # Refresh account info
25
+ [mod_count, mod_posts]
26
+ end
27
+
28
+ # Work queue processor
29
+ def generate_worker(*data, block)
30
+ work, results, total = data
31
+ begin
32
+ while post = work.pop(true)
33
+ po = Post.new(post, keep_tree: @keep_tree)
34
+ block.call(po, results.size) # Do work on Post
35
+ po.save(client: @client, simulate: @simulate)
36
+ results.push(po)
37
+ show_progress(current: results.size, total: total, message: message) unless @mute
38
+ end
39
+ rescue ThreadError # Queue empty
40
+ end
41
+ end
42
+
43
+ # Common initialization for post operations
44
+ def setup_operation(options)
45
+ process_options(options)
46
+ act_on_blog(name: @blog_name)
47
+ posts = @shuffle ? get_posts.shuffle : get_posts
48
+ work = posts_to_queue(posts)
49
+ reporter = options[:reporter] || DK::Reporter
50
+ [work, work.size, Queue.new, reporter]
51
+ end
52
+
53
+ # Create queue of Posts for worker threads
54
+ def posts_to_queue(posts)
55
+ work_q = Queue.new
56
+ posts.each { |p| work_q.push(p) }
57
+ work_q
58
+ end
59
+
60
+ # Determine number of modified posts
61
+ def calculate_result(result_q)
62
+ mod_count = 0
63
+ mod_posts = []
64
+ return [mod_count, mod_posts] if result_q.empty?
65
+ while post = result_q.pop
66
+ mod_count += post.saved
67
+ mod_posts << post if post.saved > 0
68
+ break if result_q.empty?
69
+ end
70
+ [mod_count, mod_posts]
71
+ end
72
+
73
+ # Add a comment to Posts
74
+ # @param options[:credit] [Bool] Give dk credit?
75
+ # @param options[:comment] [string] String to add as comment
76
+ # @param options[:limit] [Int] Max number of modified posts
77
+ # @param options[:message] [String] Message to display during processing
78
+ # @param options[:source] [Symbol] Target posts from :draft or :queue
79
+ # @param options[:simulate] [bool] Simulation?
80
+ # @param options[:mute] [String] Suppress progress indicator
81
+ # @return [int] Number of modified posts
82
+ def comment_posts(options = {})
83
+ src = source_string(options[:source])
84
+ options[:message] = "Adding #{src} comment \'#{comment}\': "
85
+ mod_count, _mod_posts = post_operation(options) do |post, _|
86
+ post.replace_comment_with(@comment)
87
+ post.generate_tags(keep_tags: @keep_tags,
88
+ add_tags: @tags,
89
+ exclude: @comment,
90
+ credit: @credit) if @auto_tag
91
+ end
92
+ mod_count
93
+ end
94
+
95
+ # @param options[:credit] [Bool] Give dk credit?
96
+ # @param options[:source] [Symbol] Target posts from :draft or :queue
97
+ # @param options[:mute] [String] Suppress progress indicator
98
+ # @param options[:blog_name] [String] Name of blog to target
99
+ # @param options[:keep_tags] [bool] Preserve existing post tags
100
+ # @param options[:keep_tree] [bool] Preserve existing post comments
101
+ # @param options[:simulate] [bool] Simulation?
102
+ # @param options[:comment] [String] Exclude :comment from tags
103
+ # @return [int] Number of modified posts
104
+ def tag_posts(options)
105
+ src = source_string(options[:source])
106
+ options[:message] = "Tagging #{src} with #{options[:add_tags]}: "
107
+ mod_count, _mod_posts = post_operation(options) do |post, _|
108
+ post.generate_tags(keep_tags: @keep_tags,
109
+ add_tags: @tags,
110
+ exclude: @comment,
111
+ credit: @credit) if @auto_tag
112
+ end
113
+ mod_count
114
+ end
115
+
116
+ # Determine draft data to use.
117
+ # @param options[:test_data] [[Hash]] Array of post hash data
118
+ # @param options[:limit] [Int] Limit # of posts selected
119
+ # @param options[:blog_url] [string] URL of blog to read from
120
+ # @param options[:source] [Symbol] Get posts from :draft or :queue
121
+ # @param options[:before_id] [Int] [:draft] ID of post to begin reading from
122
+ # @param options[:offset] [Int] [:queue] Post index to start reading from
123
+ # @return [[Post]] Array of Post Hash data
124
+ def get_posts
125
+ return some_test_data if @test_data
126
+ return all_posts.uniq unless @limit
127
+ return some_posts(offset: @offset, before_id: @before_id) if @limit <= 50
128
+ limited_posts
129
+ end
130
+
131
+ # Get up to 50 Posts
132
+ # @param before_id [Int] [:draft] ID of post to begin reading from
133
+ # @param offset [Int] [:queue] Post index to start reading from
134
+ # @return [[Post]] Array of Post Hash data
135
+ def some_posts(before_id: 0, offset: 0)
136
+ options = { limit: [(@limit || 50), 50].min }
137
+ options[@source == :draft ? :before_id : :offset] = (@source == :draft ? before_id : offset)
138
+
139
+ result = @client.send(@source, @blog_url, options).first[1]
140
+ result.is_a?(Integer) ? [] : result
141
+ end
142
+
143
+ # Get @limit # of Posts
144
+ def limited_posts
145
+ result = []
146
+ until result.size >= @limit
147
+ chunk = some_posts(offset: @offset, before_id: @before_id)
148
+ break if chunk.empty?
149
+ result += chunk
150
+ @offset = chunk.size
151
+ @before_id = chunk.last['id']
152
+ end
153
+ result.take(@limit)
154
+ end
155
+
156
+ # Collect all Posts
157
+ # @param last_id [Int] ID of post to begin reading from (for reading Drafts)
158
+ # @param offset [Int] Post index to start reading from (for reading Queue)
159
+ # @param blog_url [string] URL of blog to read from
160
+ # @param source [Symbol] Get posts from :draft or :queue
161
+ # @return [[Post]] Array of Post Hash data
162
+ def all_posts(last_id: 0, offset: 0)
163
+ chunk = some_posts(before_id: last_id, offset: offset)
164
+ return chunk if chunk.empty?
165
+ chunk + all_posts(last_id: chunk.last['id'], offset: offset + chunk.size)
166
+ end
167
+
168
+ # Handle limits for test data
169
+ def some_test_data
170
+ @limit ? @test_data.take(@limit) : @test_data
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,17 @@
1
+ module DK
2
+ #----------------------------- Queue Methods ----------------------------- #
3
+ module TQueue
4
+ # Move from Queue to Drafts
5
+ # @param options[:key_text] [String] Move posts not containing :key_text
6
+ # @return [Int] Number of modified posts
7
+ def move_to_drafts(options)
8
+ options[:message] = 'Moving Queue ~> Drafts: '
9
+ options[:shuffle] = false
10
+ options[:state] = DK::DRAFT
11
+ mod_count, _mod_posts = post_operation(options) do |post, _|
12
+ post.changed = !post.has_key_text?(@key_text)
13
+ end
14
+ mod_count
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,62 @@
1
+ require 'terminal-table'
2
+
3
+ module DK
4
+ # Generate report of object data
5
+ class Reporter
6
+ attr_accessor :headers, :rows, :fields, :title, :objects, :last
7
+ def initialize(opts)
8
+ @objects = opts[:objects]
9
+ @title = build_title(opts)
10
+ @rows = opts[:rows]
11
+ @fields = @rows ? nil : populate_fields(opts[:fields], @objects.first)
12
+ @headers = populate_headers(opts[:headers])
13
+ end
14
+
15
+ # Report Title
16
+ # @param opts[:simulate] [Boolean] Show simulation indicator
17
+ # @param opts[:title] [String] Report Title
18
+ def build_title(opts)
19
+ "#{opts[:title]}#{REPORT_SIM if opts[:simulate]}"
20
+ end
21
+
22
+ # Determine Field List
23
+ # @param fields [[Symbol]] Field Symbol Array
24
+ # @param obj [Object] Example Object
25
+ # @return [[Symbol]] Field List
26
+ def populate_fields(fields, obj = nil)
27
+ # Report all fields, unless specified.
28
+ return fields if fields
29
+ obj.instance_variables.map do |x|
30
+ x = x.to_s.delete('@')
31
+ obj.respond_to?(x) ? x : nil
32
+ end.compact if obj
33
+ end
34
+
35
+ # Determine Display Headers
36
+ # @param headers [[String]] Column Headers
37
+ # @return [[String]]
38
+ def populate_headers(headers)
39
+ # Use field names as headers, unless specified
40
+ return headers if headers
41
+ return @fields.map(&:to_s) if @fields
42
+ end
43
+
44
+ # Collect report data
45
+ def populate_report_rows
46
+ # Read data based on field list
47
+ return if @rows
48
+ @rows = []
49
+ @objects.each do |object|
50
+ @rows << @fields.map { |field| object.send(field.to_sym) }
51
+ end
52
+ end
53
+
54
+ # Display Report
55
+ def show
56
+ populate_report_rows
57
+ opts = { rows: @rows, headings: @headers || [], title: @title }
58
+ puts Terminal::Table.new(opts) unless @rows.empty?
59
+ end
60
+ alias to_s show
61
+ end
62
+ end
@@ -0,0 +1,97 @@
1
+
2
+ # # Get a list of Queued posts
3
+ # # @param offset [Integer] return queued posts starting with offset index
4
+ # # @return [[Post]] Array of Post JSON objects
5
+ # def some_queue(offset = 0, limit = 1)
6
+ # queue = @client.queue @blog_url, offset: offset, limit: limit
7
+ # queue.first[1]
8
+ # end
9
+ #
10
+ # # Collect entire Queue
11
+ # # @note reads in chunks of 20 posts, so runtime can be slow.
12
+ # # @return [[Post]] Array of Post JSON objects
13
+ # def all_queue
14
+ # queue = []
15
+ # offset = 0
16
+ # loop do
17
+ # q_t = @client.queue(@blog_url, offset: offset, limit: 50).first[1]
18
+ # break if q_t.empty?
19
+ # offset += q_t.size
20
+ # queue += q_t
21
+ # end
22
+ # queue
23
+ # end
24
+
25
+ # # Add a comment to Queue
26
+ # # @param caption [string] String to add as caption
27
+ # # @param options[:all] [bool] Process entire Queue
28
+ # # @param options[:skip] [String] Do not modify Queued posts that contain string
29
+ # # @return [Integer] Number of posts modified
30
+ # def comment_queue(caption, options)
31
+ # queue = options[:all] ? all_queue : some_queue(0, 50)
32
+ # skip = options[:skip]
33
+ # modified = 0
34
+ # if skip.nil?
35
+ # queue.each do |d|
36
+ # @client.edit @blog_url, id: d['id'], reblog_key: d['reblog_key'], caption: caption, state: 'queue'
37
+ # modified += 1
38
+ # end
39
+ # else
40
+ # queue.each do |d|
41
+ # next if d['summary'].include?(skip)
42
+ # @client.edit @blog_url, id: d['id'], reblog_key: d['reblog_key'], caption: caption, state: 'queue'
43
+ # modified += 1
44
+ # end
45
+ # end
46
+ # modified
47
+ # end
48
+
49
+ # # Tag Queued posts from comment
50
+ # # @return [Integer] Number of posts modified
51
+ # def tag_queue
52
+ # puts 'Tagging Queue'
53
+ # queue = all_queue
54
+ # mod = 0
55
+ # queue.each do |d|
56
+ # caption = d['summary']
57
+ # next unless caption.include?('/')
58
+ # tags = caption.gsub(%r{[\/\\|]}, ',').gsub(' , ', ',') # Tag with caption
59
+ # puts "#{caption} => #{tags}"
60
+ # @client.edit @blog_url, id: d['id'], reblog_key: d['reblog_key'], caption: caption, tags: tags, state: 'draft'
61
+ # @client.edit @blog_url, id: d['id'], reblog_key: d['reblog_key'], caption: caption, tags: tags, state: 'queue'
62
+ # mod += 1
63
+ # end
64
+ # puts 'Done'
65
+ # puts "Tags added to #{mod} queue posts"
66
+ # mod
67
+ # end
68
+
69
+ # def auto_post(hours = 24, post_count = 50)
70
+ # puts "Auto-posting #{post_count} posts over #{hours} hours:"
71
+ # seconds = hours * 60 * 60
72
+ # sleep_time = seconds / post_count
73
+ # delay_in_mins = sleep_time / 60
74
+ # offset = 0
75
+ # limit = 1
76
+ # posts_left = post_count
77
+ # post_count.times do
78
+ # if posts_available && posts_left > 0
79
+ # publish_post(some_queue(offset, limit).first)
80
+ # posts_left -= 1
81
+ # if posts_available && posts_left > 0
82
+ # puts "Next post at #{Time.now + (delay_in_mins * 60)} mins"
83
+ # sleep sleep_time
84
+ # end
85
+ # else
86
+ # puts 'Processing complete!'
87
+ # break
88
+ # end
89
+ # end
90
+ # end
91
+ #
92
+ # def publish_post(d)
93
+ # prInteger "Posting: #{d['summary']} .."
94
+ # @client.edit @blog_url, id: d['id'], reblog_key: d['reblog_key'], caption: d['summary'], tags: d['tags'], state: 'published'
95
+ # @q_size -= 1
96
+ # puts '.Done'
97
+ # end
@@ -0,0 +1,3 @@
1
+ module DK
2
+ VERSION = '0.7.0.4'.freeze
3
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '../../codeclimate.rb'
2
+ include BuildVars
3
+
4
+ namespace :build do
5
+ desc 'Build gem.'
6
+ task :gem do
7
+ Rake::Task['build:readme'].execute
8
+ `gem build tumblr_draftking.gemspec`
9
+ end
10
+
11
+ desc 'Build and install gem.'
12
+ task :install do
13
+ Rake::Task['build:gem'].execute
14
+ file = `ls -1r *.gem | head -n 1`
15
+ puts `gem install #{file}`
16
+ end
17
+
18
+ desc 'Inject table of contents into README.md'
19
+ task :readme do
20
+ `ruby readme/generate.rb`
21
+ end
22
+
23
+ desc 'Prepare gem deployment.'
24
+ task :deployment do
25
+ ENV['CODECLIMATE_REPO_TOKEN'] = CODECLIMATE_REPO_TOKEN
26
+ ENV['CI_FLAG'] = 'true'
27
+ Rake::Task['rubo:fix'].execute
28
+ puts Rake::Task['test'].execute
29
+ puts Rake::Task['build:gem'].execute
30
+ end
31
+ end
32
+
33
+ task build: ['build:install']
@@ -0,0 +1,36 @@
1
+ namespace :rubo do
2
+ desc 'Generate and display Rubocop HTML report.'
3
+ task :html do
4
+ `rubocop -f html -D --out rubocop/report.html`
5
+ end
6
+
7
+ desc 'Autofix Issues.'
8
+ task :fix do
9
+ `rubocop -a`
10
+ Rake::Task['rubo:html'].execute
11
+ end
12
+
13
+ desc 'AutoFix issues and display report.'
14
+ task :fix_report do
15
+ Rake::Task['rubo:fix'].execute
16
+ Rake::Task['rubo:gen_report'].execute
17
+ end
18
+
19
+ desc 'Regenerate To Do .yml'
20
+ task :autogen do
21
+ `rubocop --auto-gen-config`
22
+ end
23
+
24
+ desc 'Show rubocop HTML report'
25
+ task :gen_report do
26
+ `open rubocop/report.html`
27
+ end
28
+
29
+ desc 'Show rubocop HTML report'
30
+ task :report do
31
+ Rake::Task['rubo:html'].execute
32
+ Rake::Task['rubo:gen_report'].execute
33
+ end
34
+ end
35
+
36
+ task rubo: ['rubo:fix_report']
@@ -0,0 +1,18 @@
1
+ require 'bundler/setup'
2
+ require 'yaml'
3
+ require 'tumblr_client'
4
+ require 'thor'
5
+
6
+ # Workarounds for issues with depended upon projects
7
+ require_relative 'draftking/dependency_patches'
8
+
9
+ # dk
10
+ require_relative 'draftking/constants'
11
+ require_relative 'draftking/version'
12
+ require_relative 'draftking/cli'
13
+ require_relative 'draftking/config'
14
+ require_relative 'draftking/posts'
15
+ require_relative 'draftking/drafts'
16
+ require_relative 'draftking/queue'
17
+ require_relative 'draftking/client'
18
+ require_relative 'draftking/reporter'