learn_duplicate 0.0.5 → 0.0.8

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -12
  3. data/lib/learn_duplicate.rb +12 -29
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 398d6e2abe891a095ae2ebc7ed78db3f2548eb031f23d91aec4b91659aaa43b3
4
- data.tar.gz: 3504454d76e535ca4620c5dfa972e40c4c7b595ce540b3540bd8fb42e8a74fbe
3
+ metadata.gz: c9f511d965e4cb31d33209130da16d75ab19e89c5ae2eb1bc644ca1147db515a
4
+ data.tar.gz: 1f221f55c66d53a035dfc9f96f27ea907543d1ee0ff7536efbc8106a0f8fbc36
5
5
  SHA512:
6
- metadata.gz: 6e86f6092715ab6af116c7df540cdd56d6ad4d5a588abe187a7709c754e5bf400e94cc09e194cd5fba2aba2d4a6464e1214d78883755ec3713e46907f50d81b2
7
- data.tar.gz: 882bd7627d03de0218e3c9b179fc7b8f1ea2c7523ae06db1067b9ed7577bcb0a7c9259644915f9350612a94449f9b308309829216d0f392a205810e903a86749
6
+ metadata.gz: db0a1434003cec31e3f4f30c9d69bc4dae3a98839f1fa90fda5581260ebd3b065e7c194393b91d60a32157e55f5f7a7a90806594903020f184e6f541edb51253
7
+ data.tar.gz: 257dedeb103984305847efcaeb64e5ad5c65979fcd08feb98dbca1721a055e3f3178412d557a06e7566e7b1201adc2797f3f08a22d7e0f933ae9019d4a200c65
data/README.md CHANGED
@@ -1,49 +1,49 @@
1
- # Learn Create
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 `learn_create`, you must install `hub`, GitHub's extended CLI API.
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
- `learn_create`. The best way to do this is to use `hub` once to create a
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 create an initial git repo
19
- - Run `hub create learn-co-curriculum/<whatever name you've chosen>`
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 create a token in your
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 `learn_create` gem:
30
+ Install the `learn_duplicate` gem:
31
31
 
32
32
  ```sh
33
- $ gem install learn_create
33
+ $ gem install learn_duplicate
34
34
  ```
35
35
 
36
36
  ## Usage
37
37
 
38
- To create a new learn repository, navigate to the folder where you'd like your
39
- repo to be created locally. Type:
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
- learn_create
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 created locally and pushed to GitHub. When finished, you can `cd`
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
@@ -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
- url = 'https://api.github.com/repos/learn-co-curriculum/' + @repo_name
38
- encoded_url = URI.encode(url).slice(0, url.length)
39
- check_existing = Faraday.get URI.parse(encoded_url)
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
- cd_into_and('echo "Repository created."')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn_duplicate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - flatironschool