Module: RailsBase::Commands
- Extended by:
- CliActions
- Defined in:
- lib/rs-rails-base/commands.rb
Overview
This module provides commands implementation
Class Method Summary
collapse
Methods included from CliActions
ask_for_something, say_something
Class Method Details
.add_feature(feature) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rs-rails-base/commands.rb', line 23
def self.add_feature(feature)
if feature.nil?
else
feature_case(feature)
end
end
|
.clone_project(version, uri, to_folder) ⇒ Object
64
65
66
67
|
# File 'lib/rs-rails-base/commands.rb', line 64
def self.clone_project(version, uri, to_folder)
command = "git clone -b #{version.strip!} --depth 1 #{uri} #{to_folder} &> /dev/null 2>&1"
system(command)
end
|
74
75
76
77
78
79
|
# File 'lib/rs-rails-base/commands.rb', line 74
def self.
say_something('FEATURE OPTIONS:')
RailsBase::FEATURE_OPTIONS.merge(all: 'All').each_value do |feature|
say_something(" #{feature}")
end
end
|
.feature_case(feature) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/rs-rails-base/commands.rb', line 54
def self.manage_tags
filters = "awk '{print $2}'| cut -d '/' -f 3 | cut -d '^' -f 1 | uniq"
tags = "git ls-remote -t #{RailsBase::REMOTE_URI} | #{filters}"
reference_tag = RailsBase::API_BASE_VERSION
tag_numbers = reference_tag.split('.')
major = tag_numbers[0]
minor = tag_numbers[1]
`#{tags} | grep '#{major}.#{minor}.[0-9]' | tail -n 1 `
end
|
.new_project ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rs-rails-base/commands.rb', line 8
def self.new_project
say_something('Getting ready to get an amazing project')
answer = RailsBase::CliActions.ask_for_something('What would be the name for project folder?')
if Dir.exist?(answer)
say_something('Please dont use same project again and again')
else
final_version = manage_tags
RailsBase::GitActions.fetch_from_remote(final_version)
clone_project(final_version, RailsBase::REMOTE_URI, answer)
remove_git_configuration(answer)
end
FileUtils.cd("#{Dir.pwd}/#{answer}")
say_something('Download complete')
end
|
.remove_git_configuration(project_folder) ⇒ Object
69
70
71
72
|
# File 'lib/rs-rails-base/commands.rb', line 69
def self.remove_git_configuration(project_folder)
git_config = project_folder + '/.git'
FileUtils.rm_rf(git_config)
end
|