octopush 0.0.1
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/octopush +4 -0
- data/lib/octopush.rb +76 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe2ef05c127543a8644c954e3cd94a7bc84a577c
|
4
|
+
data.tar.gz: f820363c56e43fbe2ce367b9f9e7505e440bd22d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9529e58a02413094e68fca3e6dba6f4dea6588f831fa685ff2e45ee044b9025f82dcffb65912161bbbae5040666c3a6929aca2d40ca297ef4f3e04f8b2fc516f
|
7
|
+
data.tar.gz: c41d719d65fcbecc7ca5d2644cda43f8a853a24dca7a8a4af04431f3115d885c4b6852a6ebd10d4374f1dde189a6e974ee05255791a146c9d0ab07b7e371e54c
|
data/bin/octopush
ADDED
data/lib/octopush.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'colorize'
|
4
|
+
require 'github_api'
|
5
|
+
|
6
|
+
CONFIGURATION_FILE = (ENV['HOME'] + '/.octopushrc')
|
7
|
+
|
8
|
+
class Octopush < Thor
|
9
|
+
|
10
|
+
desc "octopush REPOSITORY_NAME", "uploads REPOSITORY_NAME to github (creates an empty one if needed)"
|
11
|
+
def octopush(repository_name)
|
12
|
+
@repository_name = repository_name
|
13
|
+
|
14
|
+
# re-initializing existing repos is safe:
|
15
|
+
# http://stackoverflow.com/questions/5149694/does-running-git-init-twice-initialize-a-repository-or-reinitialize-an-existing
|
16
|
+
`git init #{repository_name}`
|
17
|
+
|
18
|
+
Dir.chdir("./#{repository_name}")
|
19
|
+
FileUtils.touch('README.md')
|
20
|
+
`git add README.md`
|
21
|
+
`git commit -m 'add README.md (via octopush)'`
|
22
|
+
create_on_github
|
23
|
+
add_github_remote
|
24
|
+
push_repo
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_on_github
|
30
|
+
github_user.repos.create(name: repository_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_github_remote(remote_name = 'origin')
|
34
|
+
`git remote add #{remote_name} https://github.com/#{configuration['username']}/#{repository_name}.git`
|
35
|
+
end
|
36
|
+
|
37
|
+
def push_repo
|
38
|
+
`git push -u origin master`
|
39
|
+
end
|
40
|
+
|
41
|
+
def configuration
|
42
|
+
@configuration ||= load_configuration
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_configuration
|
46
|
+
begin
|
47
|
+
YAML.load(File.read(CONFIGURATION_FILE))
|
48
|
+
rescue
|
49
|
+
create_empty_configuration
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_empty_configuration
|
55
|
+
configuration ="username: <your_username>\npassword: <your_password>"
|
56
|
+
File.open(CONFIGURATION_FILE, 'wb') { |f| f.write(configuration) }
|
57
|
+
|
58
|
+
puts ('*' * 50).colorize(:red)
|
59
|
+
puts "No configuration found!".colorize(:red)
|
60
|
+
puts "Initialized configuration file in ~/.octopushrc"
|
61
|
+
puts ".. go edit it"
|
62
|
+
puts ('*' * 50).colorize(:red)
|
63
|
+
end
|
64
|
+
|
65
|
+
def repository_name
|
66
|
+
@repository_name
|
67
|
+
end
|
68
|
+
|
69
|
+
def github_user
|
70
|
+
@github_user ||= Github.new({
|
71
|
+
login: configuration['username'],
|
72
|
+
password: configuration['password']
|
73
|
+
})
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: octopush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martino Visintin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: github_api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ''
|
56
|
+
email: vise890@gmail.com
|
57
|
+
executables:
|
58
|
+
- octopush
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/octopush.rb
|
63
|
+
- bin/octopush
|
64
|
+
homepage: https://github.com/vise890/octopush
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.0.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Upload repos to github from the command line
|
88
|
+
test_files: []
|