-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_project.rb
More file actions
74 lines (61 loc) · 1.23 KB
/
make_project.rb
File metadata and controls
74 lines (61 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def input_check
abort('mkdir: missing input') if ARGV.empty?
end
def folder_name
ARGV.first
end
def source
["source 'https://rubygems.org'", "ruby '2.7.4'"]
end
def gems
["gem 'bundler'", "gem 'rspec'", "gem 'rubocop'", "gem 'rubocop-rspec'", "gem 'solargraph'"]
end
def extra_gems
ARGV[1..].map { |gem| "gem '#{gem}'" }
end
def gemfile
all_gems = []
gems.map { |gem| all_gems << gem }
extra_gems.map { |extra| all_gems << extra }
[source, all_gems.sort].join("\n")
end
def create_folder(name)
Dir.mkdir(name)
end
def change_folder(name)
Dir.chdir(name)
end
def create_gemfile
system('touch Gemfile')
File.write('Gemfile', gemfile)
end
def app
app = []
app << "require 'bundler'"
app << 'Bundler.require'
app << ''
app << "$LOAD_PATH.unshift File.expand_path('lib', __dir__)"
app.join("\n")
end
def create_app
system('touch app.rb')
File.write('app.rb', app)
end
def system_commands
system('rspec --init')
system('bundle install')
system('git init')
system('git add .')
system('touch README.md')
end
def execute
input_check
create_folder(folder_name)
change_folder(folder_name)
create_folder('./lib')
create_folder('./db')
create_app
create_gemfile
system_commands
end
execute