### Project Setup with Git and Bundler
Source: https://github.com/actmd/abraham/wiki/Gem-development-workflow
Clones the Abraham project repository, navigates into the project directory, and installs necessary Ruby gems using Bundler. This is the initial setup required before working on the project.
```bash
git clone ...
cd abraham
gem install bundler
bundle install
```
--------------------------------
### Install Abraham Gem and Dependencies
Source: https://context7.com/actmd/abraham/llms.txt
Installs the Abraham gem, runs the installation generator to set up migrations and initializers, and adds necessary JavaScript dependencies for tour functionality.
```bash
# Install Abraham gem and run generator
bundle add abraham
rails generate abraham:install
rails db:migrate
# Install JavaScript dependencies
yarn add js-cookie@^2.2.0 shepherd.js@^6.0.0-beta
```
--------------------------------
### Clone and Install Dependencies (Bash)
Source: https://github.com/actmd/abraham/blob/master/README.md
Commands to clone the Abraham repository and install its Ruby and Yarn dependencies. Assumes rvm is installed and configured.
```bash
~ git clone git@github.com:actmd/abraham.git
Cloning into 'abraham'...
~ cd abraham
ruby-2.5.3 - #gemset created /Users/jon/.rvm/gems/ruby-2.5.3@abraham
ruby-2.5.3 - #generating abraham wrappers - please wait
~ bundle install
Bundle complete! 13 Gemfile dependencies, 73 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
~ yarn install
```
--------------------------------
### Generate Abraham Installer and Migrate Database
Source: https://github.com/actmd/abraham/blob/master/README.md
After adding the gem, run the Abraham installer to generate necessary configuration files and run database migrations to set up tracking for tours.
```bash
$ bundle install
$ rails generate abraham:install
$ rails db:migrate
```
--------------------------------
### Manual Tour Triggering (JavaScript)
Source: https://github.com/actmd/abraham/blob/master/README.md
Demonstrates how to manually start a tour named 'walkthrough' using JavaScript event listeners. This is useful when tours should not start automatically. It requires a button to initiate the tour and uses the `Abraham.startTour` method.
```javascript
```
```javascript
$"#startTour".on("click", function() { Abraham.startTour('walkthrough'); })
```
--------------------------------
### Gem Release Process
Source: https://github.com/actmd/abraham/wiki/Gem-development-workflow
Provides commands for releasing a new version of the gem. Includes pushing the gem to rubygems, running tests, building the gem locally, and finalizing the feature branch using git flow.
```bash
# If you're not signed into rubygems yet, run this and enter your credentials
gem push
# Run all the tests
rails t
# Make sure the gem builds
rake install
# Finish & squash the branch
git flow feature finish --squash
# Create the git flow release
git flow release start VERSION
git flow release finish
rake release
```
--------------------------------
### Install JavaScript Dependencies for Abraham
Source: https://github.com/actmd/abraham/blob/master/README.md
Install the required JavaScript libraries, js-cookie and shepherd.js, using Yarn. These are essential for Abraham's tour functionality and cookie management.
```bash
$ yarn add js-cookie@^2.2.0 shepherd.js@^6.0.0-beta
```
--------------------------------
### Start Git Flow Release (Bash)
Source: https://github.com/actmd/abraham/blob/master/README.md
Command to initiate a release using the git-flow branching model.
```bash
$ git flow release start VERSION_NUMBER
```
--------------------------------
### Control Tours using Flipper in Ruby
Source: https://context7.com/actmd/abraham/llms.txt
Provides Ruby code examples for programmatically enabling or disabling feature flags that control tour visibility within the Abraham application.
```ruby
# Enable/disable tours via Flipper
Flipper.enable(:new_feature_tour)
Flipper.disable(:hide_old_tutorial)
```
--------------------------------
### Install Local Abraham Gem (Ruby)
Source: https://github.com/actmd/abraham/blob/master/README.md
How to add the Abraham gem to a local Rails application using a path to a local copy of the gem.
```ruby
gem 'abraham', path: '~/Workspace/abraham'
```
--------------------------------
### Install Abraham Gem in Rails
Source: https://github.com/actmd/abraham/blob/master/README.md
Add the Abraham gem to your application's Gemfile to include its functionality. After adding, run bundle install to install the gem and the associated generator.
```ruby
gem 'abraham'
```
--------------------------------
### Build and Push Abraham Gem (Bash)
Source: https://github.com/actmd/abraham/blob/master/README.md
Commands to build the Abraham gem locally and then push it to a package registry (like Rubygems).
```bash
$ rake build
$ gem push pkg/abraham-VERSION_NUMBER.gem
```
--------------------------------
### Manual Tour Triggering with JavaScript
Source: https://context7.com/actmd/abraham/llms.txt
Configures tours to be triggered manually rather than automatically, and provides a JavaScript API to start tours programmatically on demand, initiated by user interaction.
```yaml
# config/tours/dashboard/home.en.yml
walkthrough:
trigger: "manual"
steps:
1:
text: "This walkthrough will show you how to use advanced features."
2:
title: "Advanced Controls"
text: "Click here to access advanced settings."
attachTo:
element: "#settings-panel"
placement: "left"
```
--------------------------------
### Abraham JavaScript Core API for Tour Management
Source: https://context7.com/actmd/abraham/llms.txt
The client-side JavaScript API for Abraham, used for managing user tours. It handles tour initialization, starting tours programmatically, automatically starting the next incomplete tour on page load or Turbolinks load, and cleaning up tour elements before Turbolinks cache.
```javascript
// Abraham JavaScript API
var Abraham = new Object();
Abraham.tours = {};
Abraham.incompleteTours = [];
// Start a specific tour programmatically
Abraham.startTour = function(tourName) {
if (!Shepherd.activeTour) {
Abraham.tours[tourName].start();
}
};
// Automatically start next incomplete tour
Abraham.startNextIncompleteTour = function() {
if (Abraham.incompleteTours.length) {
Abraham.tours[Abraham.incompleteTours[0]].checkAndStart();
}
};
// Event listeners for automatic tour triggering
document.addEventListener("DOMContentLoaded", Abraham.startNextIncompleteTour);
document.addEventListener("turbolinks:load", Abraham.startNextIncompleteTour);
// Cleanup before Turbolinks cache
document.addEventListener('turbolinks:before-cache', function() {
document.querySelectorAll(".shepherd-element").forEach(function(el) {
el.remove()
});
Abraham.tours = {};
Abraham.incompleteTours = [];
});
```
--------------------------------
### Abraham Initialization and Configuration Loading
Source: https://context7.com/actmd/abraham/llms.txt
This Ruby initializer script configures Abraham by loading tour definitions from YAML files and merging them with application-wide settings from `config/abraham.yml`. It dynamically discovers tour files, parses them, and sets up `config.abraham.tour_options` and `config.abraham.tours` for use throughout the application.
```ruby
# config/initializers/abraham.rb
Rails.application.configure do
tours = {}
tours_root = Pathname.new(Rails.root.join("config/tours"))
if Rails.root.join("config/tours").exist?
Dir.glob(Rails.root.join("config/tours/**/*.yml")).each do |yml|
relative_filename = Pathname.new(yml).relative_path_from(tours_root)
controller_path, filename = relative_filename.split
file_parts = filename.to_s.split(".")
action = file_parts[0]
locale = file_parts[1]
t = YAML.load_file(yml)
tours["#{controller_path}.#{action}.#{locale}"] = t
end
end
abraham_config = Rails.application.config_for :abraham
config.abraham = ActiveSupport::OrderedOptions.new
config.abraham.tour_options = abraham_config[:tour_options]
config.abraham.tours = tours
end
```
--------------------------------
### Define Tours Using YAML Format
Source: https://context7.com/actmd/abraham/llms.txt
Defines multi-step guided tours using YAML files. Each step can include text, title, and attachment details for elements on the page, supporting internationalization.
```yaml
# config/tours/articles/index.en.yml
intro:
steps:
1:
text: "Welcome to your dashboard! This is where we'll highlight key information to manage your day."
2:
title: "Events"
text: "If you're participating in any events today, we'll show that here."
attachTo:
element: ".dashboard-events"
placement: "right"
3:
title: "Search"
text: "You can find anything else by using the search bar."
attachTo:
element: ".navbar-primary form"
placement: "bottom"
```
--------------------------------
### Define Tour with Steps (YAML)
Source: https://github.com/actmd/abraham/blob/master/README.md
Defines a tour named 'intro' with three steps. Each step has text, and specific steps include a title, element to attach to, and placement of the callout relative to the element. This format is used for structuring tour content.
```yaml
intro:
steps:
1:
text: "Welcome to your dashboard! This is where we'll highlight key information to manage your day."
2:
title: "Events"
text: "If you're participating in any events today, we'll show that here."
attachTo:
element: ".dashboard-events"
placement: "right"
3:
title: "Search"
text: "You can find anything else by using the search bar."
attachTo:
element: ".navbar-primary form"
placement: "bottom"
```
--------------------------------
### Manual Tour Triggering Configuration (YAML)
Source: https://github.com/actmd/abraham/blob/master/README.md
Configures a tour named 'walkthrough' to be triggered manually. The 'trigger: "manual"' option prevents the tour from starting automatically, requiring explicit invocation via `Abraham.startTour`.
```yaml
walkthrough:
trigger: "manual"
steps:
1:
text: "This walkthrough will show you how to..."
```
--------------------------------
### Trigger Tour Programmatically with JavaScript
Source: https://context7.com/actmd/abraham/llms.txt
Demonstrates how to initiate a tour using JavaScript by adding an event listener to a button that calls the `Abraham.startTour` method with the tour's name.
```html
```
--------------------------------
### Configure Rails Application for Abraham
Source: https://context7.com/actmd/abraham/llms.txt
Includes the necessary Abraham JavaScript and CSS assets in the Rails application's asset pipeline and adds a helper to render tour elements in the layout.
```ruby
# app/assets/javascripts/application.js
//= require abraham
# app/assets/stylesheets/application.scss
*= require abraham/theme-default
# app/views/layouts/application.html.erb
<%= abraham_tour %>