### Install X Ruby Gem Source: https://github.com/sferik/x-ruby/blob/main/README.md Instructions for installing the `x` gem, which provides a Ruby interface to the X API. You can install it using Bundler for dependency management or directly via `gem install`. ```shell bundle add x ``` ```shell gem install x ``` -------------------------------- ### Install X Ruby Dependencies Source: https://github.com/sferik/x-ruby/blob/main/README.md Installs the necessary Ruby gem dependencies for the X project using Bundler. ```Shell bin/setup ``` -------------------------------- ### Verify Ruby Code Standard Compliance Source: https://github.com/sferik/x-ruby/blob/main/README.md Checks if the Ruby code conforms to the Standard Ruby style guide. ```Shell bundle exec rake standard ``` -------------------------------- ### Initialize X API v1.1 Client with Custom Response Parsing Source: https://github.com/sferik/x-ruby/blob/main/README.md Illustrates how to configure the X API client to interact with the v1.1 endpoint. This example also shows how to define custom Ruby `Struct` objects and use them to parse API responses into more accessible data structures, allowing dot notation access to attributes. ```ruby # Initialize an API v1.1 client v1_client = X::Client.new(base_url: "https://api.twitter.com/1.1/", **x_credentials) # Define a custom response object Language = Struct.new(:code, :name, :local_name, :status, :debug) # Parse a response with custom array and object classes languages = v1_client.get("help/languages.json", object_class: Language, array_class: Set) # #, … # Access data with dots instead of brackets languages.first.local_name ``` -------------------------------- ### Initialize X Ads API Client and Fetch Accounts Source: https://github.com/sferik/x-ruby/blob/main/README.md Demonstrates how to initialize a dedicated client for the X Ads API (version 12) and retrieve a list of associated ad accounts. This is useful for managing advertising campaigns programmatically. ```ruby # Initialize an Ads API client ads_client = X::Client.new(base_url: "https://ads-api.twitter.com/12/", **x_credentials) # Get your ad accounts ads_client.get("accounts") ``` -------------------------------- ### Initialize X API Client and Perform Basic Operations Source: https://github.com/sferik/x-ruby/blob/main/README.md Demonstrates how to initialize the X API client using your OAuth credentials and perform fundamental operations such as fetching user data, posting a new tweet, and deleting an existing tweet. ```ruby require "x" x_credentials = { api_key: "INSERT YOUR X API KEY HERE", api_key_secret: "INSERT YOUR X API KEY SECRET HERE", access_token: "INSERT YOUR X ACCESS TOKEN HERE", access_token_secret: "INSERT YOUR X ACCESS TOKEN SECRET HERE", } # Initialize an X API client with your OAuth credentials x_client = X::Client.new(**x_credentials) # Get data about yourself x_client.get("users/me") # {"data"=>{"id"=>"7505382", "name"=>"Erik Berlin", "username"=>"sferik"}} # Post post = x_client.post("tweets", '{"text":"Hello, World! (from @gem)"}') # {"data"=>{"edit_history_tweet_ids"=>["1234567890123456789"], "id"=>"1234567890123456789", "text"=>"Hello, World! (from @gem)"}} # Delete the post x_client.delete("tweets/#{post["data"]["id"]}") # {"data"=>{"deleted"=>true}} ``` -------------------------------- ### Navigate to X Ruby Directory Source: https://github.com/sferik/x-ruby/blob/main/README.md Changes the current directory to the cloned X Ruby gem repository. ```Shell cd x-ruby ``` -------------------------------- ### Clone X Ruby Repository Source: https://github.com/sferik/x-ruby/blob/main/README.md Clones the X Ruby gem's Git repository from GitHub to your local machine. ```Shell git clone git@github.com:sferik/x-ruby.git ``` -------------------------------- ### Verify Ruby Code Coverage Source: https://github.com/sferik/x-ruby/blob/main/README.md Runs tests to ensure 100% C0 code coverage for the X Ruby gem. ```Shell bundle exec rake test ``` -------------------------------- ### Verify Ruby Mutation Coverage Source: https://github.com/sferik/x-ruby/blob/main/README.md Runs mutation tests to ensure 100% mutation coverage for the X Ruby gem. ```Shell bundle exec rake mutant ``` -------------------------------- ### Run All X Ruby Tests Source: https://github.com/sferik/x-ruby/blob/main/README.md Executes the default Rake task to ensure all tests for the X Ruby gem pass. ```Shell bundle exec rake ``` -------------------------------- ### Create New Git Branch Source: https://github.com/sferik/x-ruby/blob/main/README.md Creates and switches to a new Git branch for developing features or bug fixes within the X Ruby project. ```Shell git checkout -b my-new-branch ``` -------------------------------- ### Verifying RBS Type Signatures - Ruby Source: https://github.com/sferik/x-ruby/blob/main/README.md This command runs the `steep` Rake task to verify RBS type signatures in `sig/x.rbs`. It ensures type consistency and correctness for the Ruby code. ```Shell bundle exec rake steep ``` -------------------------------- ### Verify Ruby Code RuboCop Rules Source: https://github.com/sferik/x-ruby/blob/main/README.md Checks if the Ruby code conforms to the RuboCop rules for style and quality. ```Shell bundle exec rake rubocop ``` -------------------------------- ### Verify Ruby Type Signatures (RBS) Source: https://github.com/sferik/x-ruby/blob/main/README.md Verifies the RBS type signatures for the X Ruby gem, located in `sig/x.rbs`. ```Shell bundle exec rake steep ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.