rigit 0.1.7 → 0.1.8

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: dd2a2c78d7c9698965042e42736818edfbf35b015ee4e5f76fbf410dd0c6d4e4
4
- data.tar.gz: c88d8463c4992fc279cf579a0cc1422f71ebd875e58631e25d940991d88a0708
3
+ metadata.gz: ae750bc5a6bcd7579e93397d0f493ba6c97f6fe7113f3300e4140889bdcf50ea
4
+ data.tar.gz: 38d60e9d8e133bc5eaeaa88c1f3d66df767f1ce810cb1e840dd209a148846d13
5
5
  SHA512:
6
- metadata.gz: 766579f3d737a555cc26a8e4f47f9480f969d0938f15d8f94d6582f1b66d8cbc3fe2dd82a1dafa193c19ebdd1591a45a18768db9ba8bb0fc96bed170b184917b
7
- data.tar.gz: fd7b722589b4b7f46cb25d414b75f939ed316288cb3a37f258391e5a692893694f087d95af782152241770afe53fa0a9e18d034437a30299b232a88b3f05546f
6
+ metadata.gz: 989498761d02c5066f1b897110bf30956991fbe5c3405add7af598bf325e12c885de0b63f80094c53c3ad689c588449bc03f8024c0e6cc1ca5e9ff7adfcf8786
7
+ data.tar.gz: 6c86d9888bbe5c16da0c167bfc46b228dd1f28bb070a16b2e688f1cd56c56ee62b19d05b728279e1b43389782a78192850fe2f48bde9ca09168ca324706df5aa
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  Rigit
2
2
  ==================================================
3
3
 
4
- [![Gem](https://img.shields.io/gem/v/rigit.svg?style=flat-square)](https://rubygems.org/gems/rigit)
5
- [![Build](https://img.shields.io/travis/DannyBen/rigit.svg?style=flat-square)](https://travis-ci.org/DannyBen/rigit)
6
- [![Maintainability](https://img.shields.io/codeclimate/maintainability/DannyBen/rigit.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/rigit)
7
- [![Issues](https://img.shields.io/codeclimate/issues/github/DannyBen/rigit.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/rigit)
4
+ [![Gem Version](https://badge.fury.io/rb/rigit.svg)](https://badge.fury.io/rb/rigit)
5
+ [![Build Status](https://travis-ci.com/DannyBen/rigit.svg?branch=master)](https://travis-ci.com/DannyBen/rigit)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d13abbe6f7601be78cf5/maintainability)](https://codeclimate.com/github/DannyBen/rigit/maintainability)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d13abbe6f7601be78cf5/test_coverage)](https://codeclimate.com/github/DannyBen/rigit/test_coverage)
8
8
 
9
9
  ---
10
10
 
@@ -375,3 +375,4 @@ params:
375
375
  [colsole-colors]: https://github.com/dannyben/colsole#color-codes
376
376
  [colsole]: https://github.com/dannyben/colsole
377
377
 
378
+
@@ -7,6 +7,8 @@ require 'rigit/rig'
7
7
  require 'rigit/git'
8
8
  require 'rigit/command_line'
9
9
 
10
+ require 'byebug' if ENV['BYEBUG']
11
+
10
12
  module Rigit
11
13
  module Commands
12
14
  end
@@ -138,9 +138,26 @@ module Rigit::Commands
138
138
  return if Dir.empty?(target_dir) or force
139
139
 
140
140
  dirstring = target_dir == '.' ? 'Current directory' : "Directory '#{target_dir}'"
141
- continue = tty_prompt.yes? "#{dirstring} is not empty. Continue anyway?", default: false
142
- raise Rigit::Exit, "Goodbye" unless continue
141
+ options = { "Abort" => :abort, "Continue here" => :continue, "Continue in a sub directory" => :create }
142
+ response = tty_prompt.select "#{dirstring} is not empty.", options, marker: '>'
143
+
144
+ case response
145
+ when :abort
146
+ raise Rigit::Exit, "Goodbye"
147
+
148
+ when :create
149
+ create_subdir
150
+ verify_target_dir
151
+ end
143
152
  end
153
+
154
+ def create_subdir
155
+ folder = tty_prompt.ask "Sub directory to create:", default: 'app'
156
+ @target_dir = "#{target_dir}/#{folder}"
157
+ Dir.mkdir target_dir unless Dir.exist? target_dir
158
+ say "Creating in #{target_dir}"
159
+ end
160
+
144
161
  end
145
162
  end
146
163
  end
@@ -85,18 +85,23 @@ module Rigit
85
85
  files.reject! { |file| File.directory? file }
86
86
 
87
87
  files.each do |file|
88
- target_file = (file % arguments).sub dir, target_dir
89
-
88
+ target_file = get_target_filename file, arguments, target_dir, dir
90
89
  next if block_given? and !yield target_file
91
-
92
- begin
93
- content = File.read(file) % arguments
94
- rescue ArgumentError => e
95
- raise TemplateError.new file, e.message
96
- end
97
-
90
+ content = get_file_content file, arguments
98
91
  File.deep_write target_file, content
99
92
  end
100
93
  end
94
+
95
+ def get_target_filename(file, arguments, target_dir, source_dir)
96
+ (file % arguments).sub source_dir, target_dir
97
+ rescue KeyError => e
98
+ raise TemplateError.new file, e.message
99
+ end
100
+
101
+ def get_file_content(file, arguments)
102
+ File.read(file) % arguments
103
+ rescue ArgumentError, KeyError => e
104
+ raise TemplateError.new file, e.message
105
+ end
101
106
  end
102
107
  end
@@ -1,3 +1,3 @@
1
1
  module Rigit
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rigit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: super_docopt