Class: IDeleteMyTweets::CommandConvert

Inherits:
Thor
  • Object
show all
Includes:
Presenter
Defined in:
lib/i_delete_my_tweets/cli.rb

Constant Summary collapse

KEYS =
%w(id retweet_count favorite_count created_at full_text).freeze
HEADERS =
%w(tweet_id retweet_count favorite_count created_at text).freeze

Constants included from Presenter

Presenter::COLORS, Presenter::TABLE_STYLE

Instance Method Summary collapse

Methods included from Presenter

#summary, #to_date, #to_human_time, #truncate, #tweet_not_found, #tweet_presenter

Instance Method Details

#js_to_json(path_to_tweets_js) ⇒ Object



25
26
27
28
29
# File 'lib/i_delete_my_tweets/cli.rb', line 25

def js_to_json(path_to_tweets_js)
  system(%(sed -i"" -e "s/window.YTD.tweet.part0 = //g" #{path_to_tweets_js}))
rescue StandardError => e
  say_error e.message
end

#to_csv(path_to_tweets_js) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/i_delete_my_tweets/cli.rb', line 13

def to_csv(path_to_tweets_js)
  if js_to_json(path_to_tweets_js)
    save_to_csv(path_to_tweets_js)
    say set_color " ✅ Success: << #{path_to_tweets_js} >> was converted to << converted_tweets_js.csv >>!", :white, :on_green, :bold
  else
    say set_color " 🚫 Something went wrong with sed. Make sure you have it available in your terminal. ", :white, :on_red, :bold
  end
rescue StandardError => e
  say_error e.message
end