arli 0.9.0 → 1.0.0

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.
@@ -22,10 +22,9 @@ module Arli
22
22
 
23
23
  def setup
24
24
  super
25
-
26
25
  self.install_argument = runtime.argv.first
27
26
  raise InvalidInstallSyntaxError,
28
- "Missing installation argument: a name, a file or a URL." unless install_argument
27
+ 'Missing installation argument: a name, a file or a URL.' unless install_argument
29
28
 
30
29
  self.library = identify_library(install_argument)
31
30
  raise Arli::Errors::LibraryNotFound,
@@ -91,7 +91,7 @@ module Arli
91
91
  elsif search.start_with?('/')
92
92
  self.search_method = :regex_name_and_url
93
93
  # exact match
94
- "#{config.search.default_field}: #{search}, archiveFileName: #{search}"
94
+ "#{config.search.default_field}: #{search}"
95
95
  elsif search.start_with?('=')
96
96
  self.search_method = :equals
97
97
  # exact match
@@ -5,11 +5,12 @@ require 'yaml'
5
5
  module Arli
6
6
  class Configuration
7
7
 
8
- DEFAULT_FILENAME = 'Arlifile'.freeze
9
- DEFAULT_LOCK_FILENAME = (DEFAULT_FILENAME + '.lock').freeze
10
- ACTIONS_WHEN_EXISTS = %i(backup overwrite abort)
11
- ARLI_COMMAND = 'arli'.freeze
12
- DEFAULT_RESULTS_LIMIT = 0
8
+ DEFAULT_FILENAME = 'Arlifile'.freeze
9
+ DEFAULT_LOCK_FILENAME = (DEFAULT_FILENAME + '.lock').freeze
10
+ ACTIONS_WHEN_EXISTS = %i(backup overwrite abort)
11
+ ARLI_COMMAND = 'arli'.freeze
12
+ DEFAULT_RESULTS_LIMIT = 0
13
+ GENERATE_TEMPLATE_REPO = 'https://github.com/kigster/arli-cmake'
13
14
 
14
15
  extend Dry::Configurable
15
16
 
@@ -60,12 +61,20 @@ module Arli
60
61
  end
61
62
  end
62
63
 
64
+ setting :generate do
65
+ setting :project_name
66
+ setting :workspace, '.'
67
+ setting :libs
68
+ setting :template_repo, GENERATE_TEMPLATE_REPO
69
+ end
70
+
63
71
  # Arlifile
64
72
  setting :arlifile do
65
73
  setting :path, ::Dir.pwd
66
74
  setting :name, ::Arli::Configuration::DEFAULT_FILENAME
67
75
  setting :lock_name, ::Arli::Configuration::DEFAULT_LOCK_FILENAME
68
76
  setting :lock_format, :text
77
+ setting :hash
69
78
  end
70
79
 
71
80
  setting :bundle do
@@ -23,5 +23,8 @@ module Arli
23
23
  class TooManyMatchesError < ArliError; end
24
24
 
25
25
  class ZipFileError < InstallerError; end
26
+
27
+ class RequiredArgumentsMissing < ArliError; end
28
+
26
29
  end
27
30
  end
@@ -7,6 +7,7 @@ module Arli
7
7
  CHAR_FAILURE = '✖'.red
8
8
  CHAR_SUCCESS = '✔'.green
9
9
 
10
+ # Singleton Class
10
11
  class << self
11
12
  attr_accessor :enabled, :cursor
12
13
 
@@ -23,6 +24,8 @@ module Arli
23
24
  end
24
25
  end
25
26
 
27
+ # Include Module
28
+
26
29
  self.enable!
27
30
  self.cursor = TTY::Cursor
28
31
 
@@ -145,6 +148,7 @@ module Arli
145
148
  if command && command.params && Arli.config.verbose
146
149
  out << "\n#{command.params.to_s.blue}\n"
147
150
  end
151
+ out << command.additional_info if command.respond_to?(:additional_info)
148
152
  out << "\nLibrary Path: #{Arli.default_library_path.green}\n"
149
153
  out << "#{hr}\n"
150
154
  info out
