smalruby 0.1.8-x86-mingw32 → 0.1.9-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4047befb22246c65270b46b52028d25e7aaed2d2
4
- data.tar.gz: 6cc88b0af3c9f9d1e1e14d32ab21ebe6328cf0f1
3
+ metadata.gz: 7d8a9c5466d5791117a27f0ee81f345874327aae
4
+ data.tar.gz: 51d80e43ded60d8a33a85f3d07daf85a4f0cc85e
5
5
  SHA512:
6
- metadata.gz: 3d74cb270bfba0bfe311fa1e8f5ade76f685f4eb34fa8f3b75341cbb9a2ca9f8e2b1728be1650910ccd8443033ffd27353f9f07ecd94a529d312f7f5ee04847c
7
- data.tar.gz: b07782c40db851d7c5fc900a34a2e65c43a08253dd112ff23f28e8af1e82e2e89f0e29357d928c531f91a8d6f469b9b39209074a9d78a3a2fc97b157a8410df8
6
+ metadata.gz: 7d1c6bf30b3ba7d3da9867fca1afddc10f60357910fc80feca177df1446ec6aaaf512bc3cb55bac9463533549928ce7e6af9e51d77d51be65a249d112a2dc200
7
+ data.tar.gz: 7ebe348c294e7d117b58933438fb0d2872d274ad29dc1e1bbdad560a4d9bd326ba3597ecd15ba72c5d55cb95f2665fbc6b2c49ace540db875a8c725cfe38039d
data/.rubocop.yml CHANGED
@@ -1,42 +1,147 @@
1
1
  AllCops:
2
- Exclude:
3
- - tmp/**
2
+ Excludes:
3
+ - tmp/**/*
4
+ - vendor/**/*
5
+ - work/**/*
6
+ - samples/**/*
4
7
 
5
- MethodLength:
8
+ # Offense count: 1
9
+ # Configuration parameters: AllowSafeAssignment.
10
+ Lint/AssignmentInCondition:
6
11
  Enabled: false
7
12
 
8
- ClassLength:
13
+ # Offense count: 2
14
+ Lint/HandleExceptions:
9
15
  Enabled: false
10
16
 
11
- Documentation:
17
+ # Offense count: 1
18
+ Lint/RescueException:
12
19
  Enabled: false
13
20
 
14
- HandleExceptions:
21
+ # Offense count: 2
22
+ # Cop supports --auto-correct.
23
+ Lint/UnusedMethodArgument:
15
24
  Enabled: false
16
25
 
17
- Blocks:
26
+ # Offense count: 17
27
+ Metrics/AbcSize:
28
+ Max: 58
29
+
30
+ # Offense count: 3
31
+ # Configuration parameters: CountComments.
32
+ Metrics/ClassLength:
33
+ Max: 433
34
+
35
+ # Offense count: 3
36
+ Metrics/CyclomaticComplexity:
37
+ Max: 8
38
+
39
+ # Offense count: 4
40
+ # Configuration parameters: AllowURI, URISchemes.
41
+ Metrics/LineLength:
42
+ Max: 162
43
+
44
+ # Offense count: 22
45
+ # Configuration parameters: CountComments.
46
+ Metrics/MethodLength:
47
+ Max: 37
48
+
49
+ # Offense count: 2
50
+ # Configuration parameters: CountComments.
51
+ Metrics/ModuleLength:
52
+ Max: 170
53
+
54
+ # Offense count: 1
55
+ Metrics/PerceivedComplexity:
56
+ Max: 8
57
+
58
+ # Offense count: 1
59
+ # Cop supports --auto-correct.
60
+ Performance/ParallelAssignment:
61
+ Enabled: false
62
+
63
+ # Offense count: 1
64
+ Style/AccessorMethodName:
65
+ Enabled: false
66
+
67
+ # Offense count: 160
68
+ Style/AsciiComments:
69
+ Enabled: false
70
+
71
+ # Offense count: 4
72
+ # Cop supports --auto-correct.
73
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
74
+ Style/BlockDelimiters:
75
+ Enabled: false
76
+
77
+ # Offense count: 4
78
+ Style/Documentation:
79
+ Enabled: false
80
+
81
+ # Offense count: 8
82
+ # Configuration parameters: MinBodyLength.
83
+ Style/GuardClause:
84
+ Enabled: false
85
+
86
+ # Offense count: 1
87
+ # Cop supports --auto-correct.
88
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
89
+ Style/HashSyntax:
90
+ Enabled: false
91
+
92
+ # Offense count: 11
93
+ # Cop supports --auto-correct.
94
+ # Configuration parameters: MaxLineLength.
95
+ Style/IfUnlessModifier:
96
+ Enabled: false
97
+
98
+ # Offense count: 1
99
+ # Cop supports --auto-correct.
100
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
101
+ Style/MultilineOperationIndentation:
18
102
  Enabled: false
