learn_create 0.0.9 → 0.0.10
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 +4 -4
- data/README.md +21 -4
- data/lib/learn_create.rb +47 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bf2afcfb843f978d89391f3a4b434c0b6c384eee625dd4638905d7a832c5f10
|
4
|
+
data.tar.gz: 8fff4925d8a1fc5250766e0ab6d3a7d5d76f6b6360af8d1734cd1e8bfe8662bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927c820585f1ead5f3b0e4a6de0b6f1ad53d69a5ed642a2254ee57a10e91834a1e7c17c910842997d22065701bfe3a1b86900280917a18be3af59c60d21fc6e4
|
7
|
+
data.tar.gz: 9e2338fdfa1041061ef983211a1176446731246d4bd04d7a9b9b431cb3a47e8e527704261f92b527bfd5abc1d96f3d63da7c0dd1bc5f75c48a372a66e9322ed5
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
This gem is designed to aid in the creation of learn lessons.
|
4
4
|
|
5
|
-
## Installation
|
5
|
+
## Installation and Setup
|
6
6
|
|
7
7
|
Before using `learn_create`, you must install `hub`, GitHub's extended CLI API.
|
8
8
|
|
@@ -10,8 +10,18 @@ Before using `learn_create`, you must install `hub`, GitHub's extended CLI API.
|
|
10
10
|
$ brew install hub
|
11
11
|
```
|
12
12
|
|
13
|
-
Once `hub` is installed, you
|
14
|
-
|
13
|
+
Once `hub` is installed, you'll need to get it configured before running
|
14
|
+
`learn_create`. The best way to do this is to use `hub` once to create a
|
15
|
+
repository on learn-co-curriculum. In the shell:
|
16
|
+
|
17
|
+
- Create a new, empty folder and navigate into it
|
18
|
+
- Run `hub create learn-co-curriculum/<whatever name you've chosen>`
|
19
|
+
- You should be prompted to sign into GitHub
|
20
|
+
- If everything works as expected you should now have an empty
|
21
|
+
learn-co-curriculum repo
|
22
|
+
- Delete the repo. Everything should be set up now.
|
23
|
+
|
24
|
+
Install the `learn_create` gem:
|
15
25
|
|
16
26
|
```sh
|
17
27
|
$ gem install learn_create
|
@@ -27,4 +37,11 @@ learn_create
|
|
27
37
|
```
|
28
38
|
|
29
39
|
Follow the command line prompts for setting up and naming your repository. The
|
30
|
-
repo will be created locally and pushed to GitHub.
|
40
|
+
repo will be created locally and pushed to GitHub. When finished, you can `cd`
|
41
|
+
into the local folder or open it on github to start working.
|
42
|
+
|
43
|
+
## Resources
|
44
|
+
|
45
|
+
- [Hub]
|
46
|
+
|
47
|
+
[hub]: https://hub.github.com/hub.1.html
|
data/lib/learn_create.rb
CHANGED
@@ -11,7 +11,7 @@ class LearnCreate
|
|
11
11
|
|
12
12
|
loop do
|
13
13
|
puts 'What is the name of the repository you would like to create?'
|
14
|
-
@repo_name = gets.
|
14
|
+
@repo_name = gets.strip.gsub(/\s+/, '-').downcase
|
15
15
|
url = 'https://api.github.com/repos/learn-co-curriculum/' + @repo_name
|
16
16
|
encoded_url = URI.encode(url).slice(0, url.length)
|
17
17
|
|
@@ -42,7 +42,6 @@ class LearnCreate
|
|
42
42
|
case language
|
43
43
|
when /^ru/
|
44
44
|
create_local_lesson('lab', 'Ruby')
|
45
|
-
|
46
45
|
when /^j/
|
47
46
|
create_local_lesson('lab', 'JavaScript')
|
48
47
|
|
@@ -90,6 +89,7 @@ class LearnCreate
|
|
90
89
|
template_path = File.expand_path(gem_template_location) + template_folder
|
91
90
|
|
92
91
|
copy_template(template_path)
|
92
|
+
create_dot_learn_file(type, language)
|
93
93
|
end
|
94
94
|
|
95
95
|
def copy_template(template_path)
|
@@ -98,33 +98,70 @@ class LearnCreate
|
|
98
98
|
`#{cmd}`
|
99
99
|
end
|
100
100
|
|
101
|
+
def create_dot_learn_file(type = 'undefined', language = 'undefined')
|
102
|
+
`
|
103
|
+
cd #{@repo_name}
|
104
|
+
cat > .learn <<EOL
|
105
|
+
tags:
|
106
|
+
- #{type}
|
107
|
+
languages:
|
108
|
+
- #{language}
|
109
|
+
`
|
110
|
+
end
|
111
|
+
|
112
|
+
def cd_into_and(command)
|
113
|
+
"cd #{@repo_name} && #{command}"
|
114
|
+
end
|
115
|
+
|
101
116
|
def git_init
|
102
|
-
'git init'
|
117
|
+
cmd = cd_into_and('git init')
|
118
|
+
`#{cmd}`
|
103
119
|
end
|
104
120
|
|
105
121
|
def git_add
|
106
|
-
'git add .'
|
122
|
+
cmd = cd_into_and('git add .')
|
123
|
+
`#{cmd}`
|
107
124
|
end
|
108
125
|
|
109
126
|
def git_commit
|
110
|
-
'git commit -m "automated initial commit"'
|
127
|
+
cmd = cd_into_and('git commit -m "automated initial commit"')
|
128
|
+
`#{cmd}`
|
111
129
|
end
|
112
130
|
|
113
131
|
def git_create
|
114
|
-
"hub create learn-co-curriculum/#{@repo_name}"
|
132
|
+
cmd = cd_into_and("hub create learn-co-curriculum/#{@repo_name}")
|
133
|
+
`#{cmd}`
|
115
134
|
end
|
116
135
|
|
117
136
|
def git_set_remote
|
118
|
-
"git remote set-url origin https://github.com/learn-co-curriculum/#{@repo_name}"
|
137
|
+
cmd = cd_into_and("git remote set-url origin https://github.com/learn-co-curriculum/#{@repo_name}")
|
138
|
+
`#{cmd}`
|
119
139
|
end
|
120
140
|
|
121
141
|
def git_push
|
122
|
-
'git push -u origin master'
|
142
|
+
cmd = cd_into_and('git push -u origin master')
|
143
|
+
`#{cmd}`
|
123
144
|
end
|
124
145
|
|
125
146
|
def create_new_repo
|
126
147
|
# must be in a single chain. 'cd' doesn't work the way it would in the shell
|
127
|
-
|
128
|
-
|
148
|
+
puts ''
|
149
|
+
puts 'Initializing git repository'
|
150
|
+
git_init
|
151
|
+
puts ''
|
152
|
+
puts 'Staging content for commit'
|
153
|
+
git_add
|
154
|
+
puts ''
|
155
|
+
puts 'Creating initial commit'
|
156
|
+
git_commit
|
157
|
+
puts ''
|
158
|
+
puts 'Creating remote learn-co-curriculum repository'
|
159
|
+
git_create
|
160
|
+
puts ''
|
161
|
+
puts 'Setting git remote'
|
162
|
+
git_set_remote
|
163
|
+
puts ''
|
164
|
+
puts 'Pushing to remote'
|
165
|
+
git_push
|
129
166
|
end
|
130
167
|
end
|