ruby-ray 0.2.0 → 0.3.0

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: 3fa98312ac698f1368bcdba806e12551eefde2b21f1a4bfcf817c08e73b42628
4
- data.tar.gz: f8b61fe51c4ed5aa22ec12be7b28cd9bf6be9ad4e367c49e12b343969e53a41d
3
+ metadata.gz: 255d912e394ce3694f1ad4f46b1d26aafb8dd728b890b8d0939a6446f96a7cb3
4
+ data.tar.gz: 6bc5a985c7796c9a077193757b6a99344340298bacf13bf3d67256bdba469e20
5
5
  SHA512:
6
- metadata.gz: c3d87dd7beea1015e61a589089195749b812e7197fe1333c934682afa581140d23a0bde99853ef0ac9a40ce99b68d2452436158438e347a4e7775a162c6759ed
7
- data.tar.gz: '048da58bfdf3d105083cb9e7feb532ee37e29ac3f2ab94f5b670950a4b0eb35e1b827f8eec0ef2378d31f410f1bd3dfe78c41cc14662a1200fffcdac65281627'
6
+ metadata.gz: 6f35df59ebb4b5161d68077f4dfcf013c3349ec54de260dd9e6bea9a712c63498e6b2700ac8e89efc2b079c926465035663f30ae649ccbab32f1227c17c65c80
7
+ data.tar.gz: 8bb13fb068393ad54559061da0db21efd3405d1ba13a9bad9b6d279dec4e38d6dd967e369198c98322bc680f3cd546da59f02fca9389d16f5b3b6cbeaff9c76f
@@ -1,4 +1,4 @@
1
- name: Ruby
1
+ name: Tests
2
2
 
3
3
  on: [push,pull_request]
4
4
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to `ruby-ray` will be documented in this file.
4
+
5
+ ## [0.3.0] - 2021-02-11
6
+
7
+ - more payloads
8
+
1
9
  ## [0.2.0] - 2021-02-11
2
10
 
3
11
  - Relax activesupport dependency
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Debug with Ray to fix problems faster
2
2
 
