revirow 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d964e2566cd2be44b64c0138ec3c873dce7541b3f0e9e38c6cd20d8bc3a3a4b
4
- data.tar.gz: a7d99e718b3298bd8437e6160aea34720b627e999b7bb984d5e3bf306723d200
3
+ metadata.gz: bd73add511621443ceb644deb1be3b596cc07155463ec3cf6297d84cd75987d3
4
+ data.tar.gz: e6bf48453fef9a69c620017dd02374ccb33a50925d64607ebf7f7f89234f73ea
5
5
  SHA512:
6
- metadata.gz: 39f9be4f8c68093593e07300a70a32dc03f66b11f6c0c2654a85995ec6403c3d2d97fe08638119dfa4011f02576b85224f6316956b248e8cf7aa8cb6ff9fc2dc
7
- data.tar.gz: cbbd94e80bc9d3b70475d185c0873b786da78e9bddbab33d278843eba285c7ae3d882c48de05793f43544ef0e58a5c65a6d0be6cc3d4a78784d2a41d24780c92
6
+ metadata.gz: 85dc10cf13967dd10b1cdd5fdd85cef88ef85737be4dbcfe02ac95e30a2ef5ae0995fd7d390ff0aa639b71bde7e7051aa4c4ca0d9f9a1df6c98b6aa06ec4fbc7
7
+ data.tar.gz: ebad674beccf8d8c3a4fbbd9e00563e54fa69a4869b634a823d1ead960789f448d5d7373a54112a57044cd6185abcff3c85481fb75ab0a10a2b6e898568966a8
data/README.md CHANGED
@@ -1,32 +1,54 @@
1
1
  # Revirow Ruby Gem
2
2
 
3
- Official Ruby client for the Revirow API. Integrate changelog and feedback collection into your Ruby applications.
3
+ Official Ruby client for the Revirow API. Integrate changelog, feedback collection, and the Revirow widget into your Ruby applications.
4
4
 
5
5
  ## Installation
6
6
 
7
- Install the gem and add to the application's Gemfile by executing:
8
-
9
7
  ```bash
10
8
  bundle add revirow
11
9
  ```
12
10
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
11
+ ## Widget (Rails)
12
+
13
+ Run the generator:
14
14
 
15
15
  ```bash
16
- gem install revirow
16
+ rails generate revirow:install
17
17
  ```
18
18
 
19
- ## Configuration
19
+ Add to your environment:
20
20
 
21
- Add your API key as an environment variable `REVIROW_KEY`. The gem will automatically use this key.
22
-
23
- ## Usage
21
+ ```bash
22
+ REVIROW_APP_ID=your_app_id
23
+ REVIROW_KEY=your_key
24
+ ```
24
25
 
25
- ### Initialize Client
26
+ Configure the customer context in `config/initializers/revirow.rb`:
26
27
 
27
28
  ```ruby
28
- require 'revirow'
29
+ Revirow.config do |config|
30
+ config.customer = Proc.new {
31
+ {
32
+ email: Current.user&.email_address,
33
+ id: Current.user&.id
34
+ }
35
+ }
36
+ end
37
+ ```
29
38
 
39
+ Add to your layout:
40
+
41
+ ```erb
42
+ <%= revirow_widget %>
43
+ ```
44
+
45
+ Done. The widget loads automatically with authenticated customer data.
46
+
47
+ ## API Client
48
+
49
+ For server-side API calls, set `REVIROW_KEY` and use the client:
50
+
51
+ ```ruby
30
52
  client = Revirow::Client.new
31
53
  ```
32
54
 
@@ -35,17 +57,15 @@ client = Revirow::Client.new
35
57
  Fetch changelog entries with cursor-based pagination:
36
58
 
37
59
  ```ruby
38
- # Get latest changelog entries
39
60
  response = client.changelog.list(limit: 10)
40
61
 
41
- # Access entries
42
62
  response['entries'].each do |entry|
43
63
  puts entry['title']
44
64
  puts entry['content']
45
65
  puts entry['published_at']
46
66
  end
47
67
 
48
- # Paginate through more entries
68
+ # Paginate
49
69
  if response['pagination']['has_more']
50
70
  next_page = client.changelog.list(
51
71
  limit: 10,
@@ -59,14 +79,12 @@ end
59
79
  Submit feedback requests to a feedback board:
60
80
 
61
81
  ```ruby
