* Clarify uncommunicative variables in labor classes Single letter variable names are largely a question of preference, in some cases I think that convention mitigates the opaque nature of single letter variable names (e.g., e for error, i for index, etc). However, in some cases they can be unclear and there isn't much reason to use single letter variables unless for some reason character length is really important. In this case, I would prefer clarity in variable names over brevity of code so I've used Reek to identify short variable names and I'm changing them. It's pretty boring, but hopefully incremental code love changes like this one add up and improve readability and accessibility for those interested in reading this codebase. * Remove commented code from 2 years ago * Clarify uncommunicative naming in services classes There is some context for this change in 6b81880f * Clarify uncommunicative naming in models There is some context for this change in 6b81880f * Clarify uncommunicative naming in liquid_tags There is some context for this change in 6b81880f
54 lines
1.6 KiB
Ruby
54 lines
1.6 KiB
Ruby
class Bufferizer
|
|
attr_accessor :post_type, :post, :text
|
|
def initialize(post_type, post, text)
|
|
if post_type == "article"
|
|
@article = post
|
|
else
|
|
@listing = post
|
|
end
|
|
@text = text
|
|
end
|
|
|
|
def satellite_tweet!
|
|
@article.tags.find_each do |tag|
|
|
BufferUpdate.buff!(@article.id, twitter_buffer_text, tag.buffer_profile_id_code, "twitter", tag.id) if tag.buffer_profile_id_code.present?
|
|
end
|
|
@article.update(last_buffered: Time.current)
|
|
end
|
|
|
|
def main_tweet!
|
|
BufferUpdate.buff!(@article.id, twitter_buffer_text, ApplicationConfig["BUFFER_TWITTER_ID"], "twitter", nil)
|
|
@article.update(last_buffered: Time.current)
|
|
end
|
|
|
|
def facebook_post!
|
|
BufferUpdate.buff!(@article.id, fb_buffer_text, ApplicationConfig["BUFFER_FACEBOOK_ID"], "facebook")
|
|
BufferUpdate.buff!(@article.id, fb_buffer_text + social_tags, ApplicationConfig["BUFFER_LINKEDIN_ID"], "linkedin")
|
|
@article.update(facebook_last_buffered: Time.current)
|
|
end
|
|
|
|
def listings_tweet!
|
|
buffer_listings_id = ApplicationConfig["BUFFER_LISTINGS_PROFILE"]
|
|
BufferUpdate.send_to_buffer(listings_twitter_text, buffer_listings_id)
|
|
@listing.update(last_buffered: Time.current)
|
|
end
|
|
|
|
private
|
|
|
|
def twitter_buffer_text
|
|
"#{text} https://dev.to#{@article.path}" if text.size <= 255
|
|
end
|
|
|
|
def fb_buffer_text
|
|
"#{text} https://dev.to#{@article.path}"
|
|
end
|
|
|
|
def social_tags
|
|
# for linkedin's followable tags
|
|
" #programming #softwareengineering " + (@article.tag_list.map { |tag| "#" + tag }).join(" ")
|
|
end
|
|
|
|
def listings_twitter_text
|
|
"#{text} https://dev.to#{@listing.path}" if text.size <= 255
|
|
end
|
|
end
|