confc 0.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +32 -0
- data/bin/confc +5 -0
- data/confc.gemspec +32 -0
- data/files.yaml +8 -0
- data/lib/confc/cli.rb +81 -0
- data/lib/confc/conf_clone.rb +19 -0
- data/lib/confc/copy.rb +27 -0
- data/lib/confc/display_verbose.rb +17 -0
- data/lib/confc/files.rb +16 -0
- data/lib/confc/gethome.rb +9 -0
- data/lib/confc/to_filenames.rb +15 -0
- data/lib/confc/version.rb +3 -0
- data/lib/confc.rb +7 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 873beac706039c29977ef938c5ff8eb7feb8c0f8b06b6efb1d97c852bf47af39
|
4
|
+
data.tar.gz: 1418947b3de04db1a966309e33502e7a8948f97d1deecbaeef60db6704849642
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a6b944fd9a5d9f1d8ff557604a9ae86e818d2d032d73e6ffa78aa207da82d6c207b1365ab0e56f885ec88e1faff8e707cdd3348ddce7590a6f749514e1f7448
|
7
|
+
data.tar.gz: aa149ab5f16cc2e0d059683ae1c972a0440a3d183cb48af3ac03eebab838dd7bf81e204591b4709663ea45754309169a28703e3e6ded8e7cb469a1d0d221aefc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Saran Tanpituckpong
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# ConfC
|
2
|
+
[](./LICENSE)
|
3
|
+
[](https://rubygems.org/gems/confc)
|
4
|
+
[](https://rubygems.org/gems/confc)
|
5
|
+
[](https://travis-ci.org/gluons/ConfC.gem)
|
6
|
+
|
7
|
+
**Config Clone** — 🆕 Start new project with your default configs.
|
8
|
+
|
9
|
+
Clone your default configuration files to current working directory.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```bash
|
14
|
+
gem install confc
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```
|
20
|
+
Usage: confc [options] [filenames...]
|
21
|
+
|
22
|
+
Clone your default configuration files to current working directory.
|
23
|
+
-f, --overwrite Force to overwrite
|
24
|
+
-p, --path [PATH] Path to configuration files
|
25
|
+
-v, --verbose Display more information
|
26
|
+
-V, --version Show version number
|
27
|
+
-h, --help Show help
|
28
|
+
```
|
29
|
+
|
30
|
+
## Related
|
31
|
+
|
32
|
+
- [ConfC](https://github.com/gluons/ConfC) - 🆕 Start new project with your default configs. (Node.js version)
|
data/bin/confc
ADDED
data/confc.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path('./lib', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
$LOAD_PATH.push lib unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'confc/version'
|
6
|
+
|
7
|
+
DESCRIPTION =
|
8
|
+
'Clone your default configuration files to current working directory.'.freeze
|
9
|
+
|
10
|
+
Gem::Specification.new do |s|
|
11
|
+
s.name = 'confc'
|
12
|
+
s.version = ConfC::VERSION
|
13
|
+
s.summary = 'Start new project with your default configs.'
|
14
|
+
s.description = DESCRIPTION
|
15
|
+
s.files = ['confc.gemspec', 'LICENSE', 'Gemfile', 'files.yaml']
|
16
|
+
s.files += Dir['*.md', 'bin/*', 'lib/**/*']
|
17
|
+
s.executables = ['confc']
|
18
|
+
s.required_ruby_version = '>= 2.1.0'
|
19
|
+
s.author = 'Saran Tanpituckpong'
|
20
|
+
s.license = 'MIT'
|
21
|
+
s.homepage = 'https://github.com/gluons/ConfC.gem'
|
22
|
+
s.metadata = {
|
23
|
+
'bug_tracker_uri' => 'https://github.com/gluons/ConfC.gem/issues'
|
24
|
+
}
|
25
|
+
|
26
|
+
s.add_runtime_dependency 'rainbow', '~> 2.2', '>= 2.2.2'
|
27
|
+
|
28
|
+
s.add_development_dependency 'aruba', '~> 0.14.3'
|
29
|
+
s.add_development_dependency 'rake', '~> 12.3'
|
30
|
+
s.add_development_dependency 'rspec', '~> 3.7'
|
31
|
+
s.add_development_dependency 'rubocop', '~> 0.51.0'
|
32
|
+
end
|
data/files.yaml
ADDED
data/lib/confc/cli.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'rainbow'
|
3
|
+
|
4
|
+
require_relative 'conf_clone'
|
5
|
+
require_relative 'files'
|
6
|
+
require_relative 'gethome'
|
7
|
+
require_relative 'to_filenames'
|
8
|
+
require_relative 'version'
|
9
|
+
|
10
|
+
# rubocop:disable Layout/IndentHeredoc
|
11
|
+
BANNER = <<-BANNER.freeze
|
12
|
+
Usage: #{Rainbow('confc').green} [options] [filenames...]
|
13
|
+
|
14
|
+
Clone your default configuration files to current working directory.
|
15
|
+
BANNER
|
16
|
+
# rubocop:enable Layout/IndentHeredoc
|
17
|
+
|
18
|
+
DEFAULT_OPTIONS = {
|
19
|
+
files: ConfC.files,
|
20
|
+
path: ConfC.gethome,
|
21
|
+
overwrite: false,
|
22
|
+
verbose: false
|
23
|
+
}.freeze
|
24
|
+
|
25
|
+
AWW = '(。◕‿◕。)'.freeze
|
26
|
+
|
27
|
+
##
|
28
|
+
# ConfC
|
29
|
+
module ConfC
|
30
|
+
##
|
31
|
+
# ConfC's CLI class.
|
32
|
+
class CLI
|
33
|
+
##
|
34
|
+
# Start CLI.
|
35
|
+
def self.start(argv)
|
36
|
+
options = CLI.parse(argv)
|
37
|
+
files = options[:files]
|
38
|
+
|
39
|
+
confc_options = {
|
40
|
+
verbose: options[:verbose],
|
41
|
+
overwrite: options[:overwrite]
|
42
|
+
}
|
43
|
+
confc_result = ConfC.conf_clone(files, options[:path], confc_options)
|
44
|
+
puts Rainbow("ConfC completed. #{AWW}").green if confc_result
|
45
|
+
end
|
46
|
+
|
47
|
+
# rubocop:disable Metrics/MethodLength, Metrics/LineLength, Metrics/AbcSize
|
48
|
+
##
|
49
|
+
# Parse CLI ARGV.
|
50
|
+
def self.parse(argv)
|
51
|
+
options = DEFAULT_OPTIONS.dup
|
52
|
+
|
53
|
+
parser = OptionParser.new do |opts|
|
54
|
+
opts.banner = BANNER
|
55
|
+
|
56
|
+
opts.on('-f', '--overwrite', 'Force to overwrite') do
|
57
|
+
options[:overwrite] = true
|
58
|
+
end
|
59
|
+
opts.on('-p', '--path [PATH]', String, 'Path to configuration files') do |p|
|
60
|
+
options[:path] = p
|
61
|
+
end
|
62
|
+
opts.on('-v', '--verbose', 'Display more information') do
|
63
|
+
options[:verbose] = true
|
64
|
+
end
|
65
|
+
opts.on('-V', '--version', 'Show version number') do
|
66
|
+
puts "v#{ConfC::VERSION}"
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
opts.on('-h', '--help', 'Show help') do
|
70
|
+
puts opts
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
end
|
74
|
+
files = parser.parse(argv)
|
75
|
+
options[:files] = ConfC.to_filenames(files) if files.is_a?(Array) && !files.empty?
|
76
|
+
|
77
|
+
options
|
78
|
+
end
|
79
|
+
# rubocop:enable Metrics/MethodLength, Metrics/LineLength, Metrics/AbcSize
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'copy'
|
2
|
+
|
3
|
+
##
|
4
|
+
# ConfC
|
5
|
+
module ConfC
|
6
|
+
##
|
7
|
+
# Clone given files from given path to current working directory.
|
8
|
+
def self.conf_clone(
|
9
|
+
files,
|
10
|
+
path,
|
11
|
+
options = { verbose: false, overwrite: false }
|
12
|
+
)
|
13
|
+
results = files.map do |file|
|
14
|
+
src = File.expand_path(file, path)
|
15
|
+
ConfC.copy(src, options)
|
16
|
+
end
|
17
|
+
results.any? { |result| result } # Return true if any process succeed
|
18
|
+
end
|
19
|
+
end
|
data/lib/confc/copy.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
require_relative 'display_verbose'
|
4
|
+
require_relative 'gethome'
|
5
|
+
|
6
|
+
##
|
7
|
+
# ConfC
|
8
|
+
module ConfC
|
9
|
+
##
|
10
|
+
# Copy given file to current working directory.
|
11
|
+
def self.copy(src, options = { verbose: false, overwrite: false })
|
12
|
+
return false unless File.exist?(src) # Stop if no src file
|
13
|
+
|
14
|
+
# Stop if dest file exists & prevent overwriting
|
15
|
+
src_filename = File.basename(src)
|
16
|
+
dest_path = File.expand_path(src_filename, Dir.pwd)
|
17
|
+
return false if File.exist?(dest_path) && !options[:overwrite]
|
18
|
+
|
19
|
+
FileUtils.copy(src, Dir.pwd)
|
20
|
+
|
21
|
+
# Display verbose
|
22
|
+
dest = File.expand_path(src_filename, Dir.pwd)
|
23
|
+
ConfC.display_verbose(src, dest) if options[:verbose]
|
24
|
+
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
|
3
|
+
##
|
4
|
+
# ConfC
|
5
|
+
module ConfC
|
6
|
+
##
|
7
|
+
# Display verbose information.
|
8
|
+
def self.display_verbose(src, dest)
|
9
|
+
verbose = Rainbow('Copied "').green
|
10
|
+
verbose += Rainbow(src).cyan
|
11
|
+
verbose += Rainbow('" to "').green
|
12
|
+
verbose += Rainbow(dest).cyan
|
13
|
+
verbose += Rainbow('".').green
|
14
|
+
|
15
|
+
puts verbose
|
16
|
+
end
|
17
|
+
end
|
data/lib/confc/files.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
##
|
4
|
+
# ConfC
|
5
|
+
module ConfC
|
6
|
+
##
|
7
|
+
# Get list of file to be copied.
|
8
|
+
def self.files
|
9
|
+
files_path = File.expand_path('../../files.yaml', File.dirname(__FILE__))
|
10
|
+
if File.exist?(files_path)
|
11
|
+
YAML.load_file(files_path)
|
12
|
+
else
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
##
|
2
|
+
# ConfC
|
3
|
+
module ConfC
|
4
|
+
##
|
5
|
+
# Convert all raw file names to base file names.
|
6
|
+
def self.to_filenames(raw_filenames)
|
7
|
+
if raw_filenames.is_a?(Array) && !raw_filenames.empty?
|
8
|
+
raw_filenames.map do |raw_filename|
|
9
|
+
File.basename raw_filename
|
10
|
+
end
|
11
|
+
else
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/confc.rb
ADDED
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: confc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Saran Tanpituckpong
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rainbow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.2.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: aruba
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.14.3
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.14.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '12.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '12.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.7'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.7'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.51.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.51.0
|
89
|
+
description: Clone your default configuration files to current working directory.
|
90
|
+
email:
|
91
|
+
executables:
|
92
|
+
- confc
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- bin/confc
|
100
|
+
- confc.gemspec
|
101
|
+
- files.yaml
|
102
|
+
- lib/confc.rb
|
103
|
+
- lib/confc/cli.rb
|
104
|
+
- lib/confc/conf_clone.rb
|
105
|
+
- lib/confc/copy.rb
|
106
|
+
- lib/confc/display_verbose.rb
|
107
|
+
- lib/confc/files.rb
|
108
|
+
- lib/confc/gethome.rb
|
109
|
+
- lib/confc/to_filenames.rb
|
110
|
+
- lib/confc/version.rb
|
111
|
+
homepage: https://github.com/gluons/ConfC.gem
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata:
|
115
|
+
bug_tracker_uri: https://github.com/gluons/ConfC.gem/issues
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.1.0
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.7.3
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Start new project with your default configs.
|
136
|
+
test_files: []
|