animatedledstrip-client 0.6.1 → 0.7

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: fca5e042206c2c7fe45a3ea6c83b1345d88b34d54d5fee12a6177ceb8dc2d0d4
4
- data.tar.gz: e0f5367687ab1291b2ef73d7423179099d06ca54e320ca450eb1d7cd1a42b087
3
+ metadata.gz: 44ee0ca8508dde26832002725e9eccbb80c7ea92cdfbd7b22570f5a8d46795a0
4
+ data.tar.gz: 0c21f44b090c5f014d0560f06ed780cc5b5d284505e32e20019cdb6ef97ac1c8
5
5
  SHA512:
6
- metadata.gz: e6373bbf682ee21597645bd5307be3d7ed42e8089c49bc5f73318e9b458af7362568b8b904bfbeb6204a8205df6e75452e12b85ebf90d15a98c815b880333bcf
7
- data.tar.gz: 6484a4a776ae1968b9073a1b8f4edd14e09ea1fc9b15afc533ce82da69d14fe57e93d589ea7e5531aa93e1abf69b37ee059fe7f4bc75f81c474ef96446197484
6
+ metadata.gz: 806c8e33820e5d8d3da6275b5afb607437234cc90682c1e47ded9c8a8bd33ef36c8c7a503deb00343459dc27f285cd8fd5471570b360c18fc6d4d618611da620
7
+ data.tar.gz: 2dc111d24506f56d5f1612b64319f92e758f108ac507f0bd39882f7ccebe71402dc72e4d3242dbc2d4dd38a99725607e4edcde0a59a2e31b1bb9b364443069ee
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.idea/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ Gemfile.lock
@@ -0,0 +1,35 @@
1
+ ---
2
+ language: ruby
3
+
4
+ rvm:
5
+ - 2.6.6
6
+
7
+ before_install:
8
+ - gem update --system
9
+ - gem install bundler --no-document
10
+
11
+ branches:
12
+ only:
13
+ - master
14
+ - /^travis.*/
15
+ - /^v.*/
16
+
17
+ stages:
18
+ - name: test
19
+ - name: deploy
20
+ if: tag IS present
21
+
22
+ jobs:
23
+ include:
24
+ - stage: test
25
+ script: bundle exec rake
26
+
27
+ - stage: deploy
28
+ install: skip
29
+ script: skip
30
+ deploy:
31
+ - provider: rubygems
32
+ api_key: $RUBYGEMS_KEY
33
+ gem: animatedledstrip-client
34
+ on:
35
+ all_branches: true
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+ gem "codecov", :require => false, :group => :test
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-2020 AnimatedLEDStrip
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,101 @@
1
+ # AnimatedLEDStrip Client Library for Ruby
2
+
3
+ [![Build Status](https://travis-ci.com/AnimatedLEDStrip/client-ruby.svg?branch=master)](https://travis-ci.com/AnimatedLEDStrip/client-ruby)
4
+ [![Gem Version](https://badge.fury.io/rb/animatedledstrip-client.svg)](https://badge.fury.io/rb/animatedledstrip-client)
5
+ [![codecov](https://codecov.io/gh/AnimatedLEDStrip/client-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/AnimatedLEDStrip/client-ruby)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'animatedledstrip-client'
13
+ ```
14
+
15
+ Or install with:
16
+
17
+ $ gem install animatedledstrip-client
18
+
19
+ ## Creating an `AnimationSender`
20
+ An `AnimationSender` is constructed with two arguments:
21
+ - `host`: The IP address of the server (as a string)
22
+ - `port`: The port that the client should connect to (as an integer)
23
+
24
+ ```ruby
25
+ sender = AnimationSender.new("10.0.0.254", 5);
26
+ ```
27
+
28
+ ## Starting the `AnimationSender`
29
+ An `AnimationSender` is started by calling the `start()` method on the instance.
30
+
31
+ ```ruby
32
+ sender.start
33
+ ```
34
+
35
+ ## Stopping the `AnimationSender`
36
+ To stop the `AnimationSender`, call its `end()` method.
37
+
38
+ ```ruby
39
+ sender.end
40
+ ```
41
+
42
+ ## Sending Data
43
+
44
+ ### AnimationData
45
+ An animation can be sent to the server by creating an `AnimationData` instance, then calling `send_animation` with the instance as the argument.
46
+
47
+ ```ruby
48
+ cc = ColorContainer.new
49
+ cc.add_color 0xFF
50
+ cc.add_color 0xFF00
51
+
52
+ data = AnimationData.new
53
+ data.add_color cc
54
+
55
+ sender.send_animation data
56
+ ```
57
+
58
+ ### EndAnimation
59
+ The end of an animation can be sent to the server by creating an `EndAnimation` instance, then calling `send_end_animation` with the instance as the argument.
60
+
61
+ ```ruby
62
+ end_anim = EndAnimation.new
63
+ end_anim.id = "ANIM_ID"
64
+
65
+ sender.send_end_animation end_anim
66
+ ```
67
+
68
+ ### Section
69
+ A new section can be sent to the server by creating a `Section` instance, then calling `send_section` with the instance as the argument.
70
+ Note that changing `num_leds` or `physical_start` will have no effect on the new section.
71
+
72
+ ```ruby
73
+ sect = Section.new
74
+ sect.name = "SECTION"
75
+ sect.start_pixel = 5
76
+ sect.end_pixel = 30
77
+
78
+ sender.send_section sect
79
+ ```
80
+
81
+ #### `AnimationData` type notes
82
+ The Ruby library uses the following values for `continuous` and `direction`:
83
+ - `continuous`: `nil`, `true`, `false`
84
+ - `direction`: `Direction::FORWARD`, `Direction::BACKWARD`
85
+
86
+ ## Receiving Data
87
+
88
+ ### Supported Animations
89
+ Supported animations are stored in the sender's `supported_animations` hash.
90
+
91
+ ### Running Animations
92
+ Running animations are stored in the sender's `running_animations` hash.
93
+
94
+ ### Ending Animations
95
+ Animations are removed from the sender's `running_animations` hash.
96
+
97
+ ### New Section
98
+ Sections are stored in the sender's `sections` hash.
99
+
100
+ ### Strip Info
101
+ The strip's info is stored in the sender's `strip_info` attribute.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "animatedledstrip-client"
6
+ spec.version = "0.7"
7
+ spec.authors = ["Max Narvaez"]
8
+ spec.email = ["mnmax.narvaez3@gmail.com"]
9
+
10
+ spec.summary = "Library for connecting to an AnimatedLEDStripServer"
11
+ spec.homepage = "https://github.com/AnimatedLEDStrip/client-ruby"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
15
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ end
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_runtime_dependency "json"
20
+ spec.add_runtime_dependency "simplecov"
21
+ spec.add_runtime_dependency "url"
22
+
23
+ spec.add_development_dependency "mocha"
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "minitest"
27
+ end
@@ -18,18 +18,18 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'animation'
22
- require_relative 'direction'
23
- require_relative 'color_container'
21
+ require_relative "direction"
22
+ require_relative "color_container"
24
23
 
24
+ #noinspection RubyTooManyInstanceVariablesInspection
25
25
  class AnimationData
26
26
  attr_accessor :animation, :colors, :center,
27
27
  :continuous, :delay, :delay_mod,
28
- :direction, :distance, :end_pixel,
29
- :id, :spacing, :start_pixel
28
+ :direction, :distance, :id,
29
+ :section, :spacing
30
30
 
31
31
  def initialize
32
- @animation = Animation::COLOR
32
+ @animation = "Color"
33
33
  @colors = []
34
34
  @center = -1
35
35
  @continuous = nil
@@ -37,10 +37,9 @@ class AnimationData
37
37
  @delay_mod = 1.0
38
38
  @direction = Direction::FORWARD
39
39
  @distance = -1
40
- @end_pixel = -1
41
- @id = ''
40
+ @id = ""
41
+ @section = ""
42
42
  @spacing = -1
43
- @start_pixel = 0
44
43
  end
45
44
 
46
45
  def add_color(color)
@@ -51,7 +50,7 @@ class AnimationData
51
50
 
52
51
  # @return [String]
53
52
  def json
54
- raise TypeError unless @animation.is_a? Integer
53
+ raise TypeError unless @animation.is_a? String
55
54
  raise TypeError unless @colors.is_a? Array
56
55
  raise TypeError unless @center.is_a? Integer
57
56
  unless @continuous.is_a?(TrueClass) || @continuous.is_a?(FalseClass) || @continuous.nil?
@@ -61,27 +60,44 @@ class AnimationData
61
60
  raise TypeError unless @delay_mod.is_a? Float
62
61
  raise TypeError unless @direction.is_a? Integer
63
62
  raise TypeError unless @distance.is_a? Integer
64
- raise TypeError unless @end_pixel.is_a? Integer
65
63
  raise TypeError unless @id.is_a? String
64
+ raise TypeError unless @section.is_a? String
66
65
  raise TypeError unless @spacing.is_a? Integer
67
- raise TypeError unless @start_pixel.is_a? Integer
68
66
 
69
67
  @colors.each { |cc| raise TypeError unless cc.is_a? ColorContainer }
70
68
 
71
- str = "DATA:{\"animation\":\"#{Animation.string(@animation)}\","\
69
+ str = "DATA:{\"animation\":\"#{@animation}\","\
72
70
  '"colors":['
73
71
  @colors.each { |cc| str += "#{cc.json}," }
74
72
  str.delete_suffix! ','
75
- str + '],'\
73
+ str += '],'\
76
74
  "\"center\":#{@center},"\
77
75
  "\"continuous\":#{@continuous.nil? ? 'null' : @continuous},"\
78
76
  "\"delay\":#{@delay},"\
79
77
  "\"delayMod\":#{delay_mod},"\
80
78
  "\"direction\":\"#{Direction.string(@direction)}\","\
81
79
  "\"distance\":#{@distance},"\
82
- "\"endPixel\":#{@end_pixel},"\
83
80
  "\"id\":\"#{@id}\","\
84
- "\"spacing\":#{@spacing},"\
85
- "\"startPixel\":#{@start_pixel}}"
81
+ "\"section\":\"#{section}\","\
82
+ "\"spacing\":#{@spacing}}"
83
+
84
+ str
85
+ end
86
+
87
+ def self.new_from_json(json_data)
88
+ data = AnimationData.new
89
+ data.animation = json_data["animation"] unless json_data["animation"].nil?
90
+ json_data["colors"].each { |cc| data.add_color(ColorContainer.new_from_json cc) }
91
+ data.center = json_data["center"] unless json_data["center"].nil?
92
+ data.continuous = json_data["continuous"]
93
+ data.delay = json_data["delay"] unless json_data["delay"].nil?
94
+ data.delay_mod = json_data["delayMod"] unless json_data["delayMod"].nil?
95
+ data.direction = Direction::from_string(json_data["direction"]) unless json_data["direction"].nil?
96
+ data.distance = json_data["distance"] unless json_data["distance"].nil?
97
+ data.id = json_data["id"] unless json_data["id"].nil?
98
+ data.section = json_data["section"] unless json_data["section"].nil?
99
+ data.spacing = json_data["spacing"] unless json_data["spacing"].nil?
100
+
101
+ data
86
102
  end
87
103
  end
@@ -0,0 +1,71 @@
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 'param_usage'
22
+
23
+ #noinspection RubyTooManyInstanceVariablesInspection
24
+ class AnimationInfo
25
+ attr_accessor :name, :abbr, :description,
26
+ :signature_file, :repetitive,
27
+ :minimum_colors, :unlimited_colors,
28
+ :center, :delay, :direction,
29
+ :distance, :spacing, :delay_default,
30
+ :distance_default, :spacing_default
31
+
32
+ def initialize
33
+ @name = ""
34
+ @abbr = ""
35
+ @description = ""
36
+ @signature_file = ""
37
+ @repetitive = false
38
+ @minimum_colors = 0
39
+ @unlimited_colors = false
40
+ @center = ParamUsage::NOTUSED
41
+ @delay = ParamUsage::NOTUSED
42
+ @direction = ParamUsage::NOTUSED
43
+ @distance = ParamUsage::NOTUSED
44
+ @spacing = ParamUsage::NOTUSED
45
+ @delay_default = 50
46
+ @distance_default = -1
47
+ @spacing_default = 3
48
+ end
49
+
50
+ def self.new_from_json(json_data)
51
+ info = AnimationInfo.new
52
+ info.name = json_data["name"] unless json_data["name"].nil?
53
+ info.abbr = json_data["abbr"] unless json_data["abbr"].nil?
54
+ info.description = json_data["description"] unless json_data["description"].nil?
55
+ info.signature_file = json_data["signatureFile"] unless json_data["signatureFile"].nil?
56
+ info.repetitive = json_data["repetitive"] unless json_data["repetitive"].nil?
57
+ info.minimum_colors = json_data["minimumColors"] unless json_data["minimumColors"].nil?
58
+ info.unlimited_colors = json_data["unlimitedColors"] unless json_data["unlimitedColors"].nil?
59
+ info.center = ParamUsage::from_string(json_data["center"]) unless json_data["center"].nil?
60
+ info.delay = ParamUsage::from_string(json_data["delay"]) unless json_data["delay"].nil?
61
+ info.direction = ParamUsage::from_string(json_data["direction"]) unless json_data["direction"].nil?
62
+ info.distance = ParamUsage::from_string(json_data["distance"]) unless json_data["distance"].nil?
63
+ info.spacing = ParamUsage::from_string(json_data["spacing"]) unless json_data["spacing"].nil?
64
+ info.delay_default = json_data["delayDefault"] unless json_data["delayDefault"].nil?
65
+ info.distance_default = json_data["distanceDefault"] unless json_data["distanceDefault"].nil?
66
+ info.spacing_default = json_data["spacingDefault"] unless json_data["spacingDefault"].nil?
67
+
68
+ info
69
+ end
70
+
71
+ end
@@ -0,0 +1,104 @@
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 "json"
22
+ require "socket"
23
+ require_relative "animation_data"
24
+ require_relative "animation_info"
25
+ require_relative "end_animation"
26
+ require_relative "section"
27
+ require_relative "strip_info"
28
+
29
+ class AnimationSender
30
+ attr_accessor :address, :port, :strip_info,
31
+ :running_animations, :supported_animations,
32
+ :sections
33
+
34
+ def initialize(address, port)
35
+ @address = address
36
+ @port = port
37
+ @running_animations = {}
38
+ @supported_animations = {}
39
+ @sections = {}
40
+ end
41
+
42
+ def start
43
+ @socket = TCPSocket.new @address, @port
44
+ @receive_thread = Thread.new {
45
+ begin
46
+ while (line = @socket.gets ";;;")
47
+ puts line
48
+ if line.start_with? "DATA:"
49
+ json = JSON.parse (line.delete_prefix "DATA:").delete_suffix(";;;")
50
+ data = AnimationData::new_from_json json
51
+ @running_animations[data.id] = data
52
+ elsif line.start_with? "AINF:"
53
+ json = JSON.parse (line.delete_prefix "AINF:").delete_suffix(";;;")
54
+ info = AnimationInfo.new_from_json json
55
+ @supported_animations[info.name] = info
56
+ elsif line.start_with? "END :"
57
+ json = JSON.parse (line.delete_prefix "END :").delete_suffix(";;;")
58
+ anim = EndAnimation.new_from_json json
59
+ @running_animations.delete anim.id
60
+ elsif line.start_with? "SECT:"
61
+ json = JSON.parse (line.delete_prefix "SECT:").delete_suffix(";;;")
62
+ sect = Section.new_from_json json
63
+ @sections[sect.name] = sect
64
+ elsif line.start_with? "SINF:"
65
+ json = JSON.parse (line.delete_prefix "SINF:").delete_suffix(";;;")
66
+ info = StripInfo.new_from_json json
67
+ @strip_info = info
68
+ end
69
+ end
70
+ rescue IOError
71
+ # ignored
72
+ end
73
+ }
74
+ end
75
+
76
+ #noinspection RubyUnusedLocalVariable
77
+ def end
78
+ @socket.close
79
+ @receive_thread.join
80
+ strip_info = nil
81
+ running_animations = {}
82
+ supported_animations = {}
83
+ sections = {}
84
+ end
85
+
86
+ def send_animation(animation)
87
+ raise TypeError unless animation.is_a? AnimationData
88
+
89
+ @socket.write(animation.json + ";;;")
90
+ end
91
+
92
+ def send_end_animation(end_animation)
93
+ raise TypeError unless end_animation.is_a? EndAnimation
94
+
95
+ @socket.write(end_animation.json + ";;;")
96
+ end
97
+
98
+ def send_section(section)
99
+ raise TypeError unless section.is_a? Section
100
+
101
+ @socket.write(section.json + ";;;")
102
+ end
103
+
104
+ end
@@ -42,4 +42,11 @@ class ColorContainer
42
42
  @colors.push(color)
43
43
  end
44
44
 
45
+ def self.new_from_json(json_str)
46
+ cc = ColorContainer.new
47
+ json_str["colors"].each { |c| cc.add_color c }
48
+
49
+ cc
50
+ end
51
+
45
52
  end
@@ -25,11 +25,24 @@ module Direction
25
25
  def self.string(direction)
26
26
  case direction
27
27
  when FORWARD
28
- 'FORWARD'
28
+ "FORWARD"
29
29
  when BACKWARD
30
- 'BACKWARD'
30
+ "BACKWARD"
31
31
  else
32
- 'FORWARD'
32
+ "FORWARD"
33
33
  end
34
34
  end
35
- end
35
+
36
+ def self.from_string(direction_str)
37
+ raise TypeError unless direction_str.is_a? String
38
+
39
+ case direction_str.upcase
40
+ when "FORWARD"
41
+ FORWARD
42
+ when "BACKWARD"
43
+ BACKWARD
44
+ else
45
+ FORWARD
46
+ end
47
+ end
48
+ end
@@ -18,15 +18,23 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'helper'
22
- require 'minitest'
23
- require_relative '../lib/animation_sender'
21
+ class EndAnimation
22
+ attr_accessor :id
24
23
 
25
- class AnimationSenderTest < Minitest::Test
26
- def test_initialization
27
- sender = AnimationSender.new '10.0.0.254', 5
24
+ def initialize
25
+ @id = ""
26
+ end
27
+
28
+ def json
29
+ raise TypeError unless @id.is_a? String
30
+
31
+ "END :{\"id\":\"#{@id}\"}"
32
+ end
33
+
34
+ def self.new_from_json(json_data)
35
+ anim = EndAnimation.new
36
+ anim.id = json_data["id"] unless json_data["id"].nil?
28
37
 
29
- assert_equal '10.0.0.254', sender.address
30
- assert_equal 5, sender.port
38
+ anim
31
39
  end
32
- end
40
+ end
@@ -18,29 +18,31 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
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
21
+ module ParamUsage
22
+ USED = 0
23
+ NOTUSED = 1
24
+
25
+ def self.string(param_usage)
26
+ case param_usage
27
+ when USED
28
+ "USED"
29
+ when NOTUSED
30
+ "NOTUSED"
31
+ else
32
+ "NOTUSED"
33
+ end
34
34
  end
35
35
 
36
- def end
37
- @socket.close
36
+ def self.from_string(param_usage_str)
37
+ raise TypeError unless param_usage_str.is_a? String
38
+
39
+ case param_usage_str.upcase
40
+ when "USED"
41
+ USED
42
+ when "NOTUSED"
43
+ NOTUSED
44
+ else
45
+ NOTUSED
46
+ end
38
47
  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
48
  end
@@ -0,0 +1,52 @@
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 Section
22
+ attr_accessor :name, :num_leds, :start_pixel,
23
+ :end_pixel, :physical_start
24
+
25
+ def initialize
26
+ @name = ""
27
+ @num_leds = 0
28
+ @start_pixel = -1
29
+ @end_pixel = -1
30
+ @physical_start = -1
31
+ end
32
+
33
+ def json
34
+ raise TypeError unless @name.is_a? String
35
+ raise TypeError unless @start_pixel.is_a? Integer
36
+ raise TypeError unless @end_pixel.is_a? Integer
37
+
38
+ "SECT:{\"name\":\"#{@name}\","\
39
+ "\"startPixel\":#{@start_pixel},\"endPixel\":#{@end_pixel}}"
40
+ end
41
+
42
+ def self.new_from_json(json_data)
43
+ sect = Section.new
44
+ sect.name = json_data["name"] unless json_data["name"].nil?
45
+ sect.num_leds = json_data["numLEDs"] unless json_data["numLEDs"].nil?
46
+ sect.start_pixel = json_data["startPixel"] unless json_data["startPixel"].nil?
47
+ sect.end_pixel = json_data["endPixel"] unless json_data["endPixel"].nil?
48
+ sect.physical_start = json_data["physicalStart"] unless json_data["physicalStart"].nil?
49
+
50
+ sect
51
+ end
52
+ end
@@ -18,14 +18,29 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'helper'
22
- require 'minitest'
23
- require_relative '../lib/direction'
21
+ class StripInfo
22
+ attr_accessor :num_leds, :pin, :image_debugging,
23
+ :file_name, :renders_before_save,
24
+ :thread_count
24
25
 
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)
26
+ def initialize
27
+ @num_leds = 0
28
+ @pin = -1
29
+ @image_debugging = false
30
+ @file_name = ""
31
+ @renders_before_save = -1
32
+ @thread_count = 100
33
+ end
34
+
35
+ def self.new_from_json(json_data)
36
+ info = StripInfo.new
37
+ info.num_leds = json_data["numLEDs"] unless json_data["numLEDs"].nil?
38
+ info.pin = json_data["pin"] unless json_data["pin"].nil?
39
+ info.image_debugging = json_data["imageDebugging"] unless json_data["imageDebugging"].nil?
40
+ info.file_name = json_data["fileName"] unless json_data["fileName"].nil?
41
+ info.renders_before_save = json_data["rendersBeforeSave"] unless json_data["rendersBeforeSave"].nil?
42
+ info.thread_count = json_data["threadCount"] unless json_data["threadCount"].nil?
43
+
44
+ info
30
45
  end
31
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: animatedledstrip-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Narvaez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2020-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: mocha
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: mocha
70
+ name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -94,23 +94,46 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description:
98
- email:
112
+ email:
113
+ - mnmax.narvaez3@gmail.com
99
114
  executables: []
100
115
  extensions: []
101
116
  extra_rdoc_files: []
102
117
  files:
103
- - lib/animation.rb
104
- - lib/animation_data.rb
105
- - lib/animation_sender.rb
106
- - lib/color_container.rb
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
112
- homepage:
113
- licenses: []
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - animatedledstrip-client.gemspec
125
+ - lib/animatedledstrip/animation_data.rb
126
+ - lib/animatedledstrip/animation_info.rb
127
+ - lib/animatedledstrip/animation_sender.rb
128
+ - lib/animatedledstrip/color_container.rb
129
+ - lib/animatedledstrip/direction.rb
130
+ - lib/animatedledstrip/end_animation.rb
131
+ - lib/animatedledstrip/param_usage.rb
132
+ - lib/animatedledstrip/section.rb
133
+ - lib/animatedledstrip/strip_info.rb
134
+ homepage: https://github.com/AnimatedLEDStrip/client-ruby
135
+ licenses:
136
+ - MIT
114
137
  metadata: {}
115
138
  post_install_message:
116
139
  rdoc_options: []
@@ -127,13 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
150
  - !ruby/object:Gem::Version
128
151
  version: '0'
129
152
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.7.7
153
+ rubygems_version: 3.0.8
132
154
  signing_key:
133
155
  specification_version: 4
134
156
  summary: Library for connecting to an AnimatedLEDStripServer
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
157
+ test_files: []
@@ -1,109 +0,0 @@
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,121 +0,0 @@
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
@@ -1,200 +0,0 @@
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