iamsellek_cl_helper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +21 -0
- data/Rakefile.rb +2 -0
- data/bin/iamsellek_cl_helper +0 -0
- data/iamsellek_cl_helper.gemspec +26 -0
- data/lib/iamsellek_cl_helper/version.rb +3 -0
- data/lib/iamsellek_cl_helper.rb +79 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a345889747f0da1b91723a4604d3c65d50be72dc
|
4
|
+
data.tar.gz: 3cd9b058984092ace4c8dcd95a68e5ff612fe2a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f892288d33c10240a14e38ccd9214ac40684bf8948543981629475ee58493090337a033b487cac43e8cd302517367ac1ed589f8d0ba3ed7fa1ebc5ce1ab1f045
|
7
|
+
data.tar.gz: 94172873a8463cd4a3a626b98fcd69ad068f4d7528bde3935bf56ea1c97bac0efd36f62a6ba2d5251ec2e6df48e1f33b7ed892f5d294ade303f22a5776112ce5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.2.1)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
gemspec (0.3.1)
|
11
|
+
activesupport (= 4.2.1)
|
12
|
+
memoist (= 0.12.0)
|
13
|
+
rake (~> 10.4)
|
14
|
+
i18n (0.7.0)
|
15
|
+
json (1.8.6)
|
16
|
+
memoist (0.12.0)
|
17
|
+
minitest (5.10.1)
|
18
|
+
rainbow (2.1.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
thread_safe (0.3.5)
|
21
|
+
tzinfo (1.2.2)
|
22
|
+
thread_safe (~> 0.1)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
gemspec
|
29
|
+
rainbow (~> 2.1.0)
|
30
|
+
|
31
|
+
BUNDLED WITH
|
32
|
+
1.13.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 iamsellek
|
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/Rakefile.rb
ADDED
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'iamsellek_cl_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'iamsellek_cl_helper'
|
8
|
+
spec.version = IamsellekClHelper::VERSION
|
9
|
+
spec.authors = ['Chris Sellek']
|
10
|
+
spec.email = ['iamsellek@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Common/helper methods for my command-line apps.'
|
13
|
+
spec.description = 'None.'
|
14
|
+
spec.homepage = 'https://github.com/iamsellek/iamsellek_cl_helper'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = ['iamsellek_cl_helper']
|
19
|
+
spec.test_files = []
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'rainbow'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module IamsellekClHelper
|
2
|
+
# Attempt to restore settings from previous version.
|
3
|
+
def restore_settings(gem_name, version)
|
4
|
+
lines_pretty_print "I see that you have a previous #{gem_name} installation on this machine."
|
5
|
+
lines_pretty_print Rainbow('Would you like to restore its settings?').yellow
|
6
|
+
|
7
|
+
answered = false
|
8
|
+
|
9
|
+
until answered
|
10
|
+
answer = STDIN.gets.strip!
|
11
|
+
|
12
|
+
single_space
|
13
|
+
|
14
|
+
if answer == 'yes' || answer == 'y' || answer == 'no' || answer == 'n'
|
15
|
+
answered = true
|
16
|
+
else
|
17
|
+
lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
return if answer == 'no' || answer == 'n'
|
22
|
+
|
23
|
+
lines_pretty_print 'One moment, please.'
|
24
|
+
|
25
|
+
single_space
|
26
|
+
|
27
|
+
all_gems = Dir.glob("#{@app_directory.chomp("/#{gem_name}-#{version}")}/#{gem_name}*")
|
28
|
+
|
29
|
+
# glob orders things in the array alphabetically, so the second-to-last one in the array is the
|
30
|
+
# most recent version that is not the current version.
|
31
|
+
previous_config_file = "#{all_gems[-2]}/lib/config.yaml"
|
32
|
+
config = YAML.load_file(previous_config_file)
|
33
|
+
new_config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
|
34
|
+
|
35
|
+
YAML.dump(config, new_config_file)
|
36
|
+
new_config_file.close
|
37
|
+
|
38
|
+
lines_pretty_print 'Done! Please run me again when you\'re ready.'
|
39
|
+
|
40
|
+
abort
|
41
|
+
end
|
42
|
+
|
43
|
+
def second_argument_missing?(arguments)
|
44
|
+
arguments[1].nil? || arguments[1] == ''
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete_arguments(arguments, number_to_delete)
|
48
|
+
(1..number_to_delete).each do
|
49
|
+
# Deleting the first one each time because the array shifts left when one is deleted.
|
50
|
+
arguments.delete_at(0)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def bash(directory, command)
|
55
|
+
# Dir.chdir ensures all bash commands are being run from the correct
|
56
|
+
# directory.
|
57
|
+
Dir.chdir(directory) { system "#{command}" }
|
58
|
+
end
|
59
|
+
|
60
|
+
def lines_pretty_print(string)
|
61
|
+
lines = string.scan(/\S.{0,70}\S(?=\s|$)|\S+/)
|
62
|
+
|
63
|
+
lines.each { |line| puts line }
|
64
|
+
end
|
65
|
+
|
66
|
+
def single_space
|
67
|
+
puts ''
|
68
|
+
end
|
69
|
+
|
70
|
+
def double_space
|
71
|
+
puts "\n\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
def surround_by_double_space(string)
|
75
|
+
double_space
|
76
|
+
lines_pretty_print(string)
|
77
|
+
double_space
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iamsellek_cl_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Sellek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-16 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: None.
|
56
|
+
email:
|
57
|
+
- iamsellek@gmail.com
|
58
|
+
executables:
|
59
|
+
- iamsellek_cl_helper
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- Rakefile.rb
|
68
|
+
- bin/iamsellek_cl_helper
|
69
|
+
- iamsellek_cl_helper.gemspec
|
70
|
+
- lib/iamsellek_cl_helper.rb
|
71
|
+
- lib/iamsellek_cl_helper/version.rb
|
72
|
+
homepage: https://github.com/iamsellek/iamsellek_cl_helper
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Common/helper methods for my command-line apps.
|
96
|
+
test_files: []
|