planga 0.0.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -8
  3. data/lib/planga.rb +35 -5
  4. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6ffe01fdbb613efb04c25f71e7e0b973412d111
4
- data.tar.gz: 6a8aecf7e8bb6f3e7445dbf946ddda833f2d0494
3
+ metadata.gz: e12d35f94be4c97a00dd851adef3f5ec093b6d1f
4
+ data.tar.gz: 5e1e66cf22db3239d17dc53a29c895cc7fc995ac
5
5
  SHA512:
6
- metadata.gz: '09e511265f1ed2993bb4c812b934db8904b1058d44f01f38a70e4e59048dc805ff4bb0faebc0b662d58352fb11297a8a11f46087a0e76b9e05cb60e21d26adab'
7
- data.tar.gz: 69549f8ff033da9a7bf0e0f26bcbd10b118325f7ed2521cd7e361418430759b822c329efb014c44fb1c62bb2b4fda521cd35ff6d1d454281035e7a00751ba6a5
6
+ metadata.gz: 2ba888e4fe368156d775e7f5c7d50d8a86e259e2737c1aef48373104cc0c37964e83585be3175629e49a78b0ae606ce524b109d72f283c09ec974da17179bd3b
7
+ data.tar.gz: daf392c96dc10e331802fe42a5f98dbde0a8ea5e208951b34b9eff2137adcef348fc274a7397b238e86c90bb5ce1bf5fb4fa12182a6835cc914a4fe8b837a096
data/README.md CHANGED
@@ -5,6 +5,15 @@ Planga Ruby Wrapper:
5
5
  [![Planga Docs](https://img.shields.io/badge/planga-docs-lightgrey.svg)](http://www.planga.io/docs)
6
6
  [![Gem](https://img.shields.io/gem/v/planga.svg)](https://rubygems.org/gems/planga)
7
7
 
8
+ **Installation**
9
+
10
+ Global installation:
11
+ `gem install planga`
12
+ or, for installation in a single project, add
13
+ ```
14
+ gem 'planga', '~> 0.5.0'
15
+ ```
16
+ to your Gemfile.
8
17
 
9
18
  **Example usage**
10
19
 
@@ -12,28 +21,34 @@ Planga Ruby Wrapper:
12
21
  require 'planga'
13
22
 
14
23
  planga = Planga.new(
15
- :public_api_id => "foobar",
24
+ # These stay the same for all chats:
25
+ :public_api_id => "b5fc4092f05c70445fb758caac5027ca",
16
26
  :private_api_key => "ePxoM3OTkW1z6j84JDurqw",
27
+ # These change based on the current user:
17
28
  :conversation_id => "general",
18
29
  :current_user_id => "1234",
19
30
  :current_user_name => "Bob",
20
- :container_id => "my_container_div"
21
31
  )
22
32
 
23
33
  snippet = planga.chat_snippet()
24
34
  ```
25
35
 
36
+ For more information on what the different fields mean, see the [main Planga.io documentation](https://planga.io/docs) (until more detailed Ruby-specific documentation has been written).
37
+
38
+ For a guide that goes into a little bit more details, see [Building Live Chat Between Users in a Rails application using Planga.io](https://medium.com/@renevanpelt/building-live-chat-between-users-in-a-rails-application-91bc3a33b545)
39
+
40
+
26
41
  **Requirements:**
27
42
 
28
43
  * Ruby >= 2.4.1
29
- * gem
44
+ * The Planga gem
30
45
 
31
- **Build and Deploy new gem:**
32
46
 
33
- * run `gem build planga.gemspec`
34
- * run `gem push planga-n.n.n.gem`
35
47
 
36
- **Installing the new gem:**
48
+ **Steps to build and Deploy a new version of the gem:**
49
+
50
+ _(This is only interesting if you want to make a fork of this Gem)_
37
51
 
38
- * run `gem install planga`
39
52
 
53
+ * run `gem build planga.gemspec`
54
+ * run `gem push planga-n.n.n.gem`
@@ -2,11 +2,35 @@ require 'securerandom'
2
2
  require 'jose'
3
3
  require 'json'
4
4
 
5
+ # This class allows you to create a snippet of HTML/JS that,
6
+ # if included in a webpage, lets the visitor of that webpage
7
+ # connect with the Planga Chat Server and start chatting.
5
8
  class Planga
6
9
  attr_accessor :public_api_id, :private_api_key, :conversation_id,
7
- :current_user_id, :current_user_name, :container_id, :remote_host
10
+ :current_user_id, :current_user_name, :container_id, :remote_host, :debug
8
11
 
9
12
 
13
+ # The following configuration options are available:
14
+ #
15
+ # Required are:
16
+ #
17
+ # * public_api_id: The public API ID that can be found in the Planga Dashboard.
18
+ # * private_api_key: The private API key that can be found in the Planga Dashboard.
19
+ # * conversation_id: The identifier that uniquely identifies the single conversation
20
+ # that the user can connect with in this chat. Examples would be "general", "product/1234" or "private/123/543".
21
+ # * current_user_id: The internal ID your application uses, which uniquely identifies
22
+ # the user currently using your application.
23
+ # * current_user_name: The name of this user. This name is shown in the chat interface
24
+ # next to the typed messages
25
+ #
26
+ # Optional are:
27
+ #
28
+ # * remote_host: This can point to another host, if you are hosting your own instance of Planga.
29
+ # It defaults to the URL of Planga's main chat server. (`//chat.planga.io`)
30
+ # * container_id: If you want a custom HTML ID attribute specified to the created HTML element,
31
+ # you can enter it here.
32
+ # * debug: (defaults to `false`).
33
+ #
10
34
  def initialize(**conf)
11
35
  @public_api_id = conf[:public_api_id]
12
36
  @private_api_key = conf[:private_api_key]
@@ -15,6 +39,7 @@ class Planga
15
39
  @current_user_name = conf[:current_user_name]
16
40
  @container_id = conf[:container_id]
17
41
  @remote_host = conf[:remote_host] || "//chat.planga.io"
42
+ @debug = conf[:debug] || false
18
43
 
19
44
  if not container_id
20
45
  @container_id = "planga-chat-" + SecureRandom.hex
@@ -22,6 +47,7 @@ class Planga
22
47
  end
23
48
 
24
49
 
50
+ # Creates a full-fledged HTML snippet that includes Planga in your page.
25
51
  def chat_snippet
26
52
  return %{
27
53
  <script type=\"text/javascript\" src=\"#{self.remote_host}/js/js_snippet.js\"></script>
@@ -29,16 +55,20 @@ class Planga
29
55
  <script type=\"text/javascript\">
30
56
  new Planga(document.getElementById(\"#{self.container_id}\"), \{
31
57
  public_api_id: \"#{self.public_api_id}\",
32
- encrypted_options: \"#{encrypt_options()}\",
58
+ encrypted_options: \"#{encrypted_options()}\",
33
59
  socket_location: \"#{self.remote_host}/socket\",
60
+ debug: #{self.debug},
34
61
  \});
35
62
  </script>
36
63
  }
37
64
  end
38
65
 
39
66
 
40
- private
41
- def encrypt_options
67
+ # Returns the encrypted configuration.
68
+ #
69
+ # This function is useful if (and only if) you do not want to use the normal chat snippet,
70
+ # but want to completely customize how Planga loads (so you want to create it manually).
71
+ def encrypted_options
42
72
  key = JOSE::JWK.from({"k" => self.private_api_key, "kty" => "oct"})
43
73
 
44
74
  payload = {
@@ -53,4 +83,4 @@ class Planga
53
83
  { "alg" => "A128GCMKW", "enc" => "A128GCM" }
54
84
  ).compact
55
85
  end
56
- end
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wiebe Marten Wijnja
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-13 00:00:00.000000000 Z
12
+ date: 2018-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jose
@@ -25,15 +25,15 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.1'
28
- description: Wrapper for interacting with the Planga chat server.
29
- email:
28
+ description: Ruby Wrapper for interacting with the Planga Chat Service.
29
+ email: contact@planga.io
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - README.md
35
35
  - lib/planga.rb
36
- homepage: https://github.com/ResiliaDev/Planga
36
+ homepage: https://github.com/ResiliaDev/planga-ruby
37
37
  licenses:
38
38
  - MIT
39
39
  metadata: {}
@@ -53,8 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  requirements: []
55
55
  rubyforge_project:
56
- rubygems_version: 2.6.11
56
+ rubygems_version: 2.6.13
57
57
  signing_key:
58
58
  specification_version: 4
59
- summary: Planga
59
+ summary: Ruby Wrapper for the Planga Chat Service
60
60
  test_files: []