62
- # Create a feedback request
63
82
  response = client.feedback.create(
64
83
  feedback_board_public_id: 'board_abc123',
65
84
  description: 'Would love to see dark mode support!',
66
85
  title: 'Dark Mode Feature Request' # optional
67
86
  )
68
87
 
69
- # Response includes the created feedback request
70
88
  puts response['id'] # public_id
71
89
  puts response['title'] # title (if provided)
72
90
  puts response['description'] # description
@@ -2,11 +2,20 @@
2
2
 
3
3
  module Revirow
4
4
  class Configuration
5
- attr_accessor :api_url, :api_key
5
+ attr_accessor :api_url, :api_key, :app_id, :secret, :customer
6
6
 
7
7
  def initialize
8
8
  @api_url = "https://api.revirow.com"
9
9
  @api_key = ENV["REVIROW_KEY"]
10
+ @app_id = ENV["REVIROW_APP_ID"]
11
+ @secret = ENV["REVIROW_KEY"]
12
+ @customer = nil
13
+ end
14
+
15
+ def customer_data
16
+ return {} unless @customer.is_a?(Proc)
17
+ result = @customer.call
18
+ result.is_a?(Hash) ? result : {}
10
19
  end
11
20
  end
12
21
 
@@ -21,6 +30,8 @@ module Revirow
21
30
  yield(configuration)
22
31
  end
23
32
 
33
+ alias_method :config, :configure
34
+
24
35
  def reset_configuration!
25
36
  @configuration = Configuration.new
26
37
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Revirow
4
+ class Railtie < Rails::Railtie
5
+ initializer "revirow.view_helpers" do
6
+ ActiveSupport.on_load(:action_view) do
7
+ include Revirow::ViewHelpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Revirow
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Revirow
4
+ module ViewHelpers
5
+ def revirow_widget
6
+ Revirow::Widget.script_tag.html_safe
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jwt"
4
+
5
+ module Revirow
6
+ class Widget
7
+ class << self
8
+ def script_tag
9
+ config = Revirow.configuration
10
+ raise Error, "REVIROW_APP_ID not set" unless config.app_id
11
+
12
+ jwt = generate_jwt(config)
13
+
14
+ <<~HTML
15
+ <script src="https://client.revirow.com/loader.js"></script>
16
+ <script>
17
+ Revirow("boot", {
18
+ appId: "#{config.app_id}"#{jwt ? %Q(,\n jwt: "#{jwt}") : ""}
19
+ });
20
+ </script>
21
+ HTML
22
+ end
23
+
24
+ private
25
+
26
+ def generate_jwt(config)
27
+ return nil unless config.secret
28
+ payload = config.customer_data
29
+ return nil if payload.empty?
30
+
31
+ JWT.encode(payload, config.secret, "HS256")
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/revirow.rb CHANGED
@@ -5,7 +5,11 @@ require_relative "revirow/configuration"
5
5
  require_relative "revirow/resources/changelog"
6
6
  require_relative "revirow/resources/feedback"
7
7
  require_relative "revirow/client"
8
+ require_relative "revirow/widget"
9
+ require_relative "revirow/view_helpers"
8
10
 
9
11
  module Revirow
10
12
  class Error < StandardError; end
11
13
  end
14
+
15
+ require_relative "revirow/railtie" if defined?(Rails::Railtie)
data/revirow-0.1.1.gem ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revirow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Revirow
8
8
  bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: jwt
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.5'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.5'
12
26
  email:
13
27
  - development@revirow.com
14
28
  executables: []
@@ -22,10 +36,14 @@ files:
22
36
  - lib/revirow.rb
23
37
  - lib/revirow/client.rb
24
38
  - lib/revirow/configuration.rb
39
+ - lib/revirow/railtie.rb
25
40
  - lib/revirow/resources/changelog.rb
26
41
  - lib/revirow/resources/feedback.rb
27
42
  - lib/revirow/version.rb
43
+ - lib/revirow/view_helpers.rb
44
+ - lib/revirow/widget.rb
28
45
  - revirow-0.1.0.gem
46
+ - revirow-0.1.1.gem
29
47
  - sig/revirow.rbs
30
48
  homepage: https://revirow.com
31
49
  licenses:
@@ -46,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
64
  - !ruby/object:Gem::Version
47
65
  version: '0'
48
66
  requirements: []
49
- rubygems_version: 3.7.2
67
+ rubygems_version: 3.6.9
50
68
  specification_version: 4
51
69
  summary: Ruby client for the Revirow API.
52
70
  test_files: []