learn_duplicate 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -12
- data/lib/learn_duplicate.rb +12 -29
- 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: c9f511d965e4cb31d33209130da16d75ab19e89c5ae2eb1bc644ca1147db515a
|
4
|
+
data.tar.gz: 1f221f55c66d53a035dfc9f96f27ea907543d1ee0ff7536efbc8106a0f8fbc36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db0a1434003cec31e3f4f30c9d69bc4dae3a98839f1fa90fda5581260ebd3b065e7c194393b91d60a32157e55f5f7a7a90806594903020f184e6f541edb51253
|
7
|
+
data.tar.gz: 257dedeb103984305847efcaeb64e5ad5c65979fcd08feb98dbca1721a055e3f3178412d557a06e7566e7b1201adc2797f3f08a22d7e0f933ae9019d4a200c65
|
data/README.md
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
# Learn
|
1
|
+
# Learn Duplicate
|
2
2
|
|
3
3
|
This gem is designed to aid in the creation of learn lessons.
|
4
4
|
|
5
5
|
## Installation and Setup
|
6
6
|
|
7
|
-
Before using `
|
7
|
+
Before using `learn_duplicate`, you must install `hub`, GitHub's extended CLI API.
|
8
8
|
|
9
9
|
```sh
|
10
10
|
$ brew install hub
|
11
11
|
```
|
12
12
|
|
13
13
|
Once `hub` is installed, you'll need to get it configured before running
|
14
|
-
`
|
14
|
+
`learn_duplicate`. The best way to do this is to use `hub` once to duplicate a
|
15
15
|
repository on learn-co-curriculum. In the shell:
|
16
16
|
|
17
17
|
- Create a new, empty folder and `cd` into it
|
18
|
-
- `git init` to
|
19
|
-
- Run `hub
|
18
|
+
- `git init` to duplicate an initial git repo
|
19
|
+
- Run `hub duplicate learn-co-curriculum/<whatever name you've chosen>`
|
20
20
|
- You should be prompted to sign into GitHub
|
21
21
|
- **Note:** If you have set up two-factor identification on GitHub, when
|
22
22
|
prompted for your password, you have two options:
|
23
23
|
- If Github SMS' you a one-time password, use it!
|
24
24
|
- Otherwise, instead of using your normal password, you
|
25
|
-
need to enter a personal access token. You can
|
25
|
+
need to enter a personal access token. You can duplicate a token in your
|
26
26
|
GitHub settings page.
|
27
27
|
- If everything works as expected you should now have an empty `learn-co-curriculum` repo.
|
28
28
|
- Delete the repo. Everything should be set up now.
|
29
29
|
|
30
|
-
Install the `
|
30
|
+
Install the `learn_duplicate` gem:
|
31
31
|
|
32
32
|
```sh
|
33
|
-
$ gem install
|
33
|
+
$ gem install learn_duplicate
|
34
34
|
```
|
35
35
|
|
36
36
|
## Usage
|
37
37
|
|
38
|
-
To
|
39
|
-
repo to be
|
38
|
+
To duplicate a new learn repository, navigate to the folder where you'd like your
|
39
|
+
repo to be duplicated locally. Type:
|
40
40
|
|
41
41
|
```sh
|
42
|
-
|
42
|
+
learn_duplicate
|
43
43
|
```
|
44
44
|
|
45
45
|
Follow the command line prompts for setting up and naming your repository. The
|
46
|
-
repo will be
|
46
|
+
repo will be duplicated locally and pushed to GitHub. When finished, you can `cd`
|
47
47
|
into the local folder or open it on github to start working.
|
48
48
|
|
49
49
|
## Resources
|
data/lib/learn_duplicate.rb
CHANGED
@@ -21,6 +21,7 @@ class LearnDuplicate
|
|
21
21
|
encoded_url = URI.encode(url).slice(0, url.length)
|
22
22
|
check_existing = Faraday.get URI.parse(encoded_url)
|
23
23
|
|
24
|
+
# careful - will hit rate limit on GitHub if abused
|
24
25
|
if check_existing.body.include? '"Not Found"'
|
25
26
|
puts 'Provided repository name is not a valid learn-co-curriculum repository. Please try again.'
|
26
27
|
else
|
@@ -34,11 +35,16 @@ class LearnDuplicate
|
|
34
35
|
puts 'What is the name of the repository you would like to create?'
|
35
36
|
|
36
37
|
@repo_name = gets.strip.gsub(/\s+/, '-').downcase
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
if @repo_name.length >= 100
|
39
|
+
puts 'Repository names must be shorter than 100 characters'
|
40
|
+
else
|
41
|
+
url = 'https://api.github.com/repos/learn-co-curriculum/' + @repo_name
|
42
|
+
encoded_url = URI.encode(url).slice(0, url.length)
|
43
|
+
check_existing = Faraday.get URI.parse(encoded_url)
|
44
|
+
|
45
|
+
break if check_existing.body.include? '"Not Found"'
|
46
|
+
end
|
40
47
|
|
41
|
-
break if check_existing.body.include? '"Not Found"'
|
42
48
|
|
43
49
|
puts 'A repository with that name already exists:'
|
44
50
|
puts 'https://github.com/learn-co-curriculum/' + @repo_name
|
@@ -49,7 +55,8 @@ class LearnDuplicate
|
|
49
55
|
|
50
56
|
create_new_repo
|
51
57
|
puts ''
|
52
|
-
|
58
|
+
puts 'To access local folder, change directory into ' + @repo_name + '/'
|
59
|
+
puts 'Repository available at https://github.com/learn-co-curriculum/' + @repo_name
|
53
60
|
|
54
61
|
end
|
55
62
|
|
@@ -88,21 +95,6 @@ class LearnDuplicate
|
|
88
95
|
`#{cmd}`
|
89
96
|
end
|
90
97
|
|
91
|
-
# def git_init
|
92
|
-
# cmd = cd_into_and('git init')
|
93
|
-
# `#{cmd}`
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# def git_add
|
97
|
-
# cmd = cd_into_and('git add .')
|
98
|
-
# `#{cmd}`
|
99
|
-
# end
|
100
|
-
#
|
101
|
-
# def git_commit
|
102
|
-
# cmd = cd_into_and('git commit -m "automated initial commit"')
|
103
|
-
# `#{cmd}`
|
104
|
-
# end
|
105
|
-
#
|
106
98
|
def git_create
|
107
99
|
cmd = cd_into_and("hub create learn-co-curriculum/#{@repo_name}")
|
108
100
|
`#{cmd}`
|
@@ -130,15 +122,6 @@ class LearnDuplicate
|
|
130
122
|
git_clone
|
131
123
|
puts 'Renaming old repository with new name'
|
132
124
|
rename_repo
|
133
|
-
# puts ''
|
134
|
-
# puts 'Reinitializing'
|
135
|
-
# git_init
|
136
|
-
# puts ''
|
137
|
-
# puts 'Staging content for commit'
|
138
|
-
# git_add
|
139
|
-
# puts ''
|
140
|
-
# puts 'Creating initial commit'
|
141
|
-
# git_commit
|
142
125
|
puts ''
|
143
126
|
puts 'Creating new remote learn-co-curriculum repository'
|
144
127
|
git_create
|