begin_cli 1.0.0 → 1.0.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
- SHA1:
3
- metadata.gz: e81ba548666c85ad86e52b27b0c559a683d1a2e9
4
- data.tar.gz: 3b7d6cc55d5e16ac49d99e9b0025d54538040202
2
+ SHA256:
3
+ metadata.gz: 0d55eb029e60b9bc2409c876faa09133e3aa0c63a2cfed11ef464456537830b3
4
+ data.tar.gz: 66fba39eaed04a7c0a161d31ba66c97b8fc3ad59872847a5c9c965953c0e5b1c
5
5
  SHA512:
6
- metadata.gz: 14951d1b81a107188e8f21bffc6b0f2733e815bd51da3b4332c67b76936c3ea687fec84f3e25c7e9ce5c03fd2629ae2056bf2fad64a9ed35233df0bf8ceb270b
7
- data.tar.gz: 4b0d650e1613e63af6815ba55d850b2f6069f7dd456c4c9a68d2028e7fd7962e3c7afefb737c30411ad034fddfc2888c76a95135bcd256b03e369a324f27979d
6
+ metadata.gz: 0a2c8ea6a573ff987d3673bb50e326e61b1c5c590394b34f06a44407f98ffbb076928a3e93f6b996a860963dae5588cb4f92f1cf9652bf062b18b81790aea8af
7
+ data.tar.gz: 06dacc90ad10e3864c84e003bcb1f09f55d407c4ed378cdac8f7109ddc0ae5716184633551512ca504d9353f4c7d12f5b8797f23b35cb4b18ac81d956f8bf25c
data/begin_cli.gemspec CHANGED
@@ -1,13 +1,13 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'begin/version'
6
6
 
7
- GEM_NAME = 'begin_cli'.freeze
7
+ GEM_NAME = 'begin_cli'
8
8
 
9
9
  SUMMARY = \
10
- 'A terminal command for running logic-less project templates.'.freeze
10
+ 'A terminal command for running logic-less project templates.'
11
11
 
12
12
  DESCRIPTION = \
13
13
  'A terminal command for running logic-less project templates. ' \
@@ -15,13 +15,14 @@ DESCRIPTION = \
15
15
  'are copied to the working directory when run. Directory names, ' \
16
16
  'file names, and file content can contain Mustache tags - the ' \
17
17
  'values of which are prompted for in the terminal and substituted ' \
18
- 'when the template is run.'.freeze
18
+ 'when the template is run.'
19
19
 
20
20
  Gem::Specification.new do |spec|
21
- spec.name = GEM_NAME
22
- spec.version = Begin::VERSION
23
- spec.authors = ['James Bird']
24
- spec.email = ['jbrd.git@outlook.com']
21
+ spec.name = GEM_NAME
22
+ spec.version = Begin::VERSION
23
+ spec.authors = ['James Bird']
24
+ spec.email = ['jbrd.git@outlook.com']
25
+ spec.required_ruby_version = '>= 2.4.0'
25
26
 
26
27
  spec.summary = SUMMARY
27
28
  spec.description = DESCRIPTION
@@ -29,12 +30,12 @@ Gem::Specification.new do |spec|
29
30
  spec.homepage = 'https://jbrd.github.io/begin'
30
31
  spec.license = 'MIT'
31
32
 
32
- spec.files = %w(begin_cli.gemspec) + Dir["*.md", "exe/*", "lib/**/*.rb"]
33
+ spec.files = %w[begin_cli.gemspec] + Dir['*.md', 'exe/*', 'lib/**/*.rb']
33
34
  spec.bindir = 'exe'
34
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
36
  spec.require_paths = ['lib']
36
37
 
37
- spec.add_development_dependency 'bundler', '~> 1.11'
38
+ spec.add_development_dependency 'bundler', '>= 2.2.33'
38
39
  spec.add_development_dependency 'rake', '~> 12.0'
39
40
  spec.add_development_dependency 'rspec', '~> 3.0'
40
41
  spec.add_development_dependency 'rubocop', '~> 0.49'
data/exe/begin CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'begin'
4
5
  require 'begin/output'
data/lib/begin/cli.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'begin/input'
2
4
  require 'begin/output'
3
5
  require 'begin/repository'
@@ -13,11 +15,11 @@ module Begin
13
15
  'Instead, take them from given YAML file.'
14
16
  def new(template)
15
17
  template_impl = repository.template template
16
- if options[:yaml]
17
- context = YAML.load_file(options[:yaml])
18
- else
19
- context = Input.prompt_user_for_tag_values(template_impl.config.tags)
20
- end
18
+ context = if options[:yaml]
19
+ YAML.load_file(options[:yaml])
20
+ else
21
+ Input.prompt_user_for_tag_values(template_impl.config.tags)
22
+ end
21
23
  Output.action "Running template '#{template}'"
22
24
  template_impl.run Dir.getwd, context
23
25
  Output.success "Template '#{template}' successfully run"
data/lib/begin/config.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  module Begin
@@ -43,6 +45,7 @@ module Begin
43
45
 
44
46
  def self.from_config(key, value)
45
47
  return HashTag.from_config(key, value) if value.include? 'tags'
48
+
46
49
  ValueTag.from_config(key, value)
47
50
  end
48
51
  end
@@ -82,9 +85,11 @@ module Begin
82
85
 
83
86
  def self.from_config_hash(config)
84
87
  return [] unless config.include?('tags') && config['tags'].is_a?(Hash)
88
+
85
89
  config['tags'].each.map do |key, value|
86
90
  raise "Invalid template. Expected value of '#{key}' to be a Hash" \
87
91
  unless value.is_a? Hash
92
+
88
93
  Tag.from_config key, value
89
94
  end
90
95
  end
