revirow 0.1.1 → 0.1.3

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: b11db5a0914298ea819aacb7a1547f115656865cd55ef7333d640d1fe9b4aab2
4
+ data.tar.gz: 11a9af71ae8d13098638409f407e0469cc5db5fc61655e8e5bad8c62f761a177
5
5
  SHA512:
6
- metadata.gz: 39f9be4f8c68093593e07300a70a32dc03f66b11f6c0c2654a85995ec6403c3d2d97fe08638119dfa4011f02576b85224f6316956b248e8cf7aa8cb6ff9fc2dc
7
- data.tar.gz: cbbd94e80bc9d3b70475d185c0873b786da78e9bddbab33d278843eba285c7ae3d882c48de05793f43544ef0e58a5c65a6d0be6cc3d4a78784d2a41d24780c92
6
+ metadata.gz: 4efde37c03482f9e883882b3679179699bc94021b911dd74626d394bb0c258cb3d0a3ef8a5dbdbc053c882b1a02172f0a3335e96939aaa31233fb75e171b007b
7
+ data.tar.gz: 0b82b836b84ab396263711614dd5c3f0f92f51167037c818ca97b5d2cca22ec3735329de2b0a01c14301910952192c4c1c84c715c1838a98b6ff6fa4bf0e8316
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
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Revirow
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ desc "Creates a Revirow initializer file"
9
+
10
+ def copy_initializer
11
+ template "initializer.rb", "config/initializers/revirow.rb"
12
+ end
13
+
14
+ def show_readme
15
+ say ""
16
+ say "Revirow installed!", :green
17
+ say ""
18
+ say "Next steps:"
19
+ say " 1. Add REVIROW_APP_ID and REVIROW_KEY to your environment"
20
+ say " 2. Update config/initializers/revirow.rb with your customer data"
21
+ say " 3. Add <%= revirow_widget %> to your layout"
22
+ say ""
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ Revirow.config do |config|
4
+ # Define your customer context for the widget.
5
+ # This is called on each request to get the current customer data for JWT.
6
+ # config.customer = Proc.new {
7
+ # {
8
+ # email: Current.user&.email_address,
9
+ # id: Current.user&.id
10
+ # }
11
+ # }
12
+
13
+ # Optional: Override if not using environment variables
14
+ # config.app_id = "your_app_id"
15
+ # config.secret = "your_secret"
16
+ end
@@ -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.3"
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
data/revirow-0.1.2.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.3
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: []
@@ -19,13 +33,20 @@ files:
19
33
  - LICENSE.txt
20
34
  - README.md
21
35
  - Rakefile
36
+ - lib/generators/revirow/install_generator.rb
37
+ - lib/generators/revirow/templates/initializer.rb
22
38
  - lib/revirow.rb
23
39
  - lib/revirow/client.rb
24
40
  - lib/revirow/configuration.rb
41
+ - lib/revirow/railtie.rb
25
42
  - lib/revirow/resources/changelog.rb
26
43
  - lib/revirow/resources/feedback.rb
27
44
  - lib/revirow/version.rb
45
+ - lib/revirow/view_helpers.rb
46
+ - lib/revirow/widget.rb
28
47
  - revirow-0.1.0.gem
48
+ - revirow-0.1.1.gem
49
+ - revirow-0.1.2.gem
29
50
  - sig/revirow.rbs
30
51
  homepage: https://revirow.com
31
52
  licenses:
@@ -46,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
67
  - !ruby/object:Gem::Version
47
68
  version: '0'
48
69
  requirements: []
49
- rubygems_version: 3.7.2
70
+ rubygems_version: 3.6.9
50
71
  specification_version: 4
51
72
  summary: Ruby client for the Revirow API.
52
73
  test_files: []