revirow 0.1.0 → 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: 2b8aad536825b4fd30fafb55b524eb41818078e2afc40d7600d7a125758196c6
4
- data.tar.gz: b22386d8e3a405c0fa138699070b94dda5bba3b79ab27cb3f1389d078721ca9e
3
+ metadata.gz: bd73add511621443ceb644deb1be3b596cc07155463ec3cf6297d84cd75987d3
4
+ data.tar.gz: e6bf48453fef9a69c620017dd02374ccb33a50925d64607ebf7f7f89234f73ea
5
5
  SHA512:
6
- metadata.gz: 45bd145f6b69dac9c96c2d3d24f3eebfc928900d0329d86ea8ab4c5a92fb859475df60708b06ec1831b199e17c943b41039e20e14c798a805f6156414f004c71
7
- data.tar.gz: 86a401e3c53b89b323319acc7c5bd49686d50f87dca7e284da9ea4539273937374c62479fe4b1cc369b89e57eb5bd2cc89a34ae7e48e189fad85f30beb7bf535
6
+ metadata.gz: 85dc10cf13967dd10b1cdd5fdd85cef88ef85737be4dbcfe02ac95e30a2ef5ae0995fd7d390ff0aa639b71bde7e7051aa4c4ca0d9f9a1df6c98b6aa06ec4fbc7
7
+ data.tar.gz: ebad674beccf8d8c3a4fbbd9e00563e54fa69a4869b634a823d1ead960789f448d5d7373a54112a57044cd6185abcff3c85481fb75ab0a10a2b6e898568966a8
data/README.md CHANGED
@@ -1,39 +1,98 @@
1
- # Revirow
1
+ # Revirow Ruby Gem
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/revirow`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Official Ruby client for the Revirow API. Integrate changelog, feedback collection, and the Revirow widget into your Ruby applications.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
7
+ ```bash
8
+ bundle add revirow
9
+ ```
10
10
 
11
- Install the gem and add to the application's Gemfile by executing:
11
+ ## Widget (Rails)
12
+
13
+ Run the generator:
12
14
 
13
15
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ rails generate revirow:install
15
17
  ```
16
18
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
19
+ Add to your environment:
18
20
 
19
21
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
22
+ REVIROW_APP_ID=your_app_id
23
+ REVIROW_KEY=your_key
21
24
  ```
22
25
 
23
- ## Usage
26
+ Configure the customer context in `config/initializers/revirow.rb`:
27
+
28
+ ```ruby
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
+ ```
24
38
 
25
- TODO: Write usage instructions here
39
+ Add to your layout:
26
40
 
27
- ## Development
41
+ ```erb
42
+ <%= revirow_widget %>
43
+ ```
44
+
45
+ Done. The widget loads automatically with authenticated customer data.
28
46
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+ ## API Client
30
48
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+ For server-side API calls, set `REVIROW_KEY` and use the client:
50
+
51
+ ```ruby
52
+ client = Revirow::Client.new
53
+ ```
32
54
 
33
- ## Contributing
55
+ ### Changelog
34
56
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/revirow.
57
+ Fetch changelog entries with cursor-based pagination:
36
58
 
37
- ## License
59
+ ```ruby
60
+ response = client.changelog.list(limit: 10)
61
+
62
+ response['entries'].each do |entry|
63
+ puts entry['title']
64
+ puts entry['content']
65
+ puts entry['published_at']
66
+ end
67
+
68
+ # Paginate
69
+ if response['pagination']['has_more']
70
+ next_page = client.changelog.list(
71
+ limit: 10,
72
+ cursor: response['pagination']['next_cursor']
73
+ )
74
+ end
75
+ ```
76
+
77
+ ### Feedback
78
+
79
+ Submit feedback requests to a feedback board:
80
+
81
+ ```ruby
82
+ response = client.feedback.create(
83
+ feedback_board_public_id: 'board_abc123',
84
+ description: 'Would love to see dark mode support!',
85
+ title: 'Dark Mode Feature Request' # optional
86
+ )
87
+
88
+ puts response['id'] # public_id
89
+ puts response['title'] # title (if provided)
90
+ puts response['description'] # description
91
+ puts response['status'] # 'open'
92
+ puts response['created_at'] # timestamp
93
+ ```
38
94
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
95
+ **Parameters:**
96
+ - `feedback_board_public_id` (required): The public ID of the feedback board
97
+ - `description` (required): The feedback content/description
98
+ - `title` (optional): A title for the feedback request
@@ -17,6 +17,10 @@ module Revirow
17
17
  @changelog ||= Resources::Changelog.new(self)
18
18
  end
19
19
 
20
+ def feedback
21
+ @feedback ||= Resources::Feedback.new(self)
22
+ end
23
+
20
24
  def get(path, params = {})
21
25
  uri = URI("#{@base_url}#{path}")
22
26
  uri.query = URI.encode_www_form(params) unless params.empty?
@@ -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
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Revirow
4
+ module Resources
5
+ class Feedback
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def create(feedback_board_public_id:, description:, title: nil)
11
+ body = {
12
+ feedback_board_public_id: feedback_board_public_id,
13
+ feedback_request: {
14
+ description: description
15
+ }
16
+ }
17
+ body[:feedback_request][:title] = title if title
18
+
19
+ @client.post("/api/feedback", body)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Revirow
4
- VERSION = "0.1.0"
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
@@ -3,8 +3,13 @@
3
3
  require_relative "revirow/version"
4
4
  require_relative "revirow/configuration"
5
5
  require_relative "revirow/resources/changelog"
6
+ require_relative "revirow/resources/feedback"
6
7
  require_relative "revirow/client"
8
+ require_relative "revirow/widget"
9
+ require_relative "revirow/view_helpers"
7
10
 
8
11
  module Revirow
9
12
  class Error < StandardError; end
10
13
  end
14
+
15
+ require_relative "revirow/railtie" if defined?(Rails::Railtie)
data/revirow-0.1.0.gem ADDED
Binary file
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.0
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,8 +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
41
+ - lib/revirow/resources/feedback.rb
26
42
  - lib/revirow/version.rb
43
+ - lib/revirow/view_helpers.rb
44
+ - lib/revirow/widget.rb
45
+ - revirow-0.1.0.gem
46
+ - revirow-0.1.1.gem
27
47
  - sig/revirow.rbs
28
48
  homepage: https://revirow.com
29
49
  licenses:
@@ -44,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
64
  - !ruby/object:Gem::Version
45
65
  version: '0'
46
66
  requirements: []
47
- rubygems_version: 3.7.2
67
+ rubygems_version: 3.6.9
48
68
  specification_version: 4
49
69
  summary: Ruby client for the Revirow API.
50
70
  test_files: []