arduino_ci 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'os'
2
2
  require 'open3'
3
+ require 'pathname'
3
4
 
4
5
  module ArduinoCI
5
6
 
@@ -38,15 +39,20 @@ module ArduinoCI
38
39
  end
39
40
 
40
41
  # if on windows, call mklink, else self.symlink
41
- # https://stackoverflow.com/a/22716582/2063546
42
+ # @param [Pathname] old_path
43
+ # @param [Pathname] new_path
42
44
  def self.symlink(old_path, new_path)
43
- return FileUtils.ln_s(old_path, new_path) unless RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
45
+ return FileUtils.ln_s(old_path.to_s, new_path.to_s) unless RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
44
46
 
47
+ # https://stackoverflow.com/a/22716582/2063546
45
48
  # windows mklink syntax is reverse of unix ln -s
46
49
  # windows mklink is built into cmd.exe
47
50
  # vulnerable to command injection, but okay because this is a hack to make a cli tool work.
48
- _stdin, _stdout, _stderr, wait_thr = Open3.popen3('cmd.exe', "/c mklink #{new_path} #{old_path}")
49
- wait_thr.value.exitstatus
51
+ orp = old_path.realpath.to_s.tr("/", "\\") # HACK DUE TO REALPATH BUG where it
52
+ np = new_path.to_s.tr("/", "\\") # still joins windows paths with '/'
53
+
54
+ _stdout, _stderr, exitstatus = Open3.capture3('cmd.exe', "/C mklink /D #{np} #{orp}")
55
+ exitstatus.success?
50
56
  end
51
57
  end
52
58
  end
@@ -1,3 +1,3 @@
1
1
  module ArduinoCI
2
- VERSION = "0.1.10".freeze
2
+ VERSION = "0.1.11".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Katz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-06 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.1
33
+ version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.1
40
+ version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.49.0
75
+ version: 0.59.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.49.0
82
+ version: 0.59.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,8 @@ email:
99
99
  - ianfixes@gmail.com
100
100
  executables:
101
101
  - arduino_ci_remote.rb
102
+ - arduino_ci_remote.rb.orig
103
+ - ensure_arduino_installation.rb
102
104
  extensions: []
103
105
  extra_rdoc_files: []
104
106
  files:
@@ -113,6 +115,7 @@ files:
113
115
  - cpp/arduino/HardwareSerial.h
114
116
  - cpp/arduino/PinHistory.h
115
117
  - cpp/arduino/Print.h
118
+ - cpp/arduino/SPI.h
116
119
  - cpp/arduino/SoftwareSerial.h
117
120
  - cpp/arduino/Stream.h
118
121
  - cpp/arduino/WCharacter.h
@@ -403,6 +406,8 @@ files:
403
406
  - cpp/unittest/Assertion.h
404
407
  - cpp/unittest/Compare.h
405
408
  - exe/arduino_ci_remote.rb
409
+ - exe/arduino_ci_remote.rb.orig
410
+ - exe/ensure_arduino_installation.rb
406
411
  - lib/arduino_ci.rb
407
412
  - lib/arduino_ci/arduino_cmd.rb
408
413
  - lib/arduino_ci/arduino_cmd_linux.rb
@@ -410,17 +415,12 @@ files:
410
415
  - lib/arduino_ci/arduino_cmd_osx.rb
411
416
  - lib/arduino_ci/arduino_cmd_windows.rb
412
417
  - lib/arduino_ci/arduino_downloader.rb
413
- - lib/arduino_ci/arduino_downloader.rb.orig
414
418
  - lib/arduino_ci/arduino_downloader_linux.rb
415
- - lib/arduino_ci/arduino_downloader_linux.rb.orig
416
419
  - lib/arduino_ci/arduino_downloader_osx.rb
417
- - lib/arduino_ci/arduino_downloader_osx.rb.orig
418
420
  - lib/arduino_ci/arduino_downloader_windows.rb
419
421
  - lib/arduino_ci/arduino_installation.rb
420
- - lib/arduino_ci/arduino_installation.rb.orig
421
422
  - lib/arduino_ci/ci_config.rb
422
423
  - lib/arduino_ci/cpp_library.rb
423
- - lib/arduino_ci/display_manager.rb
424
424
  - lib/arduino_ci/host.rb
425
425
  - lib/arduino_ci/version.rb
426
426
  - misc/default.yml
@@ -1,219 +0,0 @@
1
- DOWNLOAD_ATTEMPTS = 3
2
-
3
- module ArduinoCI
4
-
5
- # Manage the OS-specific download & install of Arduino
6
- class ArduinoDownloader
7
-
8
- def initialize(desired_ide_version)
9
- @desired_ide_version = desired_ide_version
10
- end
11
-
12
- # Provide guidelines to the implementer of this class
13
- <<<<<<< HEAD
14
- def must_implement(method)
15
- raise NoMethodError("#{self.class.name} failed to implement ArduinoDownloader.#{method}")
16
- =======
17
- def self.must_implement(method)
18
- raise NotImplementedError, "#{self.class.name} failed to implement ArduinoDownloader.#{method}"
19
- >>>>>>> Refactor force_install code in preparation for windows CI
20
- end
21
-
22
- # Make any preparations or run any checks prior to making changes
23
- # @return [string] Error message, or nil if success
24
- def prepare
25
- nil
26
- end
27
-
28
- # The autolocated executable of the installation
29
- #
30
- # @return [string] or nil
31
- <<<<<<< HEAD
32
- def self.autolocation
33
- =======
34
- def self.autolocated_executable
35
- >>>>>>> Refactor force_install code in preparation for windows CI
36
- # Arbitrarily, I'm going to pick the force installed location first
37
- # if it exists. I'm not sure why we would have both, but if we did
38
- # a force install then let's make sure we actually use it.
39
- locations = [self.force_installed_executable, self.existing_executable]
40
- locations.each do |loc|
41
- next if loc.nil?
42
- next unless File.exist? loc
43
- return loc
44
- end
45
- nil
46
- end
47
-
48
- <<<<<<< HEAD
49
- # The executable Arduino file in an existing installation, or nil
50
- # @return [string]
51
- def self.existing_executable
52
- must_implement(__method__)
53
- =======
54
- # The autolocated directory of the installation
55
- #
56
- # @return [string] or nil
57
- def self.autolocated_installation
58
- # Arbitrarily, I'm going to pick the force installed location first
59
- # if it exists. I'm not sure why we would have both, but if we did
60
- # a force install then let's make sure we actually use it.
61
- locations = [self.force_install_location, self.existing_installation]
62
- locations.each do |loc|
63
- next if loc.nil?
64
- next unless File.exist? loc
65
- return loc
66
- end
67
- nil
68
- end
69
-
70
- # The path to the directory of an existing installation, or nil
71
- # @return [string]
72
- def self.existing_installation
73
- self.must_implement(__method__)
74
- end
75
-
76
- # The executable Arduino file in an existing installation, or nil
77
- # @return [string]
78
- def self.existing_executable
79
- self.must_implement(__method__)
80
- >>>>>>> Refactor force_install code in preparation for windows CI
81
- end
82
-
83
- # The executable Arduino file in a forced installation, or nil
84
- # @return [string]
85
- def self.force_installed_executable
86
- <<<<<<< HEAD
87
- must_implement(__method__)
88
- =======
89
- self.must_implement(__method__)
90
- >>>>>>> Refactor force_install code in preparation for windows CI
91
- end
92
-
93
- # The technology that will be used to complete the download
94
- # (for logging purposes)
95
- # @return [string]
96
- def downloader
97
- <<<<<<< HEAD
98
- must_implement(__method__)
99
- =======
100
- self.class.must_implement(__method__)
101
- >>>>>>> Refactor force_install code in preparation for windows CI
102
- end
103
-
104
- # The technology that will be used to extract the download
105
- # (for logging purposes)
106
- # @return [string]
107
- def extracter
108
- <<<<<<< HEAD
109
- must_implement(__method__)
110
- =======
111
- self.class.must_implement(__method__)
112
- >>>>>>> Refactor force_install code in preparation for windows CI
113
- end
114
-
115
- # The URL of the desired IDE package (zip/tar/etc) for this platform
116
- # @return [string]
117
- def package_url
118
- "https://downloads.arduino.cc/#{package_file}"
119
- end
120
-
121
- # The local file (dir) name of the desired IDE package (zip/tar/etc)
122
- # @return [string]
123
- def package_file
124
- <<<<<<< HEAD
125
- must_implement(__method__)
126
- =======
127
- self.class.must_implement(__method__)
128
- >>>>>>> Refactor force_install code in preparation for windows CI
129
- end
130
-
131
- # The local filename of the extracted IDE package (zip/tar/etc)
132
- # @return [string]
133
- def extracted_file
134
- <<<<<<< HEAD
135
- must_implement(__method__)
136
- =======
137
- self.class.must_implement(__method__)
138
- >>>>>>> Refactor force_install code in preparation for windows CI
139
- end
140
-
141
- # @return [String] The location where a forced install will go
142
- def self.force_install_location
143
- File.join(ENV['HOME'], 'arduino_ci_ide')
144
- end
145
-
146
- # Download the package_url to package_file, and maybe print a line of dots......
147
- # @return [bool] whether successful
148
- def download
149
- <<<<<<< HEAD
150
- must_implement(__method__)
151
- =======
152
- self.class.must_implement(__method__)
153
- >>>>>>> Refactor force_install code in preparation for windows CI
154
- end
155
-
156
- # Extract the package_file to extracted_file
157
- # @return [bool] whether successful
158
- def extract
159
- <<<<<<< HEAD
160
- must_implement(__method__)
161
- =======
162
- self.class.must_implement(__method__)
163
- >>>>>>> Refactor force_install code in preparation for windows CI
164
- end
165
-
166
- # Move the extracted package file from extracted_file to the force_install_location
167
- # @return [bool] whether successful
168
- def install
169
- <<<<<<< HEAD
170
- must_implement(__method__)
171
- =======
172
- self.class.must_implement(__method__)
173
- >>>>>>> Refactor force_install code in preparation for windows CI
174
- end
175
-
176
- # Forcibly install Arduino on linux from the web
177
- # @return [bool] Whether the command succeeded
178
- def execute
179
- error_preparing = prepare
180
- unless error_preparing.nil?
181
- puts "Arduino force-install failed preparation: #{error_preparing}"
182
- return false
183
- end
184
-
185
- attempts = 0
186
-
187
- loop do
188
- if File.exist? package_file
189
- puts "Arduino package seems to have been downloaded already" if attempts.zero?
190
- break
191
- elsif attempts >= DOWNLOAD_ATTEMPTS
192
- break puts "After #{DOWNLOAD_ATTEMPTS} attempts, failed to download #{package_url}"
193
- else
194
- puts "Attempting to download Arduino package with #{downloader}"
195
- download
196
- end
197
- attempts += 1
198
- end
199
-
200
- if File.exist? extracted_file
201
- puts "Arduino package seems to have been extracted already"
202
- elsif File.exist? package_file
203
- puts "Extracting archive with #{extracter}"
204
- extract
205
- end
206
-
207
- if File.exist? self.class.force_install_location
208
- puts "Arduino package seems to have been installed already"
209
- elsif File.exist? extracted_file
210
- install
211
- else
212
- puts "Arduino force-install failed"
213
- end
214
-
215
- File.exist? self.class.force_install_location
216
- end
217
-
218
- end
219
- end
@@ -1,79 +0,0 @@
1
- require "arduino_ci/arduino_downloader_posix"
2
-
3
- USE_BUILDER = false
4
-
5
- module ArduinoCI
6
-
7
- # Manage the linux download & install of Arduino
8
- class ArduinoDownloaderLinux < ArduinoDownloaderPosix
9
-
10
- # The local filename of the desired IDE package (zip/tar/etc)
11
- # @return [string]
12
- def package_file
13
- "#{extracted_file}-linux64.tar.xz"
14
- end
15
-
16
- # The technology that will be used to extract the download
17
- # (for logging purposes)
18
- # @return [string]
19
- def extracter
20
- "tar"
21
- end
22
-
23
- # Extract the package_file to extracted_file
24
- # @return [bool] whether successful
25
- def extract
26
- system(extracter, "xf", package_file)
27
- end
28
-
29
- # The local file (dir) name of the extracted IDE package (zip/tar/etc)
30
- # @return [string]
31
- def extracted_file
32
- "arduino-#{@desired_ide_version}"
33
- end
34
-
35
- <<<<<<< HEAD
36
- =======
37
- # The path to the directory of an existing installation, or nil
38
- # @return [string]
39
- def self.existing_installation
40
- exe = self.existing_executable
41
- return nil if exe.nil?
42
- File.dirname(exe) # it's not really this
43
- # but for this platform it doesn't really matter
44
- end
45
-
46
- >>>>>>> Refactor force_install code in preparation for windows CI
47
- # The executable Arduino file in an existing installation, or nil
48
- # @return [string]
49
- def self.existing_executable
50
- if USE_BUILDER
51
- # builder_name = "arduino-builder"
52
- # cli_place = Host.which(builder_name)
53
- # unless cli_place.nil?
54
- # ret = ArduinoCmdLinuxBuilder.new
55
- # ret.base_cmd = [cli_place]
56
- # return ret
57
- # end
58
- end
59
- Host.which("arduino")
60
- end
61
-
62
- # The executable Arduino file in a forced installation, or nil
63
- # @return [string]
64
- def self.force_installed_executable
65
- if USE_BUILDER
66
- # forced_builder = File.join(ArduinoCmdLinuxBuilder.force_install_location, builder_name)
67
- # if File.exist?(forced_builder)
68
- # ret = ArduinoCmdLinuxBuilder.new
69
- # ret.base_cmd = [forced_builder]
70
- # return ret
71
- # end
72
- end
73
- forced_arduino = File.join(self.force_install_location, "arduino")
74
- return forced_arduino if File.exist? forced_arduino
75
- nil
76
- end
77
-
78
- end
79
- end
@@ -1,88 +0,0 @@
1
- require "arduino_ci/arduino_downloader_posix"
2
-
3
- module ArduinoCI
4
-
5
- # Manage the OSX download & install of Arduino
6
- class ArduinoDownloaderOSX < ArduinoDownloaderPosix
7
-
8
- # The local filename of the desired IDE package (zip/tar/etc)
9
- # @return [string]
10
- def package_file
11
- <<<<<<< HEAD
12
- "#arduino-#{@desired_ide_version}-macosx.zip"
13
- =======
14
- "arduino-#{@desired_ide_version}-macosx.zip"
15
- >>>>>>> Refactor force_install code in preparation for windows CI
16
- end
17
-
18
- # The technology that will be used to extract the download
19
- # (for logging purposes)
20
- # @return [string]
21
- def extracter
22
- "unzip"
23
- end
24
-
25
- # Extract the package_file to extracted_file
26
- # @return [bool] whether successful
27
- def extract
28
- system(extracter, package_file)
29
- end
30
-
31
- # The local file (dir) name of the extracted IDE package (zip/tar/etc)
32
- # @return [string]
33
- def extracted_file
34
- "Arduino.app"
35
- end
36
-
37
- <<<<<<< HEAD
38
- # The an existing Arduino file in one of the given directories, or nil
39
- =======
40
- # An existing Arduino directory in one of the given directories, or nil
41
- # @param Array<string> a list of places to look
42
- # @return [string]
43
- def self.find_existing_arduino_dir(paths)
44
- paths.each do |path|
45
- return path if File.exist? path
46
- end
47
- nil
48
- end
49
-
50
- # An existing Arduino file in one of the given directories, or nil
51
- >>>>>>> Refactor force_install code in preparation for windows CI
52
- # @param Array<string> a list of places to look for the executable
53
- # @return [string]
54
- def self.find_existing_arduino_exe(paths)
55
- paths.each do |path|
56
- <<<<<<< HEAD
57
- exe = File.join(path, "Arduino")
58
- =======
59
- exe = File.join(path, "MacOS", "Arduino")
60
- >>>>>>> Refactor force_install code in preparation for windows CI
61
- return exe if File.exist? exe
62
- end
63
- nil
64
- end
65
-
66
- <<<<<<< HEAD
67
- =======
68
- # The path to the directory of an existing installation, or nil
69
- # @return [string]
70
- def self.existing_installation
71
- self.find_existing_arduino_dir(["/Applications/Arduino.app/Contents"])
72
- end
73
-
74
- >>>>>>> Refactor force_install code in preparation for windows CI
75
- # The executable Arduino file in an existing installation, or nil
76
- # @return [string]
77
- def self.existing_executable
78
- self.find_existing_arduino_exe(["/Applications/Arduino.app/Contents"])
79
- end
80
-
81
- # The executable Arduino file in a forced installation, or nil
82
- # @return [string]
83
- def self.force_installed_executable
84
- self.find_existing_arduino_exe([File.join(self.force_install_location, "Contents")])
85
- end
86
-
87
- end
88
- end