animatedledstrip-client 0.0.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c23ae558840af80bfb0161f275df791382dc716934c261fc9dff7398a3a7c4d
4
- data.tar.gz: a9ddabb34944385a0e252ce7367221c701859aeaaa6e1b8bbe469126a68d0557
3
+ metadata.gz: fca5e042206c2c7fe45a3ea6c83b1345d88b34d54d5fee12a6177ceb8dc2d0d4
4
+ data.tar.gz: e0f5367687ab1291b2ef73d7423179099d06ca54e320ca450eb1d7cd1a42b087
5
5
  SHA512:
6
- metadata.gz: 14c61a66d1a36b55f56ed61b242b6040fe752d2b408be4ce5b364d0ba2f37280089760e94fd4467bca9dc73153717b5d20440ca6690e1f97c62d16a11f18432f
7
- data.tar.gz: b8050a64d8ef24d47a0047f8edf4e55d1db80b43edba32d6eae4be8b901a0d94fe8bac89ab05fa5163526c326e6bd6cf946e3b6e90de39c5dae54ef5b8d060b4
6
+ metadata.gz: e6373bbf682ee21597645bd5307be3d7ed42e8089c49bc5f73318e9b458af7362568b8b904bfbeb6204a8205df6e75452e12b85ebf90d15a98c815b880333bcf
7
+ data.tar.gz: 6484a4a776ae1968b9073a1b8f4edd14e09ea1fc9b15afc533ce82da69d14fe57e93d589ea7e5531aa93e1abf69b37ee059fe7f4bc75f81c474ef96446197484
data/lib/animation.rb CHANGED
@@ -1,80 +1,109 @@
1
- module Animation
2
- COLOR = 0
3
- CUSTOM_ANIMATION = 1
4
- CUSTOM_REPETITIVE_ANIMATION = 2
5
- ALTERNATE = 3
6
- BOUNCE = 4
7
- BOUNCE_TO_COLOR = 5
8
- CAT_TOY = 6
9
- METEOR = 7
10
- MULTIPIXEL_RUN = 8
11
- MULTIPIXEL_RUN_TO_COLOR = 9
12
- RIPPLE = 10
13
- PIXEL_MARATHON = 11
14
- PIXEL_RUN = 12
15
- SMOOTH_CHASE = 13
16
- SMOOTH_FADE = 14
17
- SPARKLE = 15
18
- SPARKLE_FADE = 16
19
- SPARKLE_TO_COLOR = 17
20
- SPLAT = 18
21
- STACK = 19
22
- STACK_OVERFLOW = 20
23
- WIPE = 21
24
- END_ANIMATION = 22
25
-
26
- # @return [String]
27
- def self.string(animation)
28
- case animation
29
- when COLOR
30
- 'COLOR'
31
- when CUSTOM_ANIMATION
32
- 'CUSTOMANIMATION'
33
- when CUSTOM_REPETITIVE_ANIMATION
34
- 'CUSTOMREPETITIVEANIMATION'
35
- when ALTERNATE
36
- 'ALTERNATE'
37
- when BOUNCE
38
- 'BOUNCE'
39
- when BOUNCE_TO_COLOR
40
- 'BOUNCETOCOLOR'
41
- when CAT_TOY
42
- 'CATTOY'
43
- when METEOR
44
- 'METEOR'
45
- when MULTIPIXEL_RUN
46
- 'MULTIPIXELRUN'
47
- when MULTIPIXEL_RUN_TO_COLOR
48
- 'MULTIPIXELRUNTOCOLOR'
49
- when RIPPLE
50
- 'RIPPLE'
51
- when PIXEL_MARATHON
52
- 'PIXELMARATHON'
53
- when PIXEL_RUN
54
- 'PIXELRUN'
55
- when SMOOTH_CHASE
56
- 'SMOOTHCHASE'
57
- when SMOOTH_FADE
58
- 'SMOOTHFADE'
59
- when SPARKLE
60
- 'SPARKLE'
61
- when SPARKLE_FADE
62
- 'SPARKLEFADE'
63
- when SPARKLE_TO_COLOR
64
- 'SPARKLETOCOLOR'
65
- when SPLAT
66
- 'SPLAT'
67
- when STACK
68
- 'STACK'
69
- when STACK_OVERFLOW
70
- 'STACKOVERFLOW'
71
- when WIPE
72
- 'WIPE'
73
- when END_ANIMATION
74
- 'ENDANIMATION'
75
- else
76
- 'COLOR'
77
- end
78
- end
79
-
80
- end
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module Animation
22
+ COLOR = 0
23
+ CUSTOM_ANIMATION = 1
24
+ CUSTOM_REPETITIVE_ANIMATION = 2
25
+ ALTERNATE = 3
26
+ BOUNCE = 4
27
+ BOUNCE_TO_COLOR = 5
28
+ CAT_TOY = 6
29
+ CAT_TOY_TO_COLOR = 7
30
+ FADE_TO_COLOR = 8
31
+ FIREWORKS = 9
32
+ METEOR = 10
33
+ MULTIPIXEL_RUN = 11
34
+ MULTIPIXEL_RUN_TO_COLOR = 12
35
+ RIPPLE = 13
36
+ PIXEL_MARATHON = 14
37
+ PIXEL_RUN = 15
38
+ SMOOTH_CHASE = 16
39
+ SMOOTH_FADE = 17
40
+ SPARKLE = 18
41
+ SPARKLE_FADE = 19
42
+ SPARKLE_TO_COLOR = 20
43
+ SPLAT = 21
44
+ STACK = 22
45
+ STACK_OVERFLOW = 23
46
+ WIPE = 24
47
+ END_ANIMATION = 25
48
+
49
+ # @return [String]
50
+ def self.string(animation)
51
+ case animation
52
+ when COLOR
53
+ 'COLOR'
54
+ when CUSTOM_ANIMATION
55
+ 'CUSTOMANIMATION'
56
+ when CUSTOM_REPETITIVE_ANIMATION
57
+ 'CUSTOMREPETITIVEANIMATION'
58
+ when ALTERNATE
59
+ 'ALTERNATE'
60
+ when BOUNCE
61
+ 'BOUNCE'
62
+ when BOUNCE_TO_COLOR
63
+ 'BOUNCETOCOLOR'
64
+ when CAT_TOY
65
+ 'CATTOY'
66
+ when CAT_TOY_TO_COLOR
67
+ 'CATTOYTOCOLOR'
68
+ when FADE_TO_COLOR
69
+ 'FADETOCOLOR'
70
+ when FIREWORKS
71
+ 'FIREWORKS'
72
+ when METEOR
73
+ 'METEOR'
74
+ when MULTIPIXEL_RUN
75
+ 'MULTIPIXELRUN'
76
+ when MULTIPIXEL_RUN_TO_COLOR
77
+ 'MULTIPIXELRUNTOCOLOR'
78
+ when RIPPLE
79
+ 'RIPPLE'
80
+ when PIXEL_MARATHON
81
+ 'PIXELMARATHON'
82
+ when PIXEL_RUN
83
+ 'PIXELRUN'
84
+ when SMOOTH_CHASE
85
+ 'SMOOTHCHASE'
86
+ when SMOOTH_FADE
87
+ 'SMOOTHFADE'
88
+ when SPARKLE
89
+ 'SPARKLE'
90
+ when SPARKLE_FADE
91
+ 'SPARKLEFADE'
92
+ when SPARKLE_TO_COLOR
93
+ 'SPARKLETOCOLOR'
94
+ when SPLAT
95
+ 'SPLAT'
96
+ when STACK
97
+ 'STACK'
98
+ when STACK_OVERFLOW
99
+ 'STACKOVERFLOW'
100
+ when WIPE
101
+ 'WIPE'
102
+ when END_ANIMATION
103
+ 'ENDANIMATION'
104
+ else
105
+ 'COLOR'
106
+ end
107
+ end
108
+
109
+ end
@@ -1,64 +1,87 @@
1
- require_relative './imation.rb'
2
- require_relative './rection.rb'
3
- require_relative './lor_container.rb'
4
-
5
- class AnimationData
6
- attr_accessor :animation, :colors, :center,
7
- :continuous, :delay, :delay_mod,
8
- :direction, :distance, :end_pixel,
9
- :id, :spacing, :start_pixel
10
-
11
- def initialize
12
- @animation = Animation::COLOR
13
- @colors = []
14
- @center = -1
15
- @continuous = nil
16
- @delay = -1
17
- @delay_mod = 1.0
18
- @direction = Direction::FORWARD
19
- @distance = -1
20
- @end_pixel = -1
21
- @id = ''
22
- @spacing = -1
23
- @start_pixel = 0
24
- end
25
-
26
- def add_color(color)
27
- raise TypeError unless color.is_a? ColorContainer
28
-
29
- colors.push(color)
30
- end
31
-
32
- # @return [String]
33
- def json
34
- raise TypeError unless @animation.is_a? Integer
35
- raise TypeError unless @center.is_a? Integer
36
- raise TypeError unless @continuous.is_a?(Integer) || @continuous.nil?
37
- raise TypeError unless @delay.is_a? Integer
38
- raise TypeError unless @delay_mod.is_a? Float
39
- raise TypeError unless @direction.is_a? Integer
40
- raise TypeError unless @distance.is_a? Integer
41
- raise TypeError unless @end_pixel.is_a? Integer
42
- raise TypeError unless @id.is_a? String
43
- raise TypeError unless @spacing.is_a? Integer
44
- raise TypeError unless @start_pixel.is_a? Integer
45
-
46
- @colors.each { |cc| raise TypeError unless cc.is_a? ColorContainer }
47
-
48
- str = "DATA:{\"animation\":\"#{Animation.string(@animation)}\","\
49
- '"colors":['
50
- @colors.each { |cc| str += "#{cc.json}," }
51
- str.delete_suffix! ','
52
- str + '],'\
53
- "\"center\":#{@center},"\
54
- "\"continuous\":#{@continuous.nil? ? 'null' : @continuous},"\
55
- "\"delay\":#{@delay},"\
56
- "\"delayMod\":#{delay_mod},"\
57
- "\"direction\":\"#{Direction.string(@direction)}\","\
58
- "\"distance\":#{@distance},"\
59
- "\"endPixel\":#{@end_pixel},"\
60
- "\"id\":\"#{@id}\","\
61
- "\"spacing\":#{@spacing},"\
62
- "\"startPixel\":#{@start_pixel}}"
63
- end
64
- end
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'animation'
22
+ require_relative 'direction'
23
+ require_relative 'color_container'
24
+
25
+ class AnimationData
26
+ attr_accessor :animation, :colors, :center,
27
+ :continuous, :delay, :delay_mod,
28
+ :direction, :distance, :end_pixel,
29
+ :id, :spacing, :start_pixel
30
+
31
+ def initialize
32
+ @animation = Animation::COLOR
33
+ @colors = []
34
+ @center = -1
35
+ @continuous = nil
36
+ @delay = -1
37
+ @delay_mod = 1.0
38
+ @direction = Direction::FORWARD
39
+ @distance = -1
40
+ @end_pixel = -1
41
+ @id = ''
42
+ @spacing = -1
43
+ @start_pixel = 0
44
+ end
45
+
46
+ def add_color(color)
47
+ raise TypeError unless color.is_a? ColorContainer
48
+
49
+ colors.push(color)
50
+ end
51
+
52
+ # @return [String]
53
+ def json
54
+ raise TypeError unless @animation.is_a? Integer
55
+ raise TypeError unless @colors.is_a? Array
56
+ raise TypeError unless @center.is_a? Integer
57
+ unless @continuous.is_a?(TrueClass) || @continuous.is_a?(FalseClass) || @continuous.nil?
58
+ raise TypeError
59
+ end
60
+ raise TypeError unless @delay.is_a? Integer
61
+ raise TypeError unless @delay_mod.is_a? Float
62
+ raise TypeError unless @direction.is_a? Integer
63
+ raise TypeError unless @distance.is_a? Integer
64
+ raise TypeError unless @end_pixel.is_a? Integer
65
+ raise TypeError unless @id.is_a? String
66
+ raise TypeError unless @spacing.is_a? Integer
67
+ raise TypeError unless @start_pixel.is_a? Integer
68
+
69
+ @colors.each { |cc| raise TypeError unless cc.is_a? ColorContainer }
70
+
71
+ str = "DATA:{\"animation\":\"#{Animation.string(@animation)}\","\
72
+ '"colors":['
73
+ @colors.each { |cc| str += "#{cc.json}," }
74
+ str.delete_suffix! ','
75
+ str + '],'\
76
+ "\"center\":#{@center},"\
77
+ "\"continuous\":#{@continuous.nil? ? 'null' : @continuous},"\
78
+ "\"delay\":#{@delay},"\
79
+ "\"delayMod\":#{delay_mod},"\
80
+ "\"direction\":\"#{Direction.string(@direction)}\","\
81
+ "\"distance\":#{@distance},"\
82
+ "\"endPixel\":#{@end_pixel},"\
83
+ "\"id\":\"#{@id}\","\
84
+ "\"spacing\":#{@spacing},"\
85
+ "\"startPixel\":#{@start_pixel}}"
86
+ end
87
+ end
@@ -1,26 +1,46 @@
1
- require 'socket'
2
- require_relative './animation_sender.rb'
3
-
4
- class AnimationSender
5
- attr_accessor :address, :port
6
-
7
- def initialize(address, port)
8
- @address = address
9
- @port = port
10
- end
11
-
12
- def start
13
- @socket = TCPSocket.new @address, @port
14
- end
15
-
16
- def end
17
- @socket.close
18
- end
19
-
20
- def send_animation(animation)
21
- raise TypeError unless animation.is_a? AnimationData
22
-
23
- @socket.write animation.json
24
- end
25
-
26
- end
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'socket'
22
+ require_relative 'animation_data'
23
+
24
+ class AnimationSender
25
+ attr_accessor :address, :port
26
+
27
+ def initialize(address, port)
28
+ @address = address
29
+ @port = port
30
+ end
31
+
32
+ def start
33
+ @socket = TCPSocket.new @address, @port
34
+ end
35
+
36
+ def end
37
+ @socket.close
38
+ end
39
+
40
+ def send_animation(animation)
41
+ raise TypeError unless animation.is_a? AnimationData
42
+
43
+ @socket.write animation.json
44
+ end
45
+
46
+ end
@@ -1,25 +1,45 @@
1
- class ColorContainer
2
- attr_accessor :colors
3
-
4
- def initialize
5
- @colors = []
6
- end
7
-
8
- # @return [String]
9
- def json
10
- @colors.each { |c| raise TypeError unless c.is_a? Integer }
11
- str = '{"colors":['
12
- @colors.each do |c|
13
- str.concat(c.to_s, ',')
14
- end
15
- str.delete_suffix! ','
16
- str + ']}'
17
- end
18
-
19
- def add_color(color)
20
- raise TypeError unless color.is_a? Integer
21
-
22
- @colors.push(color)
23
- end
24
-
25
- end
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ class ColorContainer
22
+ attr_accessor :colors
23
+
24
+ def initialize
25
+ @colors = []
26
+ end
27
+
28
+ # @return [String]
29
+ def json
30
+ @colors.each { |c| raise TypeError unless c.is_a? Integer }
31
+ str = '{"colors":['
32
+ @colors.each do |c|
33
+ str.concat(c.to_s, ',')
34
+ end
35
+ str.delete_suffix! ','
36
+ str + ']}'
37
+ end
38
+
39
+ def add_color(color)
40
+ raise TypeError unless color.is_a? Integer
41
+
42
+ @colors.push(color)
43
+ end
44
+
45
+ end
data/lib/direction.rb CHANGED
@@ -1,15 +1,35 @@
1
- module Direction
2
- FORWARD = 0
3
- BACKWARD = 1
4
-
5
- def self.string(direction)
6
- case direction
7
- when FORWARD
8
- 'FORWARD'
9
- when BACKWARD
10
- 'BACKWARD'
11
- else
12
- 'FORWARD'
13
- end
14
- end
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module Direction
22
+ FORWARD = 0
23
+ BACKWARD = 1
24
+
25
+ def self.string(direction)
26
+ case direction
27
+ when FORWARD
28
+ 'FORWARD'
29
+ when BACKWARD
30
+ 'BACKWARD'
31
+ else
32
+ 'FORWARD'
33
+ end
34
+ end
15
35
  end
