arli 0.7.0 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +0 -2
  4. data/README.md +149 -48
  5. data/arli.gemspec +1 -3
  6. data/docs/arli-in-action.png +0 -0
  7. data/docs/arlifile.png +0 -0
  8. data/exe/arli +5 -1
  9. data/lib/arli.rb +2 -2
  10. data/lib/arli/actions.rb +6 -1
  11. data/lib/arli/actions/action.rb +57 -37
  12. data/lib/arli/actions/dir_name.rb +18 -16
  13. data/lib/arli/actions/git_repo.rb +8 -8
  14. data/lib/arli/actions/move_to_library_path.rb +54 -0
  15. data/lib/arli/actions/{zip_file.rb → unzip_file.rb} +14 -10
  16. data/lib/arli/arli_file.rb +52 -32
  17. data/lib/arli/cli/app.rb +11 -4
  18. data/lib/arli/cli/command_finder.rb +14 -11
  19. data/lib/arli/cli/parser.rb +70 -29
  20. data/lib/arli/cli/parser_factory.rb +105 -50
  21. data/lib/arli/cli/runner.rb +8 -4
  22. data/lib/arli/commands.rb +1 -0
  23. data/lib/arli/commands/base.rb +11 -6
  24. data/lib/arli/commands/bundle.rb +43 -0
  25. data/lib/arli/commands/install.rb +56 -13
  26. data/lib/arli/commands/search.rb +82 -27
  27. data/lib/arli/configuration.rb +37 -18
  28. data/lib/arli/errors.rb +6 -0
  29. data/lib/arli/library.rb +4 -46
  30. data/lib/arli/library/installer.rb +71 -0
  31. data/lib/arli/library/proxy.rb +79 -0
  32. data/lib/arli/lock/file.rb +65 -0
  33. data/lib/arli/lock/formats.rb +4 -0
  34. data/lib/arli/lock/formats/base.rb +26 -0
  35. data/lib/arli/lock/formats/cmake.rb +24 -0
  36. data/lib/arli/lock/formats/json.rb +25 -0
  37. data/lib/arli/lock/formats/text.rb +13 -0
  38. data/lib/arli/lock/formats/yaml.rb +14 -0
  39. data/lib/arli/output.rb +94 -11
  40. data/lib/arli/version.rb +1 -1
  41. metadata +17 -35
  42. data/docs/arli-full.png +0 -0
  43. data/lib/arli/installer.rb +0 -52
@@ -0,0 +1,13 @@
1
+ require_relative 'base'
2
+
3
+ module Arli
4
+ module Lock
5
+ module Formats
6
+ class Text < Base
7
+ def format(library)
8
+ "#{library.canonical_dir},#{library.version},#{library.path}"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'json'
2
+ require 'yaml'
3
+ module Arli
4
+ module Lock
5
+ module Formats
6
+ class Yaml < Json
7
+ def footer
8
+ "# vi:syntax=yaml\n" +
9
+ YAML.dump(hash)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -3,15 +3,20 @@ require 'tty-cursor'
3
3
 
4
4
  module Arli
5
5
  module Output
6
+ CHAR_FAILURE = '✖'.red
7
+ CHAR_SUCCESS = '✔'.green
6
8
 
7
9
  class << self
8
10
  attr_accessor :enabled, :cursor
11
+
9
12
  def enable!
10
13
  self.enabled = true
11
14
  end
15
+
12
16
  def enabled?
13
17
  self.enabled
14
18
  end
19
+
15
20
  def disable!
16
21
  self.enabled = false
17
22
  end
@@ -40,13 +45,19 @@ module Arli
40
45
  end
41
46
 
42
47
  def report_exception(e, header = nil)
43
- __pf header.bold.yellow + ': ' if header
48
+ if header
49
+ __pf header.bold.yellow + ': '
50
+ else
51
+ __pf 'Error: '.bold.red
52
+ end
44
53
  error e.message if (e && e.respond_to?(:message))
45
54
  if e && Arli.config.trace
46
- __pf e.backtrace.reverse.join("\n")
55
+ __pf "\n"
56
+ __pf 'Top 10 stack trace'.bold.yellow + "\n"
57
+ __pf e.backtrace.reverse[-10..-1].join("\n").red + "\n"
47
58
  elsif e
48
59
  __pf "\nUse -t (--trace) for detailed exception\n" +
49
- "or -D (--debug) to print Arli config\n"
60
+ "or -D (--debug) to print Arli config\n"
50
61
  end
51
62
  end
52
63
 
@@ -73,24 +84,67 @@ module Arli
73
84
  printf(*args) if Arli::Output.enabled?
74
85
  end
75
86
 
76
- def ok
77
- ___ '.'.green
87
+
88
+ def print_target_dir(d, verb = 'installed')
89
+ print_action_success(d.green, "#{verb} #{d.green} ")
90
+ end
91
+
92
+ def print_action_starting(action_name)
93
+ if verbose?
94
+ indent_cursor
95
+ ___ "⇨ #{action_name.yellow} ... "
96
+ end
97
+ if block_given?
98
+ yield
99
+ ok if verbose?
100
+ end
101
+ end
102
+
103
+ def print_action_success(short, verbose = nil)
104
+ if verbose? && !quiet?
105
+ indent_cursor
106
+ ___ "⇨ #{verbose || short} #{CHAR_SUCCESS}"
107
+ elsif !quiet?
108
+ ___ "#{short} #{CHAR_SUCCESS} "
109
+ end
110
+ end
111
+
112
+ def print_action_failure(short, verbose = nil)
113
+ if verbose? && !quiet?
114
+ indent_cursor
115
+ ___ "⇨ #{verbose || short} #{CHAR_FAILURE}\n"
116
+ elsif !quiet?
117
+ ___ "#{short} #{CHAR_FAILURE} "
118
+ end
119
+ end
120
+
121
+ def action_fail(action, exception)
122
+ print_action_failure(action.class.action_name,
123
+ "#{action.class.action_name} failed with #{exception.message.red}\n" +
124
+ "Action Description: #{action.class.description}")
125
+ raise(exception)
78
126
  end
79
127
 
80
- def check
81
- ___ '✔'.green
128
+ def action_ok(action)
129
+ print_action_success(action.action_name)
130
+ end
131
+
132
+ def ok
133
+ ___ " #{CHAR_SUCCESS} "
82
134
  end
83
135
 
84
136
  def fuck
85
- ___ '✖'.red
137
+ ___ " #{CHAR_FAILURE} "
86
138
  end
87
139
 
88
140
  def header(command: nil)
89
141
  out = "\n#{hr}\n"
90
142
  out << "Arli (#{::Arli::VERSION.yellow})"
91
- out << " running command #{command.name.to_s.magenta.bold}" if command
92
- out << " for #{command.params.to_s.blue}\n" if command
93
- out << "Library Path: #{Arli.default_library_path.green}\n"
143
+ out << ", Command: #{command.name.to_s.magenta.bold}" if command
144
+ if command && command.params && Arli.config.verbose
145
+ out << "\n#{command.params.to_s.blue}\n"
146
+ end
147
+ out << "\nLibrary Path: #{Arli.default_library_path.green}\n"
94
148
  out << "#{hr}\n"
95
149
  info out
96
150
  end
@@ -99,5 +153,34 @@ module Arli
99
153
  ('-' * (ENV['COLUMNS'] || 80)).red.dark
100
154
  end
101
155
 
156
+ # Some shortcuts
157
+ def verbose?
158
+ config.verbose && !quiet?
159
+ end
160
+
161
+ def quiet?
162
+ config.quiet
163
+ end
164
+
165
+ def overwrite?
166
+ config.if_exists.overwrite
167
+ end
168
+
169
+ def backup?
170
+ config.if_exists.backup
171
+ end
172
+
173
+ def abort?
174
+ config.if_exists.abort
175
+ end
176
+
177
+ def debug?
178
+ config.debug
179
+ end
180
+
181
+ private
182
+ def indent_cursor
183
+ ___ cursor.column(40)
184
+ end
102
185
  end
103
186
  end
@@ -1,3 +1,3 @@
1
1
  module Arli
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.3'.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.7.0
4
+ version: 0.8.3
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-11-29 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino-library
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.1
19
+ version: 0.5.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.1
26
+ version: 0.5.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: colored2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,34 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: awesome_print
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: archive-zip
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: tty-cursor
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -255,15 +227,16 @@ files:
255
227
  - arli.gemspec
256
228
  - bin/console
257
229
  - bin/setup
258
- - docs/arli-full.png
259
230
  - docs/arli-in-action.png
231
+ - docs/arlifile.png
260
232
  - exe/arli
261
233
  - lib/arli.rb
262
234
  - lib/arli/actions.rb
263
235
  - lib/arli/actions/action.rb
264
236
  - lib/arli/actions/dir_name.rb
265
237
  - lib/arli/actions/git_repo.rb
266
- - lib/arli/actions/zip_file.rb
238
+ - lib/arli/actions/move_to_library_path.rb
239
+ - lib/arli/actions/unzip_file.rb
267
240
  - lib/arli/arli_file.rb
268
241
  - lib/arli/cli.rb
269
242
  - lib/arli/cli/app.rb
@@ -273,13 +246,22 @@ files:
273
246
  - lib/arli/cli/runner.rb
274
247
  - lib/arli/commands.rb
275
248
  - lib/arli/commands/base.rb
249
+ - lib/arli/commands/bundle.rb
276
250
  - lib/arli/commands/install.rb
277
251
  - lib/arli/commands/search.rb
278
252
  - lib/arli/configuration.rb
279
253
  - lib/arli/errors.rb
280
254
  - lib/arli/extensions.rb
281
- - lib/arli/installer.rb
282
255
  - lib/arli/library.rb
256
+ - lib/arli/library/installer.rb
257
+ - lib/arli/library/proxy.rb
258
+ - lib/arli/lock/file.rb
259
+ - lib/arli/lock/formats.rb
260
+ - lib/arli/lock/formats/base.rb
261
+ - lib/arli/lock/formats/cmake.rb
262
+ - lib/arli/lock/formats/json.rb
263
+ - lib/arli/lock/formats/text.rb
264
+ - lib/arli/lock/formats/yaml.rb
283
265
  - lib/arli/output.rb
284
266
  - lib/arli/version.rb
285
267
  homepage: https://github.com/kigster/arli
Binary file
@@ -1,52 +0,0 @@
1
- require 'forwardable'
2
- require 'arli'
3
- require_relative 'actions'
4
-
5
- module Arli
6
- class Installer
7
- include ::Arli::Output
8
-
9
- extend Forwardable
10
- def_delegators :@library, :exists?
11
-
12
- attr_accessor :library, :config
13
-
14
- def initialize(library, config: Arli.config)
15
- self.config = config
16
- self.library = library
17
- end
18
-
19
- def install
20
- ___ "#{library.name.blue} "
21
-
22
- if library.nil? && library.library.nil?
23
- ___ ' (no library) '
24
- fuck
25
- elsif library.url.nil?
26
- ___ ' (no url) '
27
- fuck
28
- else
29
- ___ "(#{library.version.green}) " if library.version
30
- ___ cursor.column(45) unless config.quiet
31
- actions(library).each do |action|
32
- run_action(action)
33
- end
34
- end
35
- ___ "\n"
36
- end
37
-
38
- def run_action(action)
39
- klass = Arli::Actions.action(action)
40
- klass.new(library, config: config).act if klass
41
- end
42
-
43
- def actions(library)
44
- actions = []
45
- # First, how do we get the library?
46
- actions << ((library.url =~ /\.zip$/i) ? :zip_file : :git_repo)
47
- actions << :dir_name
48
- actions
49
- end
50
- end
51
- end
52
-