19
103
 
20
- FavorUnlessOverNegatedIf:
104
+ # Offense count: 2
105
+ # Cop supports --auto-correct.
106
+ # Configuration parameters: PreferredDelimiters.
107
+ Style/PercentLiteralDelimiters:
21
108
  Enabled: false
22
109
 
23
- IfUnlessModifier:
110
+ # Offense count: 1
111
+ # Cop supports --auto-correct.
112
+ Style/PerlBackrefs:
24
113
  Enabled: false
25
114
 
26
- RedundantReturn:
115
+ # Offense count: 4
116
+ # Cop supports --auto-correct.
117
+ # Configuration parameters: AllowMultipleReturnValues.
118
+ Style/RedundantReturn:
27
119
  Enabled: false
28
120
 
29
- AsciiComments:
121
+ # Offense count: 2
122
+ # Cop supports --auto-correct.
123
+ Style/SpecialGlobalVars:
30
124
  Enabled: false
31
125
 
32
- CaseEquality:
126
+ # Offense count: 12
127
+ # Cop supports --auto-correct.
128
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
129
+ Style/StringLiterals:
33
130
  Enabled: false
34
131
 
35
- StringLiterals:
132
+ # Offense count: 3
133
+ # Cop supports --auto-correct.
134
+ # Configuration parameters: IgnoredMethods.
135
+ Style/SymbolProc:
36
136
  Enabled: false
37
137
 
38
- EndOfLine:
138
+ # Offense count: 6
139
+ # Cop supports --auto-correct.
140
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
141
+ Style/TrailingComma:
39
142
  Enabled: false
40
143
 
41
- TrailingComma:
144
+ # Offense count: 2
145
+ # Cop supports --auto-correct.
146
+ Style/UnneededPercentQ:
42
147
  Enabled: false
data/Rakefile CHANGED
@@ -83,4 +83,4 @@ task :release do
83
83
  sh 'git push'
84
84
  end
85
85
 
86
- task :default => [:spec]
86
+ task :default => [:rubocop, :spec]
@@ -381,6 +381,11 @@ module Smalruby
381
381
  Hardware.create_hardware(Hardware::RgbLedCathode, pin)
382
382
  end
383
383
 
384
+ # マイコン内蔵RGB LED
385
+ def neo_pixel(pin)
386
+ Hardware.create_hardware(Hardware::NeoPixel, pin)
387
+ end
388
+
384
389
  # サーボモーター
385
390
  def servo(pin)
386
391
  Hardware.create_hardware(Hardware::Servo, pin)
@@ -13,6 +13,7 @@ module Smalruby
13
13
  autoload :Led
14
14
  autoload :RgbLedAnode
15
15
  autoload :RgbLedCathode
16
+ autoload :NeoPixel
16
17
  autoload :Servo
17
18
  autoload :TwoWheelDriveCar
18
19
  autoload :MotorDriver
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'smalruby/hardware'
3
+ require "set"
4
+
5
+ module Smalruby
6
+ module Hardware
7
+ # Adafruit NeoPixel RGB LED class
8
+ class NeoPixel < Smalrubot::Components::BaseComponent
9
+ include Util
10
+
11
+ def initialize(options)
12
+ pin = Pin.smalruby_to_smalrubot(options[:pin])
13
+ case pin
14
+ when 3, 5, 6, 9, 10, 11
15
+ super(board: world.board, pin: pin)
16
+ else
17
+ fail "ピン番号が間違っています: {options[:pin]}"
18
+ end
19
+ @indexes = Set.new
20
+ end
21
+
22
+ # set color
23
+ def set(options)
24
+ defaults = {
25
+ index: 0,
26
+ color: "black",
27
+ show: true,
28
+ }
29
+ opts = process_options(options, defaults)
30
+ @indexes << opts[:index]
31
+ color = Color.smalruby_to_dxruby(opts[:color])
32
+ board.set_neo_pixel_color(opts[:index], *color)
33
+ if opts[:show]
34
+ show
35
+ end
36
+ end
37
+
38
+ # apply color settings
39
+ def show
40
+ board.show_neo_pixel
41
+ end
42
+
43
+ # turn off
44
+ def turn_off
45
+ if @indexes.length > 0
46
+ @indexes.each do |i|
47
+ board.set_neo_pixel_color(i, 0, 0, 0)
48
+ end
49
+ board.show_neo_pixel
50
+ end
51
+ end
52
+
53
+ # destruction
54
+ def stop
55
+ if @indexes.length > 0
56
+ turn_off
57
+ @indexes.clear
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def after_initialize(_ = {})
64
+ board.set_neo_pixel_pin(pin)
65
+ board.show_neo_pixel
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Smalruby
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
5
5
  end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ DESCRIPTION = <<EOS
