newgit 0.0.1c
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 +7 -0
- data/bin/newgit +5 -0
- data/lib/newgit.rb +52 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d56083a7fbef15314b59a6e6b18235d8162b188
|
4
|
+
data.tar.gz: 086c8e4080c6ef159e59fa28c7fa959c44e8797b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c303b0b886417986cf3bb1420e3ee5fdc939371762b2e03c1d2bb89941dc28d7bc820c471f08780d6a3d9a3b62464b6f8725ec85d569924307b26a45b0a61a42
|
7
|
+
data.tar.gz: 97e77f21774ba4de8fe84e36ea7089fa4aa01d4c0e67a5b24b8e2e9ddf76888f47a9728aad4fef49ba24e473d42de3c592eb4bce9e2a4cabccfe684e64ec0b91
|
data/bin/newgit
ADDED
data/lib/newgit.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'io/console'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
module NewGit
|
6
|
+
|
7
|
+
extend self
|
8
|
+
def init(args)
|
9
|
+
if args.any?
|
10
|
+
build_new = true
|
11
|
+
repo_name = args.pop
|
12
|
+
else
|
13
|
+
build_new = false
|
14
|
+
repo_name = Dir.getwd.split('/').last
|
15
|
+
end
|
16
|
+
|
17
|
+
creds = get_credentials
|
18
|
+
response = `curl -u "#{creds[:username]}:#{creds[:password]}" https://api.github.com/user/repos -d '{"name":"'#{repo_name}'"}'`
|
19
|
+
git_url = JSON.parse(response)
|
20
|
+
if git_url['message'] || git_url['errors']
|
21
|
+
puts git_url['message'].colorize(color: :red)
|
22
|
+
git_url['errors'] && git_url['errors'].each do |err|
|
23
|
+
puts "#{err['message']}".colorize(color: :red)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
if build_new
|
27
|
+
`git clone #{git_url['clone_url']}`
|
28
|
+
else
|
29
|
+
`echo "# #{repo_name}" >> README.md`
|
30
|
+
`git init`
|
31
|
+
`git add .`
|
32
|
+
`git commit -m "initial commit"`
|
33
|
+
`git remote add origin #{git_url['clone_url']}`
|
34
|
+
end
|
35
|
+
puts "You successfully created new git repo at #{git_url['clone_url']}".colorize(color: :green)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_credentials
|
40
|
+
{username: get_user, password: get_pw }
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_user
|
44
|
+
print "github username > "
|
45
|
+
username = STDIN.gets.chomp
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_pw
|
49
|
+
print "github password > "
|
50
|
+
pw = STDIN.noecho(&:gets).chomp
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: newgit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1c
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David James Carter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: CLI Github Repo Generator written in Ruby
|
14
|
+
email: fresco.raja@gmail.com
|
15
|
+
executables:
|
16
|
+
- newgit
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/newgit
|
21
|
+
- lib/newgit.rb
|
22
|
+
homepage:
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.3.1
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.6
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: New Github Repo from the command line
|
45
|
+
test_files: []
|