Class: Twitter2Mastodon::Configuration
- Inherits:
-
Object
- Object
- Twitter2Mastodon::Configuration
- Defined in:
- lib/twitter2mastodon/configuration.rb
Instance Attribute Summary collapse
-
#mastodon ⇒ Object
readonly
Returns the value of attribute mastodon.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
-
#initialize(config_file) ⇒ Configuration
constructor
A new instance of Configuration.
- #mastodon_client ⇒ Object
- #twitter_client ⇒ Object
Constructor Details
#initialize(config_file) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 |
# File 'lib/twitter2mastodon/configuration.rb', line 8 def initialize(config_file) file = File.(config_file) raise ArgumentError, "No file provided" unless File.exist?(file) configuration = YAML.load_file(file) @users = configuration["users"].map { |user| user.downcase } @twitter = configuration["twitter"] @mastodon = configuration["mastodon"] end |
Instance Attribute Details
#mastodon ⇒ Object (readonly)
Returns the value of attribute mastodon.
6 7 8 |
# File 'lib/twitter2mastodon/configuration.rb', line 6 def mastodon @mastodon end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
6 7 8 |
# File 'lib/twitter2mastodon/configuration.rb', line 6 def twitter @twitter end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
6 7 8 |
# File 'lib/twitter2mastodon/configuration.rb', line 6 def users @users end |
Instance Method Details
#mastodon_client ⇒ Object
27 28 29 |
# File 'lib/twitter2mastodon/configuration.rb', line 27 def mastodon_client Mastodon::REST::Client.new(base_url: mastodon["base_url"], bearer_token: mastodon["bearer_token"]) end |
#twitter_client ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/twitter2mastodon/configuration.rb', line 18 def twitter_client Twitter::REST::Client.new do |config| config.consumer_key = twitter["consumer_key"] config.consumer_secret = twitter["consumer_secret"] config.access_token = twitter["access_token"] config.access_token_secret = twitter["access_token_secret"] end end |