arli 0.5.1 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 233ae21fdec4ad9e4f6fd73c632dc632d626a5df
4
- data.tar.gz: 4db04f61697a98c6288a81d5179bfc62fccf79ee
3
+ metadata.gz: 716b1c4d72d5a8d569c26ca80f0bd0c86d260414
4
+ data.tar.gz: ccb615215a6b8ecbcf129f9a2feb94a190a1c98b
5
5
  SHA512:
6
- metadata.gz: ca67abe8ac90302ffdf49aedfc0c3a33f999f5bc28721aa027e7f9ad104a29cbadff9bcc4ace2fed7bbb2fccf0fc6aada19f38f4096f597599c4188ed8eaf950
7
- data.tar.gz: 1635be7126e6515ad602c68388d0e660b2536a12a5d197621c057fcec48f0641a477224cbd87072ea673c9b51c2692a9b9153e2dec1fbc6465c02816dfbb7c66
6
+ metadata.gz: e403f0d96a42d0d21a37e5da72e882e497c045f0139ae210b7a83f9a2ec4cf63ddda3e359055daf8379f7869b500f25e302fe5791e88d83b50bbfdff8d91d48c
7
+ data.tar.gz: 7444ed04113582cf6abe9bcbc54bb1141803469b7e731ab2af575f94b5f83faa1c03e8e6cc0e6b7092b03acd66a1d9a4e53aa5378c6c563b6471b851542863e2
@@ -0,0 +1,8 @@
1
+ build
2
+ clean
3
+ clobber
4
+ doc
5
+ install
6
+ install:local
7
+ release[remote]
8
+ spec
data/README.md CHANGED
@@ -12,29 +12,19 @@ a YAML formatted file declaring dependencies, as follows:
12
12
  # vi:syntax=yaml
13
13
  version: 1.0.0
14
14
  dependencies:
15
- - name: ESP8266WiFi
16
- version: '1.0'
17
- url: https://github.com/esp8266/Arduino
18
15
  - name: Time
19
16
  - name: "Adafruit GFX Library"
20
17
  - name: SimpleTimer
21
18
  url: https://github.com/jfturcot/SimpleTimer
22
19
  ```
23
20
 
24
- The libraries may be specified with a name and url only, OR they can be specified by name (and optionally version) as long as this is one of the standard libraries documented in the [Arduino official library database](http://downloads.arduino.cc/libraries/library_index.json.gz) JSON file.
21
+ The libraries may be specified with a name and url only (in which case the URL will be used to install it), OR a library can be specified by name (and optionally version). In this case, it will be searched among the standard library index provided by the [Arduino official library database](http://downloads.arduino.cc/libraries/library_index.json.gz) JSON file.
25
22
 
26
-
27
- Basically a simple pairing of a library/project name
28
- (which also happens to be the local directory it's cloned into)
29
- and a remote URL.
30
-
31
- The gem was created to fill the need of managing many external
32
- libraries for an Arduino projects in a consistent way. Arli's
33
- API was loosely inspired by Bundler.
23
+ The gem was created to fill the need of slightly more complex Arduino projects that DO NOT use Arduino IDE, and instead use other technologies, such as `ArduinoCmake` in managing many Arduino libraries in a consistent way. Arli's API was loosely inspired by Bundler.
34
24
 
35
25
  ## Installation
36
26
 
37
- Install the gem globally like this:
27
+ Install the `arli` ruby gem as follows:
38
28
 
39
29
  ```bash
40
30
  # if using rbenv, or rvm; otherwise you may need to prefix
@@ -47,9 +37,8 @@ $ gem install arli
47
37
  Run `arli --help` for more information:
48
38
 
49
39
  ```bash
50
-
51
- Usage:
52
- arli [options] [ command [options] ]
40
+ age:
41
+ arli [ options ] [ command [ options ] ]
53
42
 
54
43
  -D, --debug Print debugging info.
55
44
  -t, --trace Print exception stack traces.
@@ -58,19 +47,80 @@ Usage:
58
47
  -h, --help prints this help
59
48
 
60
49
  Available Commands:
61
- install : installs libraries defined in Arlifile
62
- search : Flexible Search of the Arduino Library Database
50
+ install installs libraries defined in Arlifile
51
+ search Flexible Search of the Arduino Library Database
63
52
 
64
- See arli <command> --help for more information on a specific command.
53
+ See arli command --help for more information on a specific command.
65
54
  ```
66
55
 
67
56
  #### Install Command
68
57
 
