pupistry 0.0.6 → 0.0.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/pupistry +80 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b79b3dc39752440bd81aafabb9dd460c550ddf86
4
- data.tar.gz: f7307271db6cde5388db0c241fa220c44f60659b
3
+ metadata.gz: a2438d4ff627cb0c9719ae22d33a026833365769
4
+ data.tar.gz: ac00b03d3b81ad8bcac5f45d6d3bbc01fcfae733
5
5
  SHA512:
6
- metadata.gz: f0d8168a17152895c342e4bca7e0b9b80111b1e32437abb6457666951fbc8f716734b8cea7b24ee6773a056aadd1827b4fcdae11c0f238e8a6df487d7ecbacae
7
- data.tar.gz: 06ffa5171f0f98d60f83d8505594db730f18e52d2b24687b02347783c4f885e426dc09939c3fe359ff73fcd436777967eb90e2238bd9de459362a07997fb1198
6
+ metadata.gz: 91bcf3aecc457d6794b9b3f1c52cec5551ac185d8c69e84d295c38a4b0565a91b810601e121159e9476a16009b16bbf3f7969a84ee79b990a9fef878fcb47594
7
+ data.tar.gz: c42a271c5b29e972b1295f9e4891332472340065a14b9327d70670e31be3fba08463c78b6cfebcf73d8818fa23b3ccae3f153c995659dd109c12698acdc4093b
@@ -4,6 +4,7 @@
4
4
  require 'rubygems'
5
5
  require 'thor'
6
6
  require 'logger'
7
+ require 'fileutils'
7
8
  require 'pupistry'
8
9
 
9
10
  # Ensure all output is real time - this is a long running process with
@@ -305,6 +306,85 @@ class CLI < Thor
305
306
  end
306
307
 
307
308
  end
309
+
310
+
311
+ ## Other Commands
312
+
313
+ desc "setup", "Write a template configuration file"
314
+ method_option :force, :type => :boolean, :desc => "Replace an existing config file"
315
+ def setup
316
+
317
+ # Thor seems to force class options to be defined repeatedly? :-/
318
+ if options[:verbose]
319
+ $logger.level = Logger::DEBUG
320
+ else
321
+ $logger.level = Logger::INFO
322
+ end
323
+
324
+
325
+ # Generally we should put the Pupistry configuration into the home dir, a
326
+ # developer who wants it elsewhere will be capable of figuring out how to
327
+ # install themselves.
328
+ config_dest = "~/.pupistry/settings.yaml"
329
+
330
+ # If the HOME environmental hasn't been set, dump the config into CWD.
331
+ unless ENV['HOME']
332
+ config_dest = "#{Dir.pwd}/settings.yaml"
333
+ $logger.warn "HOME is not set, so writing configuration file into #{config_dest}"
334
+ end
335
+
336
+ config_dest = File.expand_path config_dest
337
+
338
+
339
+ # Does a local template exist?
340
+ if File.exists?("#{Dir.pwd}/settings.example.yaml")
341
+ config_source = "#{Dir.pwd}/settings.example.yaml"
342
+ else
343
+ # Check for GEM installed location
344
+ begin
345
+ config_source = Gem::Specification.find_by_name("pupistry").gem_dir
346
+ config_source = "#{config_source}/settings.example.yaml"
347
+ rescue Gem::LoadError
348
+ # Yeah I dunno what you're doing...
349
+ $logger.error "Unable to find settings.example.yaml, seems we are not running as a Gem nor in the CWD of the app source"
350
+ exit 0
351
+ end
352
+ end
353
+
354
+ unless File.exists?(config_source)
355
+ $logger.error "Template configuration should exist in #{config_source} but no file found/readable!"
356
+ exit 0
357
+ end
358
+
359
+ # Prevent Overwrite
360
+ if File.exists?(config_dest)
361
+ unless options[:force]
362
+ $logger.error "Configuration file #{config_dest} already exists, if you wish to replace it please call with --force"
363
+ exit 0
364
+ else
365
+ $logger.warn "Overwriting #{config_dest}..."
366
+ end
367
+ end
368
+
369
+ # Copy the template configuration file to destination
370
+ begin
371
+ FileUtils.cp config_source, config_dest
372
+
373
+ $logger.info "Successfully installed configuration file into #{config_dest}"
374
+ rescue Exception => e
375
+ $logger.error "An unexpected error occured when copying #{config_source} to #{config_dest}"
376
+ raise e
377
+ end
378
+
379
+ # Tell the user to edit it
380
+ if ENV['EDITOR']
381
+ $logger.info "Now open the config file with `#{ENV['EDITOR']} #{config_dest}` and set your configuration values before running Pupistry."
382
+ else
383
+ $logger.info "You now need to edit #{config_dest} with your configuration values before running Pupistry."
384
+ end
385
+
386
+ end
387
+
308
388
  end
309
389
 
310
390
  CLI.start(ARGV)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pupistry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jethro Carr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-18 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1