@@ -0,0 +1,48 @@
1
+ require_relative 'output'
2
+
3
+ module Arli
4
+ module Helpers
5
+ module SystemCommands
6
+
7
+ include Output
8
+
9
+ def handle_preexisting_folder(to)
10
+ if Dir.exist?(to)
11
+ if abort?
12
+ raise ::Arli::Errors::LibraryAlreadyExists, "Directory #{to} already exists"
13
+ elsif backup?
14
+ backup!(to)
15
+ elsif overwrite?
16
+ FileUtils.rm_rf(to)
17
+ end
18
+ end
19
+ end
20
+
21
+ def backup!(p)
22
+ if Dir.exist?(p)
23
+ backup_path = "#{p}.arli-backup-#{Time.now.strftime('%Y%m%d%H%M%S')}"
24
+ FileUtils.mv(p, backup_path)
25
+ print_target_dir(backup_path, 'backed up')
26
+ if verbose?
27
+ ___ "\nNOTE: path #{p.blue} has been backed up to #{backup_path.bold.green}\n"
28
+ end
29
+ end
30
+ end
31
+
32
+ # @param <String> *args — list of arguments or a single string
33
+ def run_system_command(*args)
34
+ cmd = args.join(' ')
35
+ raise 'No command to run was given' unless cmd
36
+ info("\n" + cmd.green) if Arli.debug?
37
+ o, e, s = Open3.capture3(cmd)
38
+ info("\n" + o) if o if Arli.debug?
39
+ info("\n" + e.red) if e && Arli.debug?
40
+ rescue Exception => e
41
+ error "Error running [#{args.join(' ')}]\n" +
42
+ "Current folder is [#{Dir.pwd.yellow}]", e
43
+ raise e
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -47,7 +47,7 @@ module Arli
47
47
  end
48
48
  puts if verbose?
49
49
  else
50
- print_action_failure("unsupported", "missing pre-requisites: #{klass.command_name.bold.yellow} did not succeed")
50
+ print_action_failure('unsupported', "missing pre-requisites: #{klass.command_name.bold.yellow} did not succeed")
51
51
  end
52
52
  else
53
53
  print_action_failure("#{action_name.red} not found")
@@ -13,34 +13,34 @@ module Arli
13
13
  :config,
14
14
  :formatter,
15
15
  :file,
16
- :format
16
+ :format,
17
+ :arlifile
17
18
 
18
- def initialize(config: Arli.config)
19
+ def initialize(config: Arli.config, arlifile: nil)
19
20
  self.config = config
21
+ self.arlifile = arlifile
20
22
  self.format = config.arlifile.lock_format
21
23
  self.formatter = set_formatter(format)
22
24
  self.lock_file_path = "#{config.arlifile.path}/#{config.arlifile.name}.#{formatter.extension}"
23
25
  self.file = ::File.open(lock_file_path, 'w')
24
-
25
- append(formatter.header)
26
26
  end
27
27
 
28
28
  def lock(*libraries)
29
+ append(formatter.header)
29
30
  libraries.each do |lib|
30
31
  append(formatter.format(lib))
31
32
  end
33
+ append(formatter.footer)
34
+ ensure
35
+ close
32
36
  end
33
37
 
34
38
  def lock!(*args)
35
39
  lock(*args)
36
- ensure
37
- close
38
40
  end
39
41
 
40
42
  def close
41
- append(formatter.footer)
42
- ensure
43
- file.close
43
+ file.close rescue nil
44
44
  end
45
45
 
46
46
  def append(line = nil)
@@ -7,10 +7,11 @@ module Arli
7
7
  include Arli::Helpers::Inherited
8
8
  attr_assignable :extension
9
9
 
10
- attr_accessor :lock_file
10
+ attr_accessor :lock_file, :arlifile
11
11
 
12
12
  def initialize(lock_file)
13
13
  self.lock_file = lock_file
14
+ self.arlifile = lock_file.arlifile
14
15
  end
15
16
 
16
17
  # Optional header
@@ -18,7 +19,6 @@ module Arli
18
19
  end
19
20
 
20
21
  def format(library)
21
- raise Arli::Errors::AbstractMethodCalled, "#format on Base"
22
22
  end
23
23
 
24
24
  # Optional footer
@@ -1,4 +1,5 @@
1
1
  require_relative 'base'
2
+ require_relative 'template/cmake_renderer'
2
3
 
3
4
  module Arli
4
5
  module Lock
@@ -6,33 +7,21 @@ module Arli
6
7
  class Cmake < Base
7
8
  extension :cmake
8
9
 
10
+ attr_accessor :libraries
9
11
 
10
- attr_accessor :libs, :comments
11
-
12
- def header
13
- @comments = []
14
- @libs = []
15
- "# vi:syntax=cmake"
12
+ def initialize(*args)
13
+ super(*args)
14
+ self.libraries = []
16
15
  end
