octopush 0.0.8 → 0.0.9

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 (3) hide show
  1. data/lib/octopush.rb +85 -14
  2. metadata +1 -18
  3. data/lib/gictocat.rb +0 -64
@@ -1,7 +1,6 @@
1
1
  require 'thor'
2
2
  require 'fileutils'
3
- require 'colorize'
4
- require_relative 'gictocat'
3
+ require 'github_api'
5
4
 
6
5
  require 'highline/import'
7
6
  alias :high_ask :ask
@@ -10,30 +9,99 @@ CONFIGURATION_FILE = (ENV['HOME'] + '/.octopushrc')
10
9
 
11
10
  class Octopush < Thor
12
11
 
13
- include Gictocat
12
+ desc "octopush REPOSITORY_NAME",
13
+ "uploads REPOSITORY_NAME to github (creates an empty one if needed)"
14
14
 
15
- desc "octopush REPOSITORY_NAME", "uploads REPOSITORY_NAME to github (creates an empty one if needed)"
16
- def octopush(repository_name)
17
- @repository_name ||= repository_name
18
- initialize_repo(repository_name)
19
- cd_into_repo(repository_name)
20
- add_readme
15
+ def octopush(name)
16
+ create_repo(name)
21
17
  push_to_github
22
- puts "#{cyan_arrow} done."
23
- :done
24
18
  end
25
19
 
26
20
  private
27
21
 
22
+ def create_repo(name)
23
+ initialize_repo(name)
24
+ cd_into_repo(name)
25
+ add_readme
26
+ :done
27
+ end
28
+
29
+ def push_to_github
30
+ create_repo_on_github
31
+ add_github_remote
32
+ push_repo
33
+
34
+ cyan_arrow
35
+ say "done."
36
+
37
+ :done
38
+ end
39
+
40
+ def initialize_repo(name = repository_name)
41
+ @repository_name ||= name
42
+
43
+ cyan_arrow
44
+ say "Initializing repo in '#{repository_name}'"
45
+
46
+ `git init #{repository_name}`
47
+ end
48
+
49
+
28
50
  def cd_into_repo(repository_name)
29
51
  Dir.chdir("./#{repository_name}")
30
52
  Dir.pwd
31
53
  end
32
54
 
55
+ def add_readme
56
+ cyan_arrow
57
+ say "Touching and committing README.md"
58
+
59
+ touch_readme
60
+ add_and_commit_readme
61
+ :done
62
+ end
63
+
64
+ def touch_readme
65
+ FileUtils.touch('README.md')
66
+ end
67
+
68
+ def add_and_commit_readme
69
+ `git add README.md`
70
+ `git commit -m 'add README.md (via octopush)'`
71
+ end
72
+
73
+ def create_repo_on_github
74
+ cyan_arrow
75
+ say "Creating repo '#{repository_name}' on GitHub"
76
+
77
+ github_user.repos.create(name: repository_name)
78
+ end
79
+
80
+ def add_github_remote(remote_name = 'origin')
81
+ cyan_arrow
82
+ say "Adding GitHub as a remote"
83
+
84
+ `git remote add #{remote_name} https://github.com/#{username}/#{repository_name}.git`
85
+ end
86
+
87
+ def push_repo
88
+ cyan_arrow
89
+ say "Pushing repo to GitHub"
90
+
91
+ `git push -u origin master`
92
+ end
93
+
33
94
  def repository_name
34
95
  @repository_name
35
96
  end
36
97
 
98
+ def github_user
99
+ @github_user ||= Github.new({
100
+ login: username,
101
+ password: password
102
+ })
103
+ end
104
+
37
105
  def username
38
106
  @username ||= set_username
39
107
  end
@@ -68,16 +136,19 @@ class Octopush < Thor
68
136
  end
69
137
 
70
138
  def create_empty_configuration
71
- puts "#{red_arrow} Configuration not found. Edit your ~/.octopushrc for storing credentials"
139
+ red_arrow
140
+ say "Configuration not found. Edit your ~/.octopushrc for storing credentials"
141
+
72
142
  configuration ="username: <your_username>\npassword: <your_password>"
73
143
  File.open(CONFIGURATION_FILE, 'wb') { |f| f.write(configuration) }
74
144
  end
75
145
 
76
146
  def red_arrow
77
- '==>'.colorize(:red)
147
+ say '==> ', :red
78
148
  end
79
149
 
80
150
  def cyan_arrow
81
- '==>'.colorize(:cyan)
151
+ say '==> ', :cyan
82
152
  end
153
+
83
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -60,22 +60,6 @@ dependencies:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: 1.6.19
63
- - !ruby/object:Gem::Dependency
64
- name: colorize
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: 0.5.8
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 0.5.8
79
63
  description: ''
80
64
  email: vise890@gmail.com
81
65
  executables:
@@ -84,7 +68,6 @@ extensions: []
84
68
  extra_rdoc_files: []
85
69
  files:
86
70
  - lib/octopush.rb
87
- - lib/gictocat.rb
88
71
  - bin/octopush
89
72
  homepage: https://github.com/vise890/octopush
90
73
  licenses:
@@ -1,64 +0,0 @@
1
- require 'colorize'
2
- require 'github_api'
3
-
4
- # mix in model for very simple github repo manipulation
5
- # requires class to respond to repository_name, username, password
6
- module Gictocat
7
-
8
- def initialize_repo(repository_name = repository_name)
9
- puts "#{cyan_arrow} Initializing repo in '#{repository_name}'"
10
- # re-initializing existing repos is safe:
11
- # http://stackoverflow.com/questions/5149694/does-running-git-init-twice-initialize-a-repository-or-reinitialize-an-existing
12
- `git init #{repository_name}`
13
- end
14
-
15
- def add_readme
16
- puts "#{cyan_arrow} Touching and committing README.md"
17
- touch_readme
18
- add_and_commit_readme
19
- :done
20
- end
21
-
22
- def touch_readme
23
- FileUtils.touch('README.md')
24
- end
25
-
26
- def add_and_commit_readme
27
- `git add README.md`
28
- `git commit -m 'add README.md (via octopush)'`
29
- end
30
-
31
- def push_to_github
32
- create_repo_on_github
33
- add_github_remote
34
- push_repo
35
- :done
36
- end
37
-
38
- def create_repo_on_github
39
- puts "#{cyan_arrow} Creating repo '#{repository_name}' on GitHub"
40
- github_user.repos.create(name: repository_name)
41
- end
42
-
43
- def add_github_remote(remote_name = 'origin')
44
- puts "#{cyan_arrow} Adding GitHub as a remote"
45
- `git remote add #{remote_name} https://github.com/#{username}/#{repository_name}.git`
46
- end
47
-
48
- def push_repo
49
- puts "#{cyan_arrow} Pushing repo to GitHub"
50
- `git push -u origin master`
51
- end
52
-
53
- def github_user
54
- @github_user ||= Github.new({
55
- login: username,
56
- password: password
57
- })
58
- end
59
-
60
- def cyan_arrow
61
- '==>'.colorize(:cyan)
62
- end
63
-
64
- end