### Generate and serve documentation using YARD Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md YARD provides enhanced documentation features with a local server for browsing. Install YARD if needed, generate documentation, and start a development server accessible at http://localhost:8808. ```bash # Install YARD if not already installed gem install yard # Generate YARD documentation yard doc # Start YARD server to browse documentation yard server ``` -------------------------------- ### Start YARD Server in Shell Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Commands to start the YARD documentation server, allowing users to view the documentation locally via a web browser at http://localhost:8808. ```bash # Start server yard server # Visit http://localhost:8808 ``` -------------------------------- ### Module Documentation Example (Ruby) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md An example of documenting a Ruby module using RDoc, including a brief overview, detailed description, usage examples, and key concepts. ```ruby ## # = ModuleName # # Brief overview in one sentence. # # == Detailed Description # # Multiple paragraphs explaining the module's purpose, # key concepts, and overall architecture. # # == Usage # # basic_example # # => result # # == Key Concepts # # [Concept 1] Explanation # [Concept 2] Explanation # module ModuleName end ``` -------------------------------- ### MixinBot Documentation - Rich Examples in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Provides examples of how documentation within the MixinBot gem uses Ruby code snippets to illustrate usage. Includes a simple example of calling the `me` API and a more complex example demonstrating transfer creation with error handling for insufficient balance. ```ruby # Simple example api.me # => { "user_id" => "...", "full_name" => "..." } # Complex example with error handling begin result = api.create_transfer( members: 'recipient-id', asset_id: 'asset-id', amount: '0.01', memo: 'Payment' ) puts result['snapshot_id'] rescue MixinBot::InsufficientBalanceError => e puts "Insufficient balance: #{e.message}" end ``` -------------------------------- ### Method Documentation Example (Ruby) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md An example of documenting a Ruby method using RDoc, showcasing parameter types, options, return values, exceptions, and multiple usage examples. ```ruby ## # Brief description of the method. # # Detailed explanation of what the method does, # including edge cases and important behaviors. # # @param name [String] the name parameter # @param age [Integer] the age parameter # @param opts [Hash] optional parameters # @option opts [String] :city the city name # @option opts [String] :country the country code # @return [Hash] the result hash containing: # - name: the provided name # - age: the provided age # - location: the combined location # @raise [ArgumentError] if age is negative # # @example Simple usage # result = process("John", 25) # # => { name: "John", age: 25 } # # @example With options # result = process("John", 25, city: "NYC", country: "US") # # => { name: "John", age: 25, location: "NYC, US" } # def process(name, age, **opts) end ``` -------------------------------- ### Viewing RDoc Documentation (Bash) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Demonstrates commands to generate RDoc documentation and open it in a local browser, or start a documentation server. ```bash # Generate and open rake rdoc open doc/index.html # Using YARD yard server # Using RDoc (via gem server) gem server # Visit http://localhost:8808 ``` -------------------------------- ### RDoc Command Line Generation (Bash) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Provides examples of generating RDoc documentation from the command line, including basic usage, with options, and specifying files. ```bash # Basic rdoc # With options rdoc --main README.md \ --title "MixinBot" \ --line-numbers \ --output doc \ lib/**/*.rb README.md # Specific files only rdoc lib/mixin_bot.rb lib/mixin_bot/api.rb ``` -------------------------------- ### RDoc Markup Examples (Ruby) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Demonstrates basic RDoc markup for lists, code, links, and formatting within Ruby comments. ```ruby # Bulleted list: # - Item 1 # - Item 2 # # Numbered list: # 1. First # 2. Second # # Definition list: # [Term] Definition # Inline code: +code+ # Code block (indented): # code_here # more_code # External: {Link Text}[https://example.com] # Internal: ClassName#method_name # See also: @see ClassName#method # *bold* # _italic_ # +code+ ``` -------------------------------- ### Install MixinBot Gem Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Instructions for installing the MixinBot gem using a Gemfile or the gem install command. This is the initial step to use the MixinBot library. ```ruby gem 'mixin_bot' ``` ```shell gem install mixin_bot ``` -------------------------------- ### RDoc Method Documentation Format Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Illustrates the RDoc format for documenting Ruby methods. It specifies guidelines for brief and detailed descriptions, parameter and option documentation, return values, exceptions, and provides examples for basic usage, related methods, and external links. ```ruby ## # Brief description of what the method does. # # Longer description with details about behavior, # edge cases, and important notes. # # @param param_name [Type] description of parameter # @option kwargs [Type] :key description of option # @return [Type] description of return value # @raise [ExceptionClass] when exception occurs # # @example Basic usage # result = method_name(param) # puts result # # @see RelatedClass#method # @see https://example.com/docs # def method_name(param, **kwargs) end ``` -------------------------------- ### RDoc Module/Class Documentation Format Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Demonstrates the RDoc format for documenting Ruby modules and classes. It includes a brief one-line description, a detailed multi-paragraph description, sections for terms, and examples of code usage with expected results. ```ruby ## # Brief one-line description. # # Detailed description with multiple paragraphs. # # == Sections # # [Term] Description # # == Examples # # code_example # # => result # module/class Name ``` -------------------------------- ### Generate MixinBot Documentation with Rake or RDoc Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Instructions for generating RDoc documentation for the MixinBot gem. It shows how to use the recommended Rake task or directly invoke RDoc with specific options. An alternative using YARD is also provided, including installation and server commands. ```bash # Using Rake (recommended) rake rdoc # Or using RDoc directly rdoc --main README.md --title "MixinBot - Ruby SDK for Mixin Network" # Or using YARD (alternative) gem install yard yard doc yard server # Browse at http://localhost:8808 ``` -------------------------------- ### Clone and Test MixinBot Project Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Steps to clone the MixinBot project from GitHub, configure test credentials by renaming an example config file, and run the test suite using Rake. ```shell git clone https://github.com/an-lee/mixin_bot cd mixin_bot mv spec/config.yml.example spec/config.yml rake ``` -------------------------------- ### Rakefile for RDoc Generation (Ruby) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Shows how to configure and generate RDoc documentation using a Rakefile, specifying main file, output directory, title, options, and files to include. ```ruby # Rakefile RDoc::Task.new do |rdoc| rdoc.main = 'README.md' rdoc.rdoc_dir = 'doc' rdoc.title = 'MixinBot Documentation' rdoc.options << '--line-numbers' rdoc.options << '--charset=UTF-8' rdoc.options << '--all' # Include private methods rdoc.rdoc_files.include('lib/**/*.rb', 'README.md') end ``` -------------------------------- ### Open RDoc Documentation in Shell Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Provides commands to open the generated RDoc documentation in the default web browser on macOS, Linux, and Windows systems. ```bash # Open in default browser open doc/index.html # macOS xdg-open doc/index.html # Linux start doc/index.html # Windows ``` -------------------------------- ### MixinBot Gem Documentation - Core Components Overview Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Lists the core components of the MixinBot gem that have been documented using RDoc. This includes the main module, API client, configuration, utilities, and specific API modules like Me, Asset, and Transfer. ```ruby # Documentation covers: # - MixinBot Module # - MixinBot::API # - MixinBot::Configuration # - MixinBot::Client # - MixinBot::UUID # - MixinBot::Utils # - MixinBot::Utils::Crypto # - API Modules (Me, Asset, Transfer) # - MVM Module and Components (Bridge, Client) ``` -------------------------------- ### Configure and use MixinBot API - Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Configure the MixinBot gem with application credentials and perform basic operations like retrieving bot profile and listing assets. Requires app_id, session_id, session_private_key, and server_public_key for authentication. ```ruby # Configure bot MixinBot.configure do app_id = 'your-app-id' session_id = 'your-session-id' session_private_key = 'your-private-key' server_public_key = 'server-public-key' end # Get bot profile profile = MixinBot.api.me puts profile['full_name'] # List assets assets = MixinBot.api.assets assets.each do |asset| puts "#{asset['symbol']}: #{asset['balance']}" end ``` -------------------------------- ### View Generated MixinBot Documentation Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Commands to open the generated RDoc documentation in a web browser, tailored for different operating systems (macOS, Linux, Windows). The documentation is typically found at `doc/index.html` after generation. ```bash # macOS open doc/index.html # Linux xdg-open doc/index.html # Windows start doc/index.html ``` -------------------------------- ### RDoc Custom Tags and Conditional Docs (Ruby) Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Illustrates RDoc's custom tags for detailed method documentation and the use of ':nodoc:' for excluding methods from documentation. ```ruby ## # @param name [String] the user name # @option opts [Integer] :age (18) the user age # @return [Hash] user information # @raise [ArgumentError] if name is invalid # @example # create_user("John", age: 25) # @see User # @since 1.0.0 # @deprecated Use #new_method instead ## # This method is documented. def public_method end # :nodoc: # This method is not included in docs. def internal_method end ``` -------------------------------- ### Call Mixin API Endpoints Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Examples of making API calls using the MixinBot gem after configuration. It demonstrates fetching the bot's profile, listing assets, and initiating a transfer, showcasing common API interactions. ```ruby # get the bot profile MixinBot.api.me # get assets of the bot MixinBot.api.assets # transfer asset to somebody MixinBot .api .create_transfer( '123456', # pin_code asset_id: '965e5c6e-434c-3fa9-b780-c50f43cd955c', # the asset uuid to transfer opponent_id: '6ae1c7ae-1df1-498e-8f21-d48cb6d129b5', # receiver's mixin uuid amount: 0.00000001, # amount memo: 'test from MixinBot', # memo, 140 length at max trace_id: '0798327a-d499-416e-9b26-5cdc5b7d841e' # a uuid to trace transfer ) ``` -------------------------------- ### Handle Insufficient Balance Error in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Demonstrates how to rescue specific exceptions like MixinBot::InsufficientBalanceError and MixinBot::ResponseError during API operations, allowing for graceful error handling and user feedback. ```ruby begin MixinBot.api.create_transfer(...) rescue MixinBot::InsufficientBalanceError => e puts "Insufficient balance: #{e.message}" rescue MixinBot::ResponseError => e puts "API error: #{e.message}" end ``` -------------------------------- ### Connect to Blaze Messaging in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Establishes a connection to the Blaze messaging service using EM.run and a callback function to process incoming messages. It parses the incoming event data as JSON. ```ruby EM.run { MixinBot.api.start_blaze_connect do def on_message(blaze, event) raw = JSON.parse(event.data) # Process message end end } ``` -------------------------------- ### Generate HTML documentation using RDoc Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Use RDoc, Ruby's built-in documentation tool, to generate HTML documentation. The basic command generates documentation in the doc/ directory, while the advanced command allows custom options for main file and title specification. ```bash # Generate HTML documentation rdoc # Generate documentation with custom options rdoc --main README.md --title "MixinBot - Ruby SDK for Mixin Network" ``` -------------------------------- ### Create Transfer (Simple) in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Creates a simple transfer of a specified amount of an asset to a single recipient. Requires recipient ID, asset ID, amount, and an optional memo. Returns the transfer result. ```ruby result = MixinBot.api.create_transfer( members: 'recipient-user-id', asset_id: 'asset-uuid', amount: '0.01', memo: 'Payment' ) ``` -------------------------------- ### MixinBot Documentation - Cross-References in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/RDOC_GUIDE.md Shows how RDoc documentation in the MixinBot gem utilizes cross-references to link related code components and external resources. This includes using `@see` tags to point to other methods or classes within the gem and external API documentation URLs. ```ruby # @see MixinBot::API#create_transfer # @see https://developers.mixin.one/docs/api/transfer ``` -------------------------------- ### Create Transfer (Multisig) in Ruby Source: https://github.com/an-lee/mixin_bot/blob/main/DOCUMENTATION.md Creates a multisignature transfer requiring a specified number of member signatures (threshold) out of a given set of members. Requires member IDs, threshold, asset ID, and amount. Returns the transfer result. ```ruby result = MixinBot.api.create_transfer( members: ['user1', 'user2', 'user3'], threshold: 2, asset_id: 'asset-uuid', amount: '0.01' ) ``` -------------------------------- ### MixinBot CLI Commands Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Demonstrates the available commands for the MixinBot command-line interface. These commands allow users to interact with the Mixin API directly from the terminal for tasks like requesting data, decoding transactions, and generating trace IDs. ```bash Commands: mixinbot api PATH -k, --keystore=KEYSTORE # request PATH of Mixin API mixinbot decodetx TRANSACTION # decode raw transaction mixinbot encrypt PIN -k, --keystore=KEYSTORE # encrypt PIN using private key mixinbot generatetrace HASH # generate trace ID from Tx hash mixinbot help [COMMAND] # Describe available commands or one specific command mixinbot nftmemo -c, --collection=COLLECTION -h, --hash=HASH -t, --token=N # memo for mint NFT mixinbot unique UUIDS # generate unique UUID for two or more UUIDs mixinbot version # Distay MixinBot version Options: -a, [--apihost=APIHOST] # Specify mixin api host # Default: api.mixin.one -r, [--pretty], [--no-pretty] # Print output in pretty # Default: true ``` ```bash $ mixinbot api /me -k ~/.mixinbot/keystore.json ``` -------------------------------- ### Generate RDoc Documentation Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Instructions for generating RDoc (Ruby Documentation) for the MixinBot gem. This can be done using the Rake task or the RDoc command-line tool, producing local HTML documentation. ```bash # Using Rake rake rdoc # Or using RDoc directly rdoc ``` -------------------------------- ### Configure MixinBot API Keys Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Shows how to configure the necessary API credentials for MixinBot. This includes setting the app ID, client secret, session ID, and server/session keys, which are essential for authenticating API requests. ```ruby MixinBot.configure do app_id = '25696f85-b7b4-4509-8c3f-2684a8fc4a2a' client_secret = 'd9dc58107bacde671...' session_id ='25696f85-b7b4-4509-8c3f-2684a8fc4a2a' server_public_key = 'b0pjBUKI0Vp9K+NspaL....' session_private_key = '...' end ``` -------------------------------- ### Manage Multiple Mixin Bots Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Demonstrates how to manage multiple Mixin bots concurrently by creating separate API instances for each bot. This allows for independent configuration and interaction with different bot accounts. ```ruby bot1_api = MixinBot::API.new( app_id: '...', client_secret: '...', session_id: '...', server_public_key: '...', session_private_key: '...' ) bot2_api = MixinBot::API.new( app_id: '...', client_secret: '...', session_id: '...', server_public_key: '...', session_private_key: '...' ) bot1_api.me bot2_api.me ``` -------------------------------- ### Connect to Mixin Blaze WebSocket Source: https://github.com/an-lee/mixin_bot/blob/main/README.md Illustrates how to connect to Mixin Blaze using MixinBot within an EventMachine loop. It defines callback functions for WebSocket events like connection, message reception, errors, and closure, enabling real-time communication. ```ruby # run it in a EventMachine EM.run { MixinBot.api.start_blaze_connect do # do something when the websocket connected def on_open(blaze, _event) p [Time.now.to_s, :on_open] # send the list_pending_message to receive messages blaze.send list_pending_message end # do something when receive message def on_message(blaze, event) raw = JSON.parse ws_message(event.data) p [Time.now.to_s, :on_message, raw&.[]('action')] blaze.send acknowledge_message_receipt(raw['data']['message_id']) unless raw&.[]('data')&.[]('message_id').nil? end # do something when websocket error def on_error(blaze, event) p [Time.now.to_s, :on_error] end # do something when websocket close def on_close(blaze, event) p [Time.now.to_s, :on_close, event.code, event.reason] end end } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.