@@ -0,0 +1,121 @@
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'helper'
22
+ require 'minitest/autorun'
23
+ require_relative '../lib/animation'
24
+
25
+ class AnimationTest < Minitest::Test
26
+ def test_color_string
27
+ assert_equal 'COLOR', Animation.string(Animation::COLOR)
28
+ end
29
+
30
+ def test_custom_animation_string
31
+ assert_equal 'CUSTOMANIMATION', Animation.string(Animation::CUSTOM_ANIMATION)
32
+ end
33
+
34
+ def test_custom_rep_anim_string
35
+ assert_equal 'CUSTOMREPETITIVEANIMATION', Animation.string(Animation::CUSTOM_REPETITIVE_ANIMATION)
36
+ end
37
+
38
+ def test_alternate_string
39
+ assert_equal 'ALTERNATE', Animation.string(Animation::ALTERNATE)
40
+ end
41
+
42
+ def test_bounce_string
43
+ assert_equal 'BOUNCE', Animation.string(Animation::BOUNCE)
44
+ end
45
+
46
+ def test_bounce_to_color_string
47
+ assert_equal 'BOUNCETOCOLOR', Animation.string(Animation::BOUNCE_TO_COLOR)
48
+ end
49
+
50
+ def test_cat_toy_string
51
+ assert_equal 'CATTOY', Animation.string(Animation::CAT_TOY)
52
+ end
53
+
54
+ def test_meteor_string
55
+ assert_equal 'METEOR', Animation.string(Animation::METEOR)
56
+ end
57
+
58
+ def test_multipixel_run_string
59
+ assert_equal 'MULTIPIXELRUN', Animation.string(Animation::MULTIPIXEL_RUN)
60
+ end
61
+
62
+ def test_multipixel_rtc_string
63
+ assert_equal 'MULTIPIXELRUNTOCOLOR', Animation.string(Animation::MULTIPIXEL_RUN_TO_COLOR)
64
+ end
65
+
66
+ def test_ripple_string
67
+ assert_equal 'RIPPLE', Animation.string(Animation::RIPPLE)
68
+ end
69
+
70
+ def test_pixel_marathon_string
71
+ assert_equal 'PIXELMARATHON', Animation.string(Animation::PIXEL_MARATHON)
72
+ end
73
+
74
+ def test_pixel_run_string
75
+ assert_equal 'PIXELRUN', Animation.string(Animation::PIXEL_RUN)
76
+ end
77
+
78
+ def test_smooth_chase_string
79
+ assert_equal 'SMOOTHCHASE', Animation.string(Animation::SMOOTH_CHASE)
80
+ end
81
+
82
+ def test_smooth_fade_string
83
+ assert_equal 'SMOOTHFADE', Animation.string(Animation::SMOOTH_FADE)
84
+ end
85
+
86
+ def test_sparkle_string
87
+ assert_equal 'SPARKLE', Animation.string(Animation::SPARKLE)
88
+ end
89
+
90
+ def test_sparkle_fade_string
91
+ assert_equal 'SPARKLEFADE', Animation.string(Animation::SPARKLE_FADE)
92
+ end
93
+
94
+ def test_sparkle_to_color_string
95
+ assert_equal 'SPARKLETOCOLOR', Animation.string(Animation::SPARKLE_TO_COLOR)
96
+ end
97
+
98
+ def test_splat_string
99
+ assert_equal 'SPLAT', Animation.string(Animation::SPLAT)
100
+ end
101
+
102
+ def test_stack_string
103
+ assert_equal 'STACK', Animation.string(Animation::STACK)
104
+ end
105
+
106
+ def test_stack_overflow_string
107
+ assert_equal 'STACKOVERFLOW', Animation.string(Animation::STACK_OVERFLOW)
108
+ end
109
+
110
+ def test_wipe_string
111
+ assert_equal 'WIPE', Animation.string(Animation::WIPE)
112
+ end
113
+
114
+ def test_end_animation_string
115
+ assert_equal 'ENDANIMATION', Animation.string(Animation::END_ANIMATION)
116
+ end
117
+
118
+ def test_default_string
119
+ assert_equal 'COLOR', Animation.string(-1)
120
+ end
121
+ end
@@ -0,0 +1,200 @@
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'helper'
22
+ require 'minitest'
23
+ require_relative '../lib/animation_data'
24
+
25
+ class AnimationDataTest < Minitest::Test
26
+ def test_initialization
27
+ anim = AnimationData.new
28
+
29
+ assert_equal Animation::COLOR, anim.animation
30
+ assert_equal(-1, anim.center)
31
+ assert_nil anim.continuous
32
+ assert_equal(-1, anim.delay)
33
+ assert_equal 1.0, anim.delay_mod
34
+ assert_equal Direction::FORWARD, anim.direction
35
+ assert_equal(-1, anim.distance)
36
+ assert_equal(-1, anim.end_pixel)
37
+ assert_equal '', anim.id
38
+ assert_equal(-1, anim.spacing)
39
+ assert_equal 0, anim.start_pixel
40
+ end
41
+
42
+ def test_add_color
43
+ cc = ColorContainer.new
44
+ cc.add_color(0xFF)
45
+
46
+ anim = AnimationData.new
47
+ anim.add_color(cc)
48
+
49
+ assert anim.colors.include? cc
50
+
51
+ assert_raises TypeError do
52
+ anim.add_color(0xFF)
53
+ end
54
+ end
55
+
56
+ def test_json
57
+ anim = AnimationData.new
58
+ anim.animation = Animation::METEOR
59
+ anim.center = 50
60
+ anim.continuous = false
61
+ anim.delay = 10
62
+ anim.delay_mod = 1.5
63
+ anim.direction = Direction::BACKWARD
64
+ anim.distance = 45
65
+ anim.end_pixel = 200
66
+ anim.id = 'TEST'
67
+ anim.spacing = 5
68
+ anim.start_pixel = 15
69
+
70
+ cc = ColorContainer.new
71
+ cc2 = ColorContainer.new
72
+ cc.add_color 0xFF
73
+ cc.add_color 0xFF00
74
+ cc2.add_color 0xFF0000
75
+
76
+ anim.add_color cc
77
+ anim.add_color cc2
78
+
79
+ assert_equal 'DATA:{"animation":"METEOR","colors":[{'\
80
+ '"colors":[255,65280]},{"colors":[16711680]}],"center":50,'\
81
+ '"continuous":false,"delay":10,"delayMod":1.5,'\
82
+ '"direction":"BACKWARD","distance":45,"endPixel":200,'\
83
+ '"id":"TEST","spacing":5,"startPixel":15}', anim.json
84
+ end
85
+
86
+ def test_json_animation_failure
87
+ anim = AnimationData.new
88
+
89
+ anim.animation = 'A'
90
+ assert_raises TypeError do
91
+ anim.json
92
+ end
93
+ end
94
+
95
+ def test_json_center_failure
96
+ anim = AnimationData.new
97
+
98
+ anim.center = 'A'
99
+ assert_raises TypeError do
100
+ anim.json
101
+ end
102
+ end
103
+
104
+ def test_json_continuous_failure
105
+ anim = AnimationData.new
106
+
107
+ anim.continuous = 'A'
108
+ assert_raises TypeError do
109
+ anim.json
110
+ end
111
+ end
112
+
113
+ def test_json_delay_failure
114
+ anim = AnimationData.new
115
+
116
+ anim.delay = 'A'
117
+ assert_raises TypeError do
118
+ anim.json
119
+ end
120
+ end
121
+
122
+ def test_json_delay_mod_failure
123
+ anim = AnimationData.new
124
+
125
+ anim.delay_mod = 'A'
126
+ assert_raises TypeError do
127
+ anim.json
128
+ end
129
+ end
130
+
131
+ def test_json_direction_failure
132
+ anim = AnimationData.new
133
+
134
+ anim.direction = 'A'
135
+ assert_raises TypeError do
136
+ anim.json
137
+ end
138
+ end
139
+
140
+ def test_json_distance_failure
141
+ anim = AnimationData.new
142
+
143
+ anim.distance = 'A'
144
+ assert_raises TypeError do
145
+ anim.json
146
+ end
147
+ end
148
+
149
+ def test_json_end_pixel_failure
150
+ anim = AnimationData.new
151
+
152
+ anim.end_pixel = 'A'
153
+ assert_raises TypeError do
154
+ anim.json
155
+ end
156
+ end
157
+
158
+ def test_json_id_failure
159
+ skip
160
+ anim = AnimationData.new
161
+
162
+ anim.continuous = nil
163
+ assert_raises TypeError do
164
+ anim.json
165
+ end
166
+ end
167
+
168
+ def test_json_spacing_failure
169
+ anim = AnimationData.new
170
+
171
+ anim.spacing = 'A'
172
+ assert_raises TypeError do
173
+ anim.json
174
+ end
175
+ end
176
+
177
+ def test_json_start_pixel_failure
178
+ anim = AnimationData.new
179
+
180
+ anim.start_pixel = 'A'
181
+ assert_raises TypeError do
182
+ anim.json
183
+ end
184
+ end
185
+
186
+ def test_json_colors_failure
187
+ anim = AnimationData.new
188
+
189
+ anim.colors = anim.colors.append 'A'
190
+
191
+ assert_raises TypeError do
192
+ anim.json
193
+ end
194
+
195
+ anim.colors = 'A'
196
+ assert_raises TypeError do
197
+ anim.json
198
+ end
199
+ end
200
+ end
@@ -0,0 +1,32 @@
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'helper'
22
+ require 'minitest'
23
+ require_relative '../lib/animation_sender'
24
+
25
+ class AnimationSenderTest < Minitest::Test
26
+ def test_initialization
27
+ sender = AnimationSender.new '10.0.0.254', 5
28
+
29
+ assert_equal '10.0.0.254', sender.address
30
+ assert_equal 5, sender.port
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright (c) 2019-2020 AnimatedLEDStrip
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'helper'
22
+ require 'minitest'
23
+ require_relative '../lib/direction'
24
+
25
+ class DirectionTest < Minitest::Test
26
+ def test_direction_string
27
+ assert_equal 'FORWARD', Direction.string(Direction::FORWARD)
28
+ assert_equal 'BACKWARD', Direction.string(Direction::BACKWARD)
29
+ assert_equal 'FORWARD', Direction.string(-1)
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: animatedledstrip-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Narvaez
@@ -9,7 +9,91 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-11-05 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: url
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
13
97
  description:
14
98
  email:
15
99
  executables: []
@@ -21,6 +105,10 @@ files:
21
105
  - lib/animation_sender.rb
22
106
  - lib/color_container.rb
23
107
  - lib/direction.rb
108
+ - test/test_animation.rb
109
+ - test/test_animation_data.rb
110
+ - test/test_animation_sender.rb
111
+ - test/test_direction.rb
24
112
  homepage:
25
113
  licenses: []
26
114
  metadata: {}
@@ -40,8 +128,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
128
  version: '0'
41
129
  requirements: []
42
130
  rubyforge_project:
43
- rubygems_version: 2.7.6
131
+ rubygems_version: 2.7.7
44
132
  signing_key:
45
133
  specification_version: 4
46
134
  summary: Library for connecting to an AnimatedLEDStripServer
47
- test_files: []
135
+ test_files:
136
+ - test/test_animation.rb
137
+ - test/test_animation_data.rb
138
+ - test/test_animation_sender.rb
139
+ - test/test_direction.rb