4
+ マイコン内蔵RGB LEDを制御します
5
+ EOS
6
+
7
+ # デジタルの5番ピンに接続してください。
8
+
9
+ require 'smalruby'
10
+
11
+ init_hardware
12
+
13
+ stage1 = Stage.new(color: 'white')
14
+
15
+ stage1.on(:start) do
16
+ loop do
17
+ Color::NAME_TO_CODE.keys.each do |color|
18
+ draw_font(string: "#{DESCRIPTION}#{color}", color: 'black')
19
+ neo_pixel('D5').set(color: color)
20
+ sleep(1)
21
+ fill(color: 'white')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ DESCRIPTION = <<EOS
4
+ マイコン内蔵RGB LEDを制御します
5
+ EOS
6
+
7
+ # マイコン内蔵RGB LEDデジタルの5番ピンに、
8
+ # スイッチをデジタルの3・4番ピンに接続してください。
9
+
10
+ require 'smalruby'
11
+
12
+ init_hardware
13
+
14
+ stage1 = Stage.new(color: 'white')
15
+
16
+ stage1.on(:start) do
17
+ color_codes = Color::NAME_TO_CODE.keys
18
+ index = 0
19
+ loop do
20
+ fill(color: 'white')
21
+ color = color_codes[index]
22
+ draw_font(string: "#{DESCRIPTION}#{index}:#{color}", color: 'black')
23
+ neo_pixel("D5").set(color: color)
24
+ until button("D3").pressed? || button("D4").pressed?
25
+ await
26
+ end
27
+ if button("D3").pressed?
28
+ index -= 1
29
+ if index < 0
30
+ index = 0
31
+ end
32
+ end
33
+ if button("D4").pressed?
34
+ index += 1
35
+ if index >= color_codes.length
36
+ index = color_codes.length - 1
37
+ end
38
+ end
39
+ end
40
+ end
data/smalruby.gemspec CHANGED
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
42
42
  else
43
43
  spec.add_runtime_dependency 'dxruby_sdl', '~> 0.0.13'
44
44
  end
45
- spec.add_runtime_dependency 'smalrubot', '~> 0.0.5'
45
+ spec.add_runtime_dependency 'smalrubot', '~> 0.0.6'
46
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.0.5
201
+ version: 0.0.6
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.0.5
208
+ version: 0.0.6
209
209
  description: smalruby is a 2D game development library. This is part of "Smalruby"
210
210
  project that is a learning ruby programming environment for kids.
211
211
  email:
@@ -259,6 +259,7 @@ files:
259
259
  - lib/smalruby/hardware/button.rb
260
260
  - lib/smalruby/hardware/led.rb
261
261
  - lib/smalruby/hardware/motor_driver.rb
262
+ - lib/smalruby/hardware/neo_pixel.rb
262
263
  - lib/smalruby/hardware/null_hardware.rb
263
264
  - lib/smalruby/hardware/pin.rb
264
265
  - lib/smalruby/hardware/rgb_led_anode.rb
@@ -289,6 +290,8 @@ files:
289
290
  - samples/hardware_button.rb
290
291
  - samples/hardware_led.rb
291
292
  - samples/hardware_motor_driver.rb
293
+ - samples/hardware_neo_pixel.rb
294
+ - samples/hardware_neo_pixel2.rb
292
295
  - samples/hardware_rgb_led_anode.rb
293
296
  - samples/hardware_rgb_led_cathode.rb
294
297
  - samples/hardware_sensor.rb