-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRubySetup
More file actions
executable file
·227 lines (190 loc) · 4.22 KB
/
RubySetup
File metadata and controls
executable file
·227 lines (190 loc) · 4.22 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
set -e
colour=$(tput setaf 4)
normal=$(tput sgr0)
if [[ ! -e $1 ]]; then
mkdir $1
elif [[ ! -d $1 ]]; then
echo "$1 already exists but is not a directory"
exit 0
fi
cd $1
if [[ ! -e lib ]]; then
mkdir lib
elif [[ ! -d lib ]]; then
echo "lib already exists but is not a directory"
exit 0
fi
if [[ ! -e spec ]]; then
mkdir spec
elif [[ ! -d spec ]]; then
echo "spec already exists but is not a directory"
exit 0
fi
gem install bundler -v 1.16.3
touch Gemfile
cat > Gemfile << EOF
ruby '2.5.1'
source 'https://rubygems.org'
group :test do
gem 'cycromatic'
gem 'rspec'
gem 'simplecov'
end
EOF
touch LaundryList.md
cat > LaundryList.md << EOF
# Laundry List
EOF
bundle install
rspec --init
cat > spec/spec_helper.rb << EOF
require 'simplecov'
SimpleCov.start
EOF
cat > .rspec << EOF
--require spec_helper
--format documentation
EOF
if [[ ! -e .git ]]; then
git init
printf "\n\n${colour}Initializing git${normal}\n\n"
else
printf "\n\n${colour}git already exists${normal}\n\n"
fi
if [ -e .gitignore ]
then
printf "\n\n${colour}gitignore already exists${normal}\n\n"
else
touch .gitignore
cat > .gitignore << EOF
*.sw?
.DS_Store
coverage
doc
pkg
Gemfile.lock
.bundle
*.rbc
bin
bundle
.bundle
specs.out
*.gem
.vscode
.idea/
*~
EOF
printf "\n\n${colour}sample gitignore created${normal}\n\n"
fi
touch README.md
cat > README.md << EOF
# Project Description
## Dev Environment Setup for OS X.
* Ruby 2.5.1
\`\`\`
$ brew install ruby@2.5
\`\`\`
[To install ruby on other platform please refer](https://www.ruby-lang.org/en/documentation/installation/)
* Bundler v1.16.3
\`\`\`
$ gem install bundler -v 1.16.3
\`\`\`
## Test instructions
\`\`\`
$ bundle exec rspec
\`\`\`
## Code Coverage
\`\`\`
$ bundle exec rspec
\`\`\`
It will create a folder with the name coverage and on clicking the index.html inside coverage folder you can find the code coverage.
## Using Cycromatic
\`\`\`
$ cycromatic .
\`\`\`
It will output the cyclomatic complexity of the code.
[To know further please see](https://github.com/soutaro/cycromatic)
## How to use
### Author
EOF
printf "\n\n${colour}Sample readme created\n\n***Plaese update readme before coding anything else***${normal}\n\n"
if ! [ -z "$2" ]
then
touch README.md
cat > README.md << EOF
# Project Description
$2
## Dev Environment Setup for OS X.
* Ruby 2.5.1
\`\`\`
$ brew install ruby@2.5
\`\`\`
[To install ruby on other platform please refer](https://www.ruby-lang.org/en/documentation/installation/)
* Bundler v1.16.3
\`\`\`
$ gem install bundler -v 1.16.3
\`\`\`
## Test instructions
\`\`\`
$ bundle exec rspec
\`\`\`
## Code Coverage
\`\`\`
$ bundle exec rspec
\`\`\`
It will create a folder with the name coverage and on clicking the index.html inside coverage folder you can find the code coverage.
## Using Cycromatic
\`\`\`
$ cycromatic .
\`\`\`
It will output the cyclomatic complexity of the code.
[To know further please see](https://github.com/soutaro/cycromatic)
## How to use
### Author
$3
EOF
printf "\n\n${colour}Updated the readme${normal}\n\n"
else
if ! [ -z "$2" ]
then
printf "\n\n${colour}Give both project description and Authors to automatic readme update.\n\nReadme is not updated${normal}\n\n"
fi
exit 0
fi
if ! [ -z "$4" ]
then
git add .
commit_message="$4"
git commit -m "$commit_message"
printf "\n\n***${colour}Commited with updated readme${normal}***\n\n"
else
printf "\n\n***${colour}Please do Readme commit before writing the code${normal}***\n\n"
exit 0
fi
if ! [ -z "$5" ]
then
className="$(tr [A-Z] [a-z] <<< "$5")"
printf "${colour}creating class and spec files with name as: $className...${normal}\n\n"
touch lib/"$className".rb
cat > lib/"$className".rb << EOF
module Saungkertas
class $5
end
end
EOF
touch spec/"$className"_spec.rb
cat > spec/"$className"_spec.rb << EOF
require './lib/$5'
module Saungkertas
describe 'In $5' do
end
end
EOF
printf "${colour}***Done***${normal}\n\n"
printf "${colour}***runing rspec***${normal}\n\n"
rspec
printf "${colour}\n\n***runing cyclomatic complexity***${normal}\n\n"
cycromatic .
printf "${colour}\n\n***Every thing done start with writing specs***${normal}\n\n"
fi