Module: Stretchy
- Defined in:
- lib/stretchy.rb,
lib/stretchy/api.rb,
lib/stretchy/node.rb,
lib/stretchy/utils.rb,
lib/stretchy/errors.rb,
lib/stretchy/factory.rb,
lib/stretchy/results.rb,
lib/stretchy/version.rb,
lib/stretchy/and_collector.rb
Overview
RubyDoc.info: YARD Doc Server
RubyDoc.info is the next generation Ruby doc server, replacing http://rdoc.info and http://yardoc.org/docs. This doc server uses YARD to generate project documentation on the fly, for both published RubyGems as well as GitHub projects.
The public doc server is hosted at http://www.rubydoc.info
Getting Started
This site is a public service and is community-supported. Patches and enhancements are welcome.
Requirements
- Docker Desktop
- Ruby 3.3+
Configuration
1. config/rubydoc.yml
This server uses typical Rails configuration, but we rely on a specific config/rubydoc.yml file to configure the
application level settings. You should first copy the config/rubydoc.yml.sample file to config/rubydoc.yml and
then edit the file to configure your server (although the defaults should provide a working experience).
cp config/rubydoc.yml.sample config/rubydoc.yml
2. Credentials
This Ruby on Rails application stores credentials in the config/credentials.yml.enc file, however for extra security
this file is not checked into the repository. You can create your own credentials file by running:
rails credentials:edit
[!NOTE] You may need to export
$VISUALor$EDITORto your preferred editor before running this command.
This is mosty only necessary when deploying or if using custom integrations. Since we do not use the session store, the standard Rails credentials are not used for the application.
Development
Clone the repository and run the setup script to install dependencies and create the database:
git clone git://github.com/docmeta/rubydoc.info
cd rubydoc.info
./bin/setup
You can also use ./bin/dev if you have already setup the project.
[!NOTE] Windows users must use WSL2 to run the development server.
Job Queue
You can inspect running jobs at http://localhost:3000/jobs in development. In production this URL is backed behind Basic Auth using mission_control-jobs.
Run WITHOUT_JOBS=1 ./bin/dev to disable the job queue in development. You can run ./bin/jobs to start a separate
job queue process if needed.
Deploying
This server can be deployed using Docker swarm. In the case of a single node deployment, you can use the following commands to deploy the server:
./script/deploy
This will build the Docker image and deploy the server using the local configuration files.
Administration Commands
RubyDoc.info comes with a set of rails tasks that can be run to update remote gems, force documentation generate, or install Ruby stdlib documentation.
# Update remote gems
rails rubydoc:gems:update
# Install Ruby stdlib documentation for X.Y.Z
rails rubydoc:stdlib:install VERSION=X.Y.Z
# Generate documentation for a gem or github project (NAME=owner/repo VERSION=branch for github projects)
rails rubydoc:docs:generate NAME=library VERSION=X.Y.Z SOURCE=github|gem
Thanks
RubyDoc.info was created by Loren Segal (YARD) and Nick Plante (rdoc.info) and is a project of DOCMETA, LLC. Additional help was provided by our friendly developer community. Pull requests welcome!
(c) 2025 DOCMETA LLC. This code is distributed under the MIT license.
Defined Under Namespace
Modules: Factory, Utils Classes: API, AndCollector, IndexDoesNotExistError, InvalidParamsError, Node, Results
Constant Summary collapse
- VERSION =
"0.5.0"
Class Method Summary collapse
- .client ⇒ Object
- .client=(client) ⇒ Object
- .count_index(name, params = {}) ⇒ Object
- .create_index(name, params = {}) ⇒ Object
- .delete_index(name) ⇒ Object
- .fake_results ⇒ Object
- .index_document(params = {}) ⇒ Object
- .index_exists?(name) ⇒ Boolean
- .method_missing(method, *args, &block) ⇒ Object
- .query(options = {}) ⇒ Object
- .refresh_index(name, params = {}) ⇒ Object
- .search(options = {}) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
77 78 79 80 81 82 83 |
# File 'lib/stretchy.rb', line 77 def method_missing(method, *args, &block) if client.respond_to?(method) client.send(method, *args, &block) else super end end |
Class Method Details
.client ⇒ Object
22 23 24 |
# File 'lib/stretchy.rb', line 22 def client @client ||= Elasticsearch::Client.new end |
.client=(client) ⇒ Object
26 27 28 |
# File 'lib/stretchy.rb', line 26 def client=(client) @client = client end |
.count_index(name, params = {}) ⇒ Object
55 56 57 |
# File 'lib/stretchy.rb', line 55 def count_index(name, params = {}) client.count({index: name}.merge(params))['count'] end |
.create_index(name, params = {}) ⇒ Object
47 48 49 |
# File 'lib/stretchy.rb', line 47 def create_index(name, params = {}) client.indices.create({index: name}.merge(params)) unless index_exists? name end |
.delete_index(name) ⇒ Object
43 44 45 |
# File 'lib/stretchy.rb', line 43 def delete_index(name) client.indices.delete(index: name) if index_exists? name end |
.index_document(params = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/stretchy.rb', line 59 def index_document(params = {}) Utils.require_params!(:index_document, params, :index, :type, :body) raise IndexDoesNotExistError.new( "index #{params[:index]} does not exist" ) unless index_exists? params[:index] client.index(params) end |
.index_exists?(name) ⇒ Boolean
39 40 41 |
# File 'lib/stretchy.rb', line 39 def index_exists?(name) client.indices.exists? index: name end |
.method_missing(method, *args, &block) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/stretchy.rb', line 77 def method_missing(method, *args, &block) if client.respond_to?(method) client.send(method, *args, &block) else super end end |
.query(options = {}) ⇒ Object
69 70 71 |
# File 'lib/stretchy.rb', line 69 def query( = {}) API.new(root: ) end |
.refresh_index(name, params = {}) ⇒ Object
51 52 53 |
# File 'lib/stretchy.rb', line 51 def refresh_index(name, params = {}) client.indices.refresh({index: name}.merge(params)) if index_exists? name end |
.search(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/stretchy.rb', line 30 def search( = {}) client.search() rescue Elasticsearch::Transport::Transport::Errors::BadRequest => bre msg = bre.[-150..-1] msg << "\n\n" msg << JSON.pretty_generate() raise msg end |