data/lib/begin/input.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Begin
2
4
  # All console input is routed through this module
3
5
  module Input
@@ -8,7 +10,8 @@ module Begin
8
10
  begin
9
11
  value = STDIN.gets
10
12
  raise EOFError if value.nil?
11
- return value.chomp
13
+
14
+ value.chomp
12
15
  rescue StandardError, Interrupt
13
16
  Output.newline
14
17
  raise
data/lib/begin/output.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'colorize'
2
4
 
3
5
  module Begin
@@ -7,7 +9,7 @@ module Begin
7
9
  module_function
8
10
 
9
11
  def error(value)
10
- STDERR.puts "ERROR: #{value}".colorize :red
12
+ warn "ERROR: #{value}".colorize :red
11
13
  end
12
14
 
13
15
  def warning(value)
data/lib/begin/path.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Begin
2
4
  # The canonical file path representation used throughout the application.
3
5
  # Paths are immediately expanded into absolute file paths on construction
@@ -25,18 +27,21 @@ module Begin
25
27
 
26
28
  def ensure_exists
27
29
  return if File.exist? @path
30
+
28
31
  raise IOError, "#{@help} '#{@path}' does not exist"
29
32
  end
30
33
 
31
34
  def ensure_symlink_exists
32
35
  ensure_exists
33
36
  return if File.symlink? @path
37
+
34
38
  raise IOError, "#{@help} '#{@path}' is not a symbolic link"
35
39
  end
36
40
 
37
41
  def ensure_dir_exists
38
42
  ensure_exists
39
43
  return if directory?
44
+
40
45
  raise IOError, "#{@help} '#{@path}' is not a directory"
41
46
  end
42
47
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'begin/output'
2
4
  require 'begin/path'
3
5
  require 'begin/template'
@@ -18,11 +20,10 @@ module Begin
18
20
  def install(source_uri, name)
19
21
  path = install_prerequisites(name)
20
22
  begin
21
- return GitTemplate.install source_uri, path
22
- rescue
23
- unless source_uri.include? '://'
24
- return SymlinkTemplate.install source_uri, path
25
- end
23
+ GitTemplate.install source_uri, path
24
+ rescue StandardError
25
+ return SymlinkTemplate.install source_uri, path unless source_uri.include? '://'
26
+
26
27
  raise
27
28
  end
28
29
  end
@@ -32,6 +33,7 @@ module Begin
32
33
  @template_dir.make_dir
33
34
  path = template_path name
34
35
  raise "A template is already installed at: #{path}" if path.exists?
36
+
35
37
  Output.info "Installing to '#{path}'"
36
38
  path
37
39
  end
@@ -62,6 +64,7 @@ module Begin
62
64
 
63
65
  def template_from_path(path)
64
66
  return SymlinkTemplate.new(path) if File.symlink? path
67
+
65
68
  GitTemplate.new path
66
69
  end
67
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'begin/config'
2
4
  require 'begin/output'
3
5
  require 'begin/path'
@@ -9,7 +11,7 @@ require 'uri'
9
11
  module Begin
10
12
  # Represents an installed template on the user's machine.
11
13
  class Template
12
- CONFIG_NAME = '.begin.yml'.freeze
14
+ CONFIG_NAME = '.begin.yml'
13
15
 
14
16
  def initialize(path)
15
17
  @path = path
@@ -43,6 +45,7 @@ module Begin
43
45
 
44
46
  def ensure_no_back_references(source_path, expanded_path, target_dir)
45
47
  return if target_dir.contains? expanded_path
48
+
46
49
  err = 'Backward-reference detected in expanded ' \
47
50
  "template path. Details to follow.\n"
48
51
  err += "Source Path: #{source_path}\n"
@@ -53,6 +56,7 @@ module Begin
53
56
 
54
57
  def ensure_no_conflicts(paths, source_path, target_path)
55
58
  return unless paths.key? target_path
59
+
56
60
  err = "File path collision detected. Details to follow.\n"
57
61
  err += "(1) Source File: #{source_path}\n"
58
62
  err += "(1) ..Writes To: #{target_path}\n"
@@ -63,6 +67,7 @@ module Begin
63
67
 
64
68
  def ensure_name_not_empty(source_path, expanded_name)
65
69
  return unless expanded_name.empty?
70
+
66
71
  err = "Mustache evaluation resulted in an empty file name...\n"
67
72
  err += "... whilst evaluating: #{source_path}"
68
73
  raise err
@@ -150,8 +155,8 @@ module Begin
150
155
  @repository = Git.open(path.to_s)
151
156
  end
152
157
 
153
- def self.format_git_error_message(e)
154
- partition = e.message.partition('2>&1:')
158
+ def self.format_git_error_message(err)
159
+ partition = err.message.partition('2>&1:')
155
160
  partition[2]
156
161
  end
157
162
 
@@ -180,7 +185,7 @@ module Begin
180
185
 
181
186
  def check_tracking_branch
182
187
  @repository.revparse('@{u}')
183
- rescue
188
+ rescue StandardError
184
189
  raise "Local branch '#{@repository.current_branch}' does not track " \
185
190
  "an upstream branch in local repository: #{@path}"
186
191
  end
data/lib/begin/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Begin
2
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.0.1'
3
5
  end
data/lib/begin.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'begin/cli'
2
4
  require 'begin/version'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: begin_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bird
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-17 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: 2.2.33
20
20
  type: :development
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: '1.11'
26
+ version: 2.2.33
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -161,15 +161,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
- version: '0'
164
+ version: 2.4.0
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.4.6
171
+ rubygems_version: 3.1.2
173
172
  signing_key:
174
173
  specification_version: 4
175
174
  summary: A terminal command for running logic-less project templates.