17
16
 
18
17
  def format(library)
19
- @libs << library
20
- @comments << "# Library #{library.name}:\n# version #{library.version}\n# url: #{library.url}"
18
+ self.libraries << library
21
19
  nil
22
20
  end
23
21
 
24
22
  def footer
25
- %Q[
26
- # This file is auto-generated by Arli library manager.
27
- # See https://github.com/kigster/arli for more info.
28
-
29
- set(ARLI_LIBRARIES_PATH "#{Arli.config.libraries.path}")
30
- set(ARLI_LIBRARIES #{@libs.map(&:canonical_dir).join(' ')})
31
-
32
- set(ARLI_LIBRARIES $ARLI_LIBRARIES PARENT_SCOPE)
33
-
34
- #{@comments.join("\n")}
35
- ]
23
+ renderer = Template::CMakeRenderer.new(arlifile)
24
+ renderer.render
36
25
  end
37
26
  end
38
27
  end
@@ -0,0 +1,38 @@
1
+ # vi:syntax=cmake
2
+ #
3
+ # © 2017 Konstantin Gredeskoul
4
+ # Distributed under MIT license.
5
+ #
6
+ # This file is auto-generated by the Arli library manager
7
+ # which works in tandem with another projects — "arduino-cmake",
8
+ # and "arli-cmake".
9
+ #
10
+ # For more info:
11
+ # See https://github.com/kigster/arli
12
+ # See https://github.com/kigster/arli-cmake
13
+ # See https://github.com/kigster/arduino-cmake
14
+
15
+ set(ARLI_CUSTOM_LIBS_PATH "<%= arli_library_path %>")
16
+
17
+ set(ARLI_CUSTOM_LIBS <% libraries.each do |library| %>
18
+ <%= library.canonical_dir %><% end %>)
19
+
20
+ set(ARLI_ARDUINO_HARDWARE_LIBS <% hardware_libraries.each do |library| %>
21
+ <%= library.name %><% end %>)
22
+
23
+ set(ARLI_ARDUINO_LIBS <% arduino_libraries.each do |library| %>
24
+ <%= library.name %><% end %>)
25
+
26
+ <% device_libraries_headers_only.each do |library| %>
27
+ set(<%= library.name %>_ONLY_HEADER yes)<% end %>
28
+
29
+ include(Arli)
30
+
31
+ arli_detect_serial_device("/dev/null")
32
+ arli_detect_board("<%= board %>" "<%= cpu %>")
33
+
34
+ message(STATUS "device: [${BOARD_DEVICE}], board: [${BOARD_NAME}], cpu: [${BOARD_CPU}] <<<")
35
+
36
+ arli_build_all_libraries()
37
+
38
+
@@ -0,0 +1,82 @@
1
+ require 'erb'
2
+ require 'forwardable'
3
+
4
+ module Arli
5
+ module Lock
6
+ module Formats
7
+ module Template
8
+ class CMakeRenderer
9
+
10
+ extend Forwardable
11
+
12
+ def_delegators :@arlifile, :config, :arlifile_hash, :libraries
13
+
14
+ class << self
15
+ attr_accessor :template
16
+ end
17
+
18
+ self.template = ::File.read(::File.expand_path('../Arlifile.cmake.erb', __FILE__))
19
+
20
+ attr_accessor :arlifile, :erb
21
+
22
+ def initialize(arlifile)
23
+ self.arlifile = arlifile
24
+ self.erb = ERB.new(self.class.template)
25
+ end
26
+
27
+ def render
28
+ erb.result(binding)
29
+ end
30
+
31
+ alias output render
32
+
33
+ def device
34
+ arlifile_hash.device
35
+ end
36
+
37
+ def board
38
+ device && device.board ? device.board : 'uno'
39
+ end
40
+
41
+ def cpu
42
+ device && device.cpu ? device.cpu : 'atmega328p'
43
+ end
44
+
45
+ def hardware_libraries
46
+ device && device.libraries ? device.libraries.hardware || [] : []
47
+ end
48
+
49
+ def arduino_libraries
50
+ device && device.libraries ? device.libraries.arduino || [] : []
51
+ end
52
+
53
+ def device_libraries
54
+ Array(hardware_libraries + arduino_libraries).flatten
55
+ end
56
+
57
+ def device_libraries_headers_only
58
+ device_libraries.select { |l| l.headers_only } || []
59
+ end
60
+
61
+ def library_path
62
+ config.libraries.path
63
+ end
64
+
65
+ def arli_library_path
66
+ if library_path.start_with?('/')
67
+ "#{library_path}"
68
+ elsif library_path.start_with?('~')
69
+ "$ENV{HOME}#{library_path[1..-1]}"
70
+ elsif library_path.start_with?('./')
71
+ "${CMAKE_CURRENT_SOURCE_DIR}/#{library_path[2..-1]}"
72
+ elsif library_path && library_path.size > 0
73
+ library_path
74
+ else
75
+ '${CMAKE_CURRENT_SOURCE_DIR}/libraries'
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,3 +1,3 @@
1
1
  module Arli
2
- VERSION = '0.9.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2017-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino-library
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: colored2
28
+ name: awesome_print
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: awesome_print
42
+ name: colored2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: hashie
56
+ name: dry-configurable
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: dry-types
70
+ name: dry-struct
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: dry-struct
84
+ name: dry-types
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: dry-configurable
98
+ name: hashie
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: tty-cursor
112
+ name: require_dir
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,13 +123,13 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: yard
126
+ name: tty-cursor
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
- type: :development
132
+ type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: simplecov
140
+ name: aruba
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -207,7 +207,21 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
- name: aruba
210
+ name: simplecov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: yard
211
225
  requirement: !ruby/object:Gem::Requirement
212
226
  requirements:
213
227
  - - ">="
@@ -220,9 +234,11 @@ dependencies:
220
234
  - - ">="
221
235
  - !ruby/object:Gem::Version
222
236
  version: '0'
223
- description: " This is a command-line installer of any number of dependent Github\n
224
- \ projects, or libraries. Arli was created to offer Arduino-based projects \n an
225
- easy to use and consistent library manager.\n"
237
+ description: " This is an Arduino Library manager, compatible with the \"arduino-cmake\"
238
+ project. \n Arli offers a powerful command-line tool to manage any number of dependent
239
+ Github\n projects, or official Arduino libraries. Arli was created to offer Arduino-based
240
+ \n projects of moderate to high complexity an easy way to reference external libraries\n
241
+ \ and install them at build time, instead of committing them into the project repo.\n"
226
242
  email:
227
243
  - kigster@gmail.com
228
244
  executables:
@@ -260,6 +276,7 @@ files:
260
276
  - lib/arli/commands.rb
261
277
  - lib/arli/commands/base.rb
262
278
  - lib/arli/commands/bundle.rb
279
+ - lib/arli/commands/generate.rb
263
280
  - lib/arli/commands/install.rb
264
281
  - lib/arli/commands/search.rb
265
282
  - lib/arli/configuration.rb
@@ -267,6 +284,7 @@ files:
267
284
  - lib/arli/extensions.rb
268
285
  - lib/arli/helpers/inherited.rb
269
286
  - lib/arli/helpers/output.rb
287
+ - lib/arli/helpers/system_commands.rb
270
288
  - lib/arli/library.rb
271
289
  - lib/arli/library/installer.rb
272
290
  - lib/arli/library/multi_version.rb
@@ -276,6 +294,8 @@ files:
276
294
  - lib/arli/lock/formats/base.rb
277
295
  - lib/arli/lock/formats/cmake.rb
278
296
  - lib/arli/lock/formats/json.rb
297
+ - lib/arli/lock/formats/template/Arlifile.cmake.erb
298
+ - lib/arli/lock/formats/template/cmake_renderer.rb
279
299
  - lib/arli/lock/formats/text.rb
280
300
  - lib/arli/lock/formats/yaml.rb
281
301
  - lib/arli/version.rb
@@ -302,7 +322,9 @@ rubyforge_project:
302
322
  rubygems_version: 2.6.13
303
323
  signing_key:
304
324
  specification_version: 4
305
- summary: This is a command-line installer of any number of dependent Github projects,
306
- or libraries. Arli was created to offer Arduino-based projects an easy to use and
307
- consistent library manager.
325
+ summary: This is an Arduino Library manager, compatible with the "arduino-cmake" project. Arli
326
+ offers a powerful command-line tool to manage any number of dependent Github projects,
327
+ or official Arduino libraries. Arli was created to offer Arduino-based projects
328
+ of moderate to high complexity an easy way to reference external libraries and install
329
+ them at build time, instead of committing them into the project repo.
308
330
  test_files: []