69
- Use this command to install libraries for the first time.
58
+ Use this command to install or re-install libraries.
59
+
60
+ You can specify libraries in the `Arlifile` by providing either just the `name:` (and posibly `version`) — the name must match exactly a library in the Arduino standard database. Alternatively, your can pass `archiveFileName`, `checksum` — which all uniquely identify a library in the database.
61
+
62
+ Sometimes a library will not be in the database, in which case just provide the name and `url` field for it. The URL can either be a git URL, or a downloadable ZIP file.
63
+
64
+
65
+ ##### Automatic Folder Name Correction
66
+
67
+ Arli has an build-in action that's invoked during installation of the libraries: once the library is upacked into a folder (either using git or unzip), it's contents is searched for source files. The name of the directory is then compared to the files found, and in some cases Arli will rename the library folder to match the source files.
68
+
69
+ For example, 'Adafruit GFX Library' is the proper name of the corresponding library, and it's ZIP archive will unpack into `Adafruit_GFX_Library-1.4.3` folder. Arli will first remove the version number, and move it to `Adafruit_GFX_Library`, but then it will detect that the file inside is `Adafruit_GFX.h`, and so the top-level folder gets renamed to `Adafruit_GFX` as well. This is an audacious attempt to make sense of the chaos that is the Arduino Library world.
70
+
71
+ ##### An Example
72
+
73
+ Here is the `arli install` command inside CMake-based project to build a [Wall Clock using Arduino](https://github.com/kigster/wallclock-arduino). This project has the following `Arlifile`:
74
+
75
+ ```yaml
76
+ # vi:syntax=yaml
77
+ ---
78
+ dependencies:
79
+ - name: "Adafruit GFX Library"
80
+ - name: "DS1307RTC"
81
+ - name: "Adafruit LED Backpack Library"
82
+ - name: "Adafruit Unified Sensor"
83
+ - name: "DHT sensor library"
84
+ - name: "OneButton"
85
+ - name: SimpleTimer
86
+ url: https://github.com/jfturcot/SimpleTimer.git
87
+ - name: Time
88
+ ```
89
+
90
+ You can see that most libraries are specified by name, except one (SimpleTimer) is specified together with the URL, which will be used to `git clone` the library.
91
+
92
+ So let's specify where our libraries live, and run `arli install` inside that project:
93
+
94
+ ```bash
95
+ ❯ export ARDUINO_CUSTOM_LIBRARY_PATH=~/Documents/Arduino/libraries/
96
+ ❯ cd skethes/wallclock-arduino
97
+ ❯ arli install
98
+ Adafruit GFX Library (1.2.2) ....... (Adafruit_GFX)
99
+ DS1307RTC (1.4.0) ......
100
+ Adafruit LED Backpack Library (1.1.6) ....... (Adafruit_LEDBackpack)
101
+ Adafruit Unified Sensor (1.0.2) ....... (Adafruit_Sensor)
102
+ DHT sensor library (1.3.0) ....... (DHT)
103
+ OneButton (1.2.0) .......
104
+ SimpleTimer running git clone -v https://github.com/jfturcot/SimpleTimer.git ~/Documents/Arduino/libraries/SimpleTimer 2>&1 .
105
+ s (1.5.0) ......
106
+ ```
107
+
108
+ Now, we can inspect the library folder and observe that all of the specified libraries have been installed, and into correct folders:
109
+
110
+ ```bash
111
+ ❯ ls -1 ~/Documents/Arduino/libraries
112
+ Adafruit_GFX
113
+ DS1307RTC
114
+ Adafruit_LEDBackpack
115
+ Adafruit_Sensor
116
+ DHT
117
+ OneButton
118
+ SimpleTimer
119
+ Time
120
+ ```
121
+
122
+ Below is the complete help for the install command:
70
123
 
71
- NOTE: unless you pass `-e` flag, install command falls back to `update` if
72
- the target folder already exists. With `-e` flag, installer aborts if the
73
- target library already exists.
74
124
 
75
125
  ```bash
76
126
  Description:
@@ -80,10 +130,10 @@ Usage:
80
130
  arli install [options]
81
131
 
82
132
  Command Options
83
- -l, --libs PATH Local folder where libraries are installed
133
+ -l, --libraries PATH Local folder where libraries are installed
84
134
  Defaults to ~/Dropbox/Workspace/oss/arduino/libraries
85
135
 
86
- -p, --arli-path PATH Folder where Arlifile is located,
136
+ -a, --arli-path PATH Folder where Arlifile is located,
87
137
  Defaults to the current directory.
88
138
 
89
139
  -e, --if-exists ACTION If a library folder already exists, by default
@@ -97,17 +147,58 @@ Command Options
97
147
  -h, --help prints this help
98
148
  ```
99
149
 
100
-
101
150
  #### Search Command
102
151
 
103
- To search Arduino library database, you can use the search command:
152
+ To search Arduino library database, you can use the search command.
153
+
154
+ You can search in two ways:
155
+
156
+ 1. simple name match
157
+ 2. complex arbitrary attribute match, that supports regular expressions and more.
158
+
159
+ `arli search AudioZero` does a simple search by name, and returns 3 results:
160
+
161
+ ```bash
162
+ ❯ arli search AudioZero
163
+ AudioZero (1.0.1), by Arduino
164
+ AudioZero (1.0.0), by Arduino
165
+ AudioZero (1.1.1), by Arduino
166
+
167
+ Total matches: 3
168
+ ```
169
+
170
+ The search argument can also be a ruby-syntaxed expression, that (if you know ruby) is actually `eval`-ed into the method parameters. Here are a few examples:
171
+
172
+
173
+
174
+ You can also use regular expressions, and set maximum number of results printed by the `-m MAX` flag.
175
+
176
+ ```bash
177
+ ❯ arli search 'name: /adafruit/i' -m 0
178
+ Adafruit ADS1X15 (1.0.0), by Adafruit
179
+ Adafruit ADXL345 (1.0.0), by Adafruit
180
+ Adafruit AM2315 (1.0.0), by Adafruit
181
+ Adafruit AM2315 (1.0.1), by Adafruit
182
+ .....
183
+ WEMOS Matrix Compatible With Adafruit GFX Library (1.0.0), by Thomas O Fredericks
184
+ WEMOS Matrix Compatible With Adafruit GFX Library (1.1.0), by Thomas O Fredericks
185
+ Adafruit SGP30 Sensor (1.0.0), by Adafruit
186
+
187
+ Total matches: 352
188
+ ```
189
+
190
+ With `-m 0` flag, we disabled the default search limit of 100, and got all of the libraries that have the word "adafruit" in their name. We could have used `version:`, or `author`, or `website`, or even `url` and `archiveFileName` fields. For complete description of available library attributes, please see the official definition of the [`library.properties`](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-metadata) file.
191
+
192
+ A detailed description of the complete search functionality is documented in the library that provides it — [arduino-library](https://github.com/kigster/arduino-library#using-search). Arli uses `arduino-library` gem behind the scenes to search, and lookup libraries.
193
+
194
+ Below is the help screen for the search command:
104
195
 
105
196
  ```bash
106
197
  Description:
107
198
  Flexible Search of the Arduino Library Database
108
199
 
109
200
  Usage:
110
- arli search <query> [options]
201
+ arli search [ name-match | expression ] [options]
111
202
 
112
203
  Command Options
113
204
  -d FILE/URL, a JSON file name, or a URL that contains the index
@@ -121,8 +212,9 @@ Command Options
121
212
  -h, --help prints this help
122
213
 
123
214
  Example:
124
- arli search 'name: /AudioZero/, version: "1.0.1"'
125
- I```
215
+ arli search 'name: /AudioZero/, version: "1.0.1"'
216
+ ```
217
+
126
218
 
127
219
  ## Development
128
220
 
data/Rakefile CHANGED
@@ -1,6 +1,28 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yard'
4
+
5
+ def shell(*args)
6
+ puts "running: #{args.join(' ')}"
7
+ system(args.join(' '))
8
+ end
9
+
10
+ task :permissions do
11
+ shell('rm -rf pkg/ tmp/' )
12
+ shell("chmod -v o+r,g+r * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/*")
13
+ shell("find . -type d -exec chmod o+x,g+x {} \\;")
14
+ end
15
+
16
+ task :build => :permissions
17
+
18
+ YARD::Rake::YardocTask.new(:doc) do |t|
19
+ t.files = %w(lib/**/*.rb exe/*.rb - README.md LICENSE)
20
+ t.options.unshift('--title','"Sym – Symmetric Key Encryption for Your Data"')
21
+ t.after = ->() { exec('open doc/index.html') }
22
+ end
3
23
 
4
24
  RSpec::Core::RakeTask.new(:spec)
5
25
 
6
26
  task :default => :spec
27
+
28
+
@@ -28,18 +28,21 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- spec.add_dependency 'arduino-library', '~> 0.4.1'
31
+ spec.add_dependency 'arduino-library', '~> 0.5.1'
32
32
  spec.add_dependency 'colored2'
33
33
  spec.add_dependency 'hashie'
34
34
  spec.add_dependency 'dry-types'
35
35
  spec.add_dependency 'dry-struct'
36
+ spec.add_dependency 'dry-configurable'
36
37
  spec.add_dependency 'awesome_print'
37
38
  spec.add_dependency 'archive-zip'
38
39
 
39
40
 
41
+ spec.add_development_dependency 'yard'
40
42
  spec.add_development_dependency 'simplecov'
41
43
  spec.add_development_dependency 'bundler', '~> 1.15'
42
44
  spec.add_development_dependency 'rake', '~> 10.0'
43
45
  spec.add_development_dependency 'rspec', '~> 3.0'
44
46
  spec.add_development_dependency 'rspec-its'
47
+ spec.add_development_dependency 'aruba'
45
48
  end
data/exe/arli CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'arli'
3
+ require 'arli/cli/runner'
4
4
 
5
- Arli::CLI.new.tap do |cli|
6
- cli.parse
7
- end
5
+ Arli::CLI::Runner.new(ARGV.dup).execute!
8
6
 
@@ -1,42 +1,40 @@
1
- require 'forwardable'
2
- require 'logger'
3
1
  require 'arduino/library'
4
2
 
5
3
  require 'arli/version'
4
+ require 'arli/extensions'
6
5
  require 'arli/errors'
7
- require 'arli/logger'
8
- require 'arli/config'
6
+ require 'arli/configuration'
7
+ require 'arli/library'
8
+ require 'arli/commands'
9
9
 
10
10
  module Arli
11
+ @config = ::Arli::Configuration.config
11
12
 
12
13
  class << self
13
14
  attr_accessor :config
14
- end
15
-
16
- self.config = ::Arli::Config
17
-
18
- class << self
19
- extend Forwardable
20
- def_delegators :@config, *::Arli::Config::PARAMS
21
15
 
22
16
  def configure(&_block)
23
17
  yield(self.config)
24
18
  end
25
19
 
26
20
  def debug?
27
- self.debug
21
+ self.config.debug
28
22
  end
29
- end
30
- end
31
23
 
32
- Arli.configure do |config|
33
- config.library_path = ::Arduino::Library::DefaultDatabase.library_path
34
- config.library_index_path = ::Arduino::Library::DefaultDatabase.library_index_path
35
- config.library_index_url = ::Arduino::Library::DefaultDatabase.library_index_url
36
- config.logger = ::Logger.new(STDOUT, level: :info)
37
- config.debug = ENV['ARLI_DEBUG'] || false
24
+ def library_path
25
+ self.config.libraries.path
26
+ end
27
+
28
+ def default_library_path
29
+ dehomify_path(self.config.libraries.path)
30
+ end
31
+
32
+ def dehomify_path(absolute_path)
33
+ absolute_path.gsub(%r(#{ENV['HOME']}), '~')
34
+ end
35
+ end
38
36
  end
39
37
 
40
38
  require 'arli/arli_file'
41
- require 'arli/installer'
39
+ require 'arli/actions'
42
40
  require 'arli/cli'
@@ -0,0 +1,19 @@
1
+ module Arli
2
+ module Actions
3
+ class << self
4
+ attr_accessor :actions
5
+
6
+ def action(name)
7
+ self.actions[name]
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ Arli::Actions.actions = {}
14
+
15
+ require_relative 'actions/action'
16
+ require_relative 'actions/zip_file'
17
+ require_relative 'actions/git_repo'
18
+ require_relative 'actions/dir_name'
19
+ require_relative 'actions/backup'
@@ -0,0 +1,32 @@
1
+ require_relative '../output'
2
+
3
+ module Arli
4
+ module Actions
5
+ # Represents an abstract action related to the library
6
+ class Action
7
+ include Arli::Output
8
+
9
+ extend Forwardable
10
+ def_delegators :@library, :exists?, :path, :dir, :libraries_home
11
+
12
+ class << self
13
+ def inherited(klazz)
14
+ action_name = klazz.name.gsub(/.*::/, '').underscore.to_sym
15
+ ::Arli::Actions.actions[action_name] = klazz
16
+ end
17
+ end
18
+
19
+ attr_accessor :library, :config
20
+
21
+ def initialize(library, config: Arli.config)
22
+ self.library = library
23
+ self.config = config
24
+ end
25
+
26
+ def act(**_opts)
27
+ raise 'Abstract method #act called on Action'
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'action'
2
+
3
+ module Arli
4
+ module Actions
5
+ class Backup < Action
6
+
7
+ def act(**options)
8
+ return false unless exists?
9
+
10
+ if backup_action.abort
11
+ raise Arli::Errors::LibraryAlreadyExists, path
12
+ elsif backup_action.backup
13
+ FileUtils.mv(path, backup_library_path)
14
+ elsif backup_action.overwrite
15
+ library.rm_rf!
16
+ end
17
+ end
18
+
19
+ def backup_action
20
+ config.install.if_exists
21
+ end
22
+
23
+ private
24
+
25
+ def backup_library_path
26
+ path + ".#{Time.now.strftime('%Y%m%d%H%M%S')}"
27
+ end
28
+ end
29
+ end
30
+ end