3
+ ![Gem](https://img.shields.io/gem/v/ruby-ray)
4
+ ![Tests](https://github.com/spatie/ruby-ray/workflows/Tests/badge.svg)
5
+ ![Downloads](https://img.shields.io/gem/dt/ruby-ray)
6
+
3
7
  This gem can be installed in any Ruby application to send messages to [the Ray app](https://myray.app).
4
8
 
5
9
  ## Documentation
@@ -0,0 +1,7 @@
1
+ require_relative "../lib/ray"
2
+
3
+ ray.new_screen('Class name')
4
+
5
+ ray.class_name('this is a string')
6
+ ray.class_name(5)
7
+ ray.class_name(0..5)
data/examples/colors.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require_relative "../lib/ray"
2
2
 
3
- # ray.new_screen('Colors')
3
+ ray.new_screen('Colors')
4
4
 
5
5
  ray('this is green').green
6
6
  ray('this is orange').orange
data/examples/demo.rb ADDED
@@ -0,0 +1,3 @@
1
+ require_relative "../lib/ray"
2
+
3
+ ray('demo')
data/examples/json.rb ADDED
@@ -0,0 +1,5 @@
1
+ require_relative "../lib/ray"
2
+
3
+ ray.new_screen('Json')
4
+
5
+ ray.to_json('string', ['a', 'b', 'c'])
File without changes
data/examples/size.rb ADDED
@@ -0,0 +1,6 @@
1
+ require_relative "../lib/ray"
2
+
3
+ ray.new_screen('Size')
4
+
5
+ ray('Small item').small
6
+ ray('Large item').large
@@ -6,7 +6,7 @@ ray('collapsed by default').hide
6
6
 
7
7
  ray = ray('updating this message in two seconds')
8
8
  sleep(2)
9
- ray.send('updated message');
9
+ ray.send('updated message')
10
10
 
11
11
  ray = ray('removing this item in two seconds')
12
12
  sleep(2)
data/lib/ray.rb CHANGED
@@ -21,6 +21,8 @@ require_relative "ray/payloads/show_app_payload"
21
21
  require_relative "ray/payloads/custom_payload"
22
22
  require_relative "ray/payloads/notify_payload"
23
23
  require_relative "ray/payloads/create_lock_payload"
24
+ require_relative "ray/payloads/size_payload"
25
+ require_relative "ray/payloads/json_string_payload"
24
26
 
25
27
  module Ray
26
28
  class Ray
@@ -53,6 +55,14 @@ module Ray
53
55
  color 'gray'
54
56
  end
55
57
 
58
+ def small
59
+ size 'sm'
60
+ end
61
+
62
+ def large
63
+ size 'lg'
64
+ end
65
+
56
66
  def new_screen(name = '')
57
67
  payload = Payloads::NewScreenPayload.new(name)
58
68
 
@@ -99,6 +109,30 @@ module Ray
99
109
  send_request payload
100
110
  end
101
111
 
112
+ def size(size)
113
+ payload = Payloads::SizePayload.new(size)
114
+
115
+ send_custom payload
116
+ end
117
+
118
+ def class_name(anything)
119
+ send_custom(anything.class.to_s, 'Class name')
120
+ end
121
+
122
+ def to_json(*args)
123
+ payloads = args.map do |arg|
124
+ Payloads::JsonStringPayload.new(arg)
125
+ end
126
+
127
+ send_request payloads
128
+ end
129
+
130
+ def pass(argument)
131
+ send argument
132
+
133
+ return argument
134
+ end
135
+
102
136
  def pause
103
137
  lockName = rand(10 ** 12).to_s
104
138
 
@@ -0,0 +1,18 @@
1
+ module Ray
2
+ module Origin
3
+ class Origin
4
+
5
+ def initialize(file, lineNumber)
6
+ @file = file
7
+ @lineNumber = lineNumber
8
+ end
9
+
10
+ def to_hash
11
+ {
12
+ file: @file,
13
+ line_number: @lineNumber,
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "origin"
2
+
3
+ module Ray
4
+ module Origin
5
+ class OriginFactory
6
+ def get_origin
7
+ location = self.get_location
8
+
9
+ Origin.new(
10
+ location ? location.absolute_path: nil,
11
+ location ? location.lineno : nil,
12
+ )
13
+ end
14
+
15
+ def get_location
16
+ caller_locations.find { |location| ! location.path.include? "ruby-ray/lib" }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Ray
2
+ module Payloads
3
+ class JsonStringPayload < Payload
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+
9
+ def type
10
+ 'json_string'
11
+ end
12
+
13
+ def content
14
+ {
15
+ value: @value.to_json,
16
+ }
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,9 +1,10 @@
1
+ require_relative "../origin/origin_factory"
2
+
1
3
  module Ray
2
4
  module Payloads
3
5
  class Payload
4
6
 
5
- def initialize(*args)
6
- end
7
+ def initialize(*args) end
7
8
 
8
9
  def type
9
10
  raise NotImplementedError, 'You must define the `type` method in your Payload'
@@ -13,6 +14,17 @@ module Ray
13
14
  {}
14
15
  end
15
16
 
17
+ def to_hash
18
+ {
19
+ type: self.type,
20
+ content: self.content,
21
+ origin: self.get_origin.to_hash
22
+ }
23
+ end
24
+
25
+ def get_origin
26
+ Origin::OriginFactory.new.get_origin
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -0,0 +1,22 @@
1
+ module Ray
2
+ module Payloads
3
+ class SizePayload < Payload
4
+
5
+ def initialize(size)
6
+ @size = size
7
+ end
8
+
9
+ def type
10
+ 'size'
11
+ end
12
+
13
+ def content
14
+ {
15
+ size: @size,
16
+ }
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
data/lib/ray/request.rb CHANGED
@@ -11,15 +11,9 @@ module Ray
11
11
  end
12
12
 
13
13
  def payload_contents
14
+
14
15
  return @payloads.map do |payload|
15
- {
16
- type: payload.type,
17
- content: payload.content,
18
- origin: {
19
- file: "the file",
20
- line_number: "123",
21
- },
22
- }
16
+ payload.to_hash
23
17
  end
24
18
  end
25
19
  end
data/lib/ray/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ray
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Freek Van der Herten
@@ -33,7 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".github/SECURITY.md"
36
- - ".github/workflows/main.yml"
36
+ - ".github/workflows/tests.yml"
37
37
  - ".gitignore"
38
38
  - CHANGELOG.md
39
39
  - CODE_OF_CONDUCT.md
@@ -43,16 +43,22 @@ files:
43
43
  - Rakefile
44
44
  - bin/console
45
45
  - bin/setup
46
+ - examples/class_name.rb
46
47
  - examples/colors.rb
47
48
  - examples/custom.rb
49
+ - examples/demo.rb
48
50
  - examples/general.rb
49
- - examples/newScreen.rb
51
+ - examples/json.rb
52
+ - examples/new_screen.rb
50
53
  - examples/notify.rb
51
54
  - examples/pause.rb
55
+ - examples/size.rb
52
56
  - examples/visibility.rb
53
57
  - lib/ray.rb
54
58
  - lib/ray/client.rb
55
59
  - lib/ray/errors/stop_execution_requested.rb
60
+ - lib/ray/origin/origin.rb
61
+ - lib/ray/origin/origin_factory.rb
56
62
  - lib/ray/payload_factory.rb
57
63
  - lib/ray/payloads/bool_payload.rb
58
64
  - lib/ray/payloads/color_payload.rb
@@ -61,12 +67,14 @@ files:
61
67
  - lib/ray/payloads/hide_app_payload.rb
62
68
  - lib/ray/payloads/hide_payload.rb
63
69
  - lib/ray/payloads/int_payload.rb
70
+ - lib/ray/payloads/json_string_payload.rb
64
71
  - lib/ray/payloads/new_screen_payload.rb
65
72
  - lib/ray/payloads/notify_payload.rb
66
73
  - lib/ray/payloads/null_payload.rb
67
74
  - lib/ray/payloads/payload.rb
68
75
  - lib/ray/payloads/remove_payload.rb
69
76
  - lib/ray/payloads/show_app_payload.rb
77
+ - lib/ray/payloads/size_payload.rb
70
78
  - lib/ray/payloads/string_payload.rb
71
79
  - lib/ray/request.rb
72
80
  - lib/ray/version.rb