hotdog 0.36.0 → 1.20190725.0

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
  SHA256:
3
- metadata.gz: dcecc952d1506d37d5b5c76ab31b6c9eb4d4e06e85adafefda6d4864299c6fb8
4
- data.tar.gz: 042be0d1b27868b9b2e6bee9d452d33ffc2076718904547c9258435c8eebc84d
3
+ metadata.gz: '0699880ef57158626ee7638e7cc6266a878006b482254017d13788ce08cf310e'
4
+ data.tar.gz: a4ac76092f199b6f375c5331ebee107b61f76659a03d101d40c8647989599223
5
5
  SHA512:
6
- metadata.gz: d9eef4e808bc465c320e7738696a8a6e08f160db09835af6759e3a3ad0cf8788d041668b588be956f487e69c53baaf3398ffe36b239e9f69825729ee478c1469
7
- data.tar.gz: 24eef7efe179079b9f862022f827594038954c23f04b7ebf4da7322d5b07ddd77470e4f4de76e1536dcff6f3cb9f38d07e3cc325ae2d513eaf650f503bb16668
6
+ metadata.gz: 71d16dc1aabe0256baa77e107392b97a8e54a10f95859ef50067c7feb3c6004b24bc21cc4b33b87f54718123422d6fcf4c8d413f3b203e794adf566736a64491
7
+ data.tar.gz: 47d88afa02e2558b7de9b16446a18c0d64d80870fe1bb3f8daa20c5914d485c0dcc13352b2e0512e002d1e58fe0c62bfe783e776f0408c1c663b4e05df49ecd9
@@ -3,6 +3,7 @@
3
3
  require "erb"
4
4
  require "logger"
5
5
  require "optparse"
6
+ require "shellwords"
6
7
  require "yaml"
7
8
  require "hotdog/commands"
8
9
  require "hotdog/formatters"
@@ -94,14 +95,30 @@ module Hotdog
94
95
  args = @optparse.order(argv)
95
96
 
96
97
  begin
97
- @source_provider = get_source(@options[:source])
98
+ if Hash === @options[:source_alias]
99
+ source_name = @options[:source_alias].fetch(@options[:source], @options[:source])
100
+ else
101
+ source_name = @options[:source]
102
+ end
103
+ @source_provider = get_source(source_name)
98
104
  rescue NameError
99
- STDERR.puts("hotdog: '#{@options[:source]}' is not a valid hotdog source.")
105
+ STDERR.puts("hotdog: '#{source_name}' is not a valid hotdog source.")
100
106
  exit(1)
101
107
  end
102
108
 
103
109
  begin
104
- command_name = ( args.shift || "help" )
110
+ given_command_name = ( args.shift || "help" )
111
+ if Hash === @options[:command_alias]
112
+ command_alias = @options[:command_alias].fetch(given_command_name, given_command_name)
113
+ if Array === command_alias
114
+ command_name, *command_args = command_alias
115
+ else
116
+ command_name, *command_args = Shellwords.shellsplit(command_alias)
117
+ end
118
+ else
119
+ command_name = given_command_name
120
+ command_args = []
121
+ end
105
122
  begin
106
123
  command = get_command(command_name)
107
124
  rescue NameError
@@ -114,7 +131,7 @@ module Hotdog
114
131
  command.define_options(@optparse, @options)
115
132
 
116
133
  begin
117
- args = command.parse_options(@optparse, args)
134
+ args = command.parse_options(@optparse, command_args + args)
118
135
  rescue OptionParser::ParseError => error
119
136
  STDERR.puts("hotdog: #{error.message}")
120
137
  command.parse_options(@optparse, ["--help"])
@@ -125,7 +142,12 @@ module Hotdog
125
142
  options[:headers] = true
126
143
  end
127
144
 
128
- options[:formatter] = get_formatter(options[:format])
145
+ if Hash === @options[:format_alias]
146
+ format_name = @options[:format_alias].fetch(@options[:format], @options[:format])
147
+ else
148
+ format_name = @options[:format]
149
+ end
150
+ options[:formatter] = get_formatter(format_name)
129
151
 
130
152
  if ( options[:debug] or options[:verbose] ) and ( options[:verbosity] < VERBOSITY_DEBUG )
131
153
  options[:verbosity] = VERBOSITY_DEBUG
@@ -260,19 +282,13 @@ module Hotdog
260
282
  end
261
283
 
262
284
  def get_formatter(name)
263
- begin
264
- require "hotdog/formatters/#{name}"
265
- rescue LoadError => error
266
- @logger.info("failed to load library file: #{error}")
267
- end
268
285
  begin
269
286
  klass = Hotdog::Formatters.const_get(const_name(name))
270
287
  rescue NameError
271
- library = find_library("hotdog/formatters", name)
272
- if library
273
- load library
274
- klass = Hotdog::Formatters.const_get(const_name(File.basename(library, ".rb")))
275
- else
288
+ begin
289
+ require "hotdog/formatters/#{name}"
290
+ klass = Hotdog::Formatters.const_get(const_name(name))
291
+ rescue LoadError
276
292
  raise(NameError.new("unknown format: #{name}"))
277
293
  end
278
294
  end
@@ -280,19 +296,13 @@ module Hotdog
280
296
  end
281
297
 
282
298
  def get_command(name)
283
- begin
284
- require "hotdog/commands/#{name}"
285
- rescue LoadError => error
286
- @logger.info("failed to load library file: #{error}")
287
- end
288
299
  begin
289
300
  klass = Hotdog::Commands.const_get(const_name(name))
290
301
  rescue NameError
291
- library = find_library("hotdog/commands", name)
292
- if library
293
- load library
294
- klass = Hotdog::Commands.const_get(const_name(File.basename(library, ".rb")))
295
- else
302
+ begin
303
+ require "hotdog/commands/#{name}"
304
+ klass = Hotdog::Commands.const_get(const_name(name))
305
+ rescue LoadError
296
306
  raise(NameError.new("unknown command: #{name}"))
297
307
  end
298
308
  end
@@ -300,19 +310,13 @@ module Hotdog
300
310
  end
301
311
 
302
312
  def get_source(name)
303
- begin
304
- require "hotdog/sources/#{name}"
305
- rescue LoadError => error
306
- @logger.info("failed to load library file: #{error}")
307
- end
308
313
  begin
309
314
  klass = Hotdog::Sources.const_get(const_name(name))
310
315
  rescue NameError
311
- library = find_library("hotdog/sources", name)
312
- if library
313
- load library
314
- klass = Hotdog::Sources.const_get(const_name(File.basename(library, ".rb")))
315
- else
316
+ begin
317
+ require "hotdog/sources/#{name}"
318
+ klass = Hotdog::Sources.const_get(const_name(name))
319
+ rescue LoadError
316
320
  raise(NameError.new("unknown source: #{name}"))
317
321
  end
318
322
  end
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.36.0"
2
+ VERSION = "1.20190725.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.0
4
+ version: 1.20190725.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2019-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -227,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []
230
- rubyforge_project:
231
- rubygems_version: 2.7.6
230
+ rubygems_version: 3.0.3
232
231
  signing_key:
233
232
  specification_version: 4
234
233
  summary: Yet another command-line tool for Datadog