arduino_ci 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,7 +52,7 @@ module ArduinoCI
52
52
  # do some work to extract & merge environment variables if they exist
53
53
  has_env = !args.empty? && args[0].instance_of?(Hash)
54
54
  env_vars = has_env ? args[0] : {}
55
- actual_args = has_env ? args[1..] : args # need to shift over if we extracted args
55
+ actual_args = has_env ? args[1..-1] : args # need to shift over if we extracted args
56
56
  custom_config = @config_dir.nil? ? [] : ["--config-file", @config_dir.to_s]
57
57
  full_args = [binary_path.to_s, "--format", "json"] + custom_config + actual_args
58
58
  full_cmd = env_vars.empty? ? full_args : [env_vars] + full_args
@@ -113,10 +113,17 @@ module ArduinoCI
113
113
  # @param boardname [String] The board to test
114
114
  # @return [bool] Whether the board is installed
115
115
  def board_installed?(boardname)
116
- # capture_json("core", "list")[:json].find { |b| b["ID"] == boardname } # nope, this is for the family
117
116
  run_and_capture("board", "details", "--fqbn", boardname)[:success]
118
117
  end
119
118
 
119
+ # check whether a board family is installed (e.g. arduino:avr)
120
+ #
121
+ # @param boardfamily_name [String] The board family to test
122
+ # @return [bool] Whether the board is installed
123
+ def boards_installed?(boardfamily_name)
124
+ capture_json("core", "list")[:json].any? { |b| b["ID"] == boardfamily_name }
125
+ end
126
+
120
127
  # install a board by name
121
128
  # @param name [String] the board name
122
129
  # @return [bool] whether the command succeeded
@@ -129,6 +136,15 @@ module ArduinoCI
129
136
  result[:success]
130
137
  end
131
138
 
139
+ # Find out if a library is available
140
+ #
141
+ # @param name [String] the library name
142
+ # @return [bool] whether the library can be installed via the library manager
143
+ def library_available?(name)
144
+ # the --names flag limits the size of the response to just the name field
145
+ capture_json("lib", "search", "--names", name)[:json]["libraries"].any? { |l| l["name"] == name }
146
+ end
147
+
132
148
  # @return [Hash] information about installed libraries via the CLI
133
149
  def installed_libraries
134
150
  capture_json("lib", "list")[:json]
@@ -57,20 +57,23 @@ module ArduinoCI
57
57
  # @return [ArudinoCI::CIConfig] The configuration with defaults filled in
58
58
  def default
59
59
  ret = new
60
+ ret.instance_variable_set("@is_default", true)
60
61
  ret.load_yaml(File.expand_path("../../misc/default.yml", __dir__))
61
62
  ret
62
63
  end
63
64
  end
64
65
 
66
+ attr_reader :is_default
65
67
  attr_accessor :package_info
66
68
  attr_accessor :platform_info
67
69
  attr_accessor :compile_info
68
70
  attr_accessor :unittest_info
69
71
 
70
72
  def initialize
71
- @package_info = {}
73
+ @is_default = false
74
+ @package_info = {}
72
75
  @platform_info = {}
73
- @compile_info = {}
76
+ @compile_info = {}
74
77
  @unittest_info = {}
75
78
  end
76
79
 
@@ -103,7 +103,7 @@ module ArduinoCI
103
103
  the_file = path.basename.to_s
104
104
 
105
105
  stdout, _stderr, _exitstatus = Open3.capture3('cmd.exe', "/c dir /al #{the_dir}")
106
- symlinks = stdout.lines.map { |l| DIR_SYMLINK_REGEX.match(l) }.compact
106
+ symlinks = stdout.lines.map { |l| DIR_SYMLINK_REGEX.match(l.scrub) }.compact
107
107
  our_link = symlinks.find { |m| m[1] == the_file }
108
108
  return nil if our_link.nil?
109
109
 
@@ -24,7 +24,12 @@ module ArduinoCI
24
24
 
25
25
  # @return [Hash] the properties as a hash, all strings
26
26
  def to_h
27
- @fields.clone
27
+ Hash[@fields.map { |k, _| [k.to_sym, send(k)] }]
28
+ end
29
+
30
+ # @return [String] the string representation
31
+ def to_s
32
+ to_h.to_s
28
33
  end
29
34
 
30
35
  # Enable a shortcut syntax for library property accessors, in the style of `attr_accessor` metaprogramming.
@@ -1,3 +1,3 @@
1
1
  module ArduinoCI
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -16,7 +16,7 @@ packages:
16
16
  adafruit:samd:
17
17
  url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
18
18
  esp32:esp32:
19
- url: https://dl.espressif.com/dl/package_esp32_index.json
19
+ url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
20
20
 
21
21
  platforms:
22
22
 
@@ -70,7 +70,7 @@ platforms:
70
70
  warnings:
71
71
  flags:
72
72
  esp8266:
73
- board: esp8266:esp8266:huzzah:FlashSize=4M3M,CpuFrequency=80
73
+ board: esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
74
74
  package: esp8266:esp8266
75
75
  gcc:
76
76
  features:
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: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Katz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os