joe_utils 0.0.6 → 0.0.7
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 +4 -4
- data/bin/project_utility.rb +48 -0
- data/joe_utils.gemspec +2 -3
- data/lib/joe_utils/cli_helper.rb +65 -0
- data/lib/joe_utils/console_helper.rb +5 -0
- data/lib/joe_utils.rb +1 -0
- metadata +4 -3
- data/bin/gem_utility.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6514b9588191960e54440418ff4e3c976839f89f
|
4
|
+
data.tar.gz: 1f90ed7d09c340a884af1748f9ecb9776033e205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42eb125676fdccf0227f598d18347a4a3d139aed664fd77d9fae8200370ddc183349ba905383dfe99c813b66828fe8213361fb38d502914f2ff29c6d25e5a207
|
7
|
+
data.tar.gz: dc78c8a5f0243a0942e9b42d65b5f60c45c96fad012f9b159a289e60aaf791422bb6ea53ee2029dcd323ccd31e650716e9dccb8945e21f87ea92139450ee2455
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'joe_utils'
|
4
|
+
|
5
|
+
class ProjectUtility
|
6
|
+
|
7
|
+
include CLIHelper
|
8
|
+
|
9
|
+
HELP_TEXT = 'Provide me with the name of the gem, you also can add options:
|
10
|
+
i for installing the gem locally, p for pushing the gem to rubygems.org, h for help.',
|
11
|
+
INCLUDE_GEM_NAME = 'You did not enter a gem name.
|
12
|
+
Please include it as an argument to the script or hard code it as a variable in the script.',
|
13
|
+
|
14
|
+
def process_input(input, options = {})
|
15
|
+
input.each do |arg|
|
16
|
+
case arg
|
17
|
+
when '-g', '--github'
|
18
|
+
options[:github] = true
|
19
|
+
when '-h', '--heroku'
|
20
|
+
options[:heroku] = true
|
21
|
+
when '-gh'
|
22
|
+
options[:github] = options[:heroku] = true
|
23
|
+
when '-i', '--install'
|
24
|
+
options[:install] = true
|
25
|
+
when '-p', '--push'
|
26
|
+
options[:push] = true
|
27
|
+
when '-h', '--help'
|
28
|
+
puts HELP_TEXT
|
29
|
+
exit
|
30
|
+
when '-ip'
|
31
|
+
options[:install] = options[:push] = true
|
32
|
+
else
|
33
|
+
options[:gem_name] = arg
|
34
|
+
end
|
35
|
+
end
|
36
|
+
options
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
options = process_input(ARGV)
|
41
|
+
commit_git
|
42
|
+
commit_github if options[:github]
|
43
|
+
deploy_heroku if options[:heroku]
|
44
|
+
options[:gem_name] ? build_gem(options[:gem_name], options) : puts(INCLUDE_GEM_NAME)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
ProjectUtility.new.run
|
data/joe_utils.gemspec
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'joe_utils'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.executables = %w(
|
5
|
-
|
3
|
+
s.version = '0.0.7'
|
4
|
+
s.executables = %w(project_utility.rb)
|
6
5
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
7
6
|
s.authors = ['Josef Erneker']
|
8
7
|
s.date = %q{2014-12-26}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module CLIHelper
|
2
|
+
|
3
|
+
MESSAGES = {
|
4
|
+
commit_git: 'Commiting to git...',
|
5
|
+
push_rubygems: 'Pushing to rubygems.org...',
|
6
|
+
install_gem: 'Installing gem and jgem locally...',
|
7
|
+
build_gem: 'Building gem...',
|
8
|
+
build_gem_failed: 'The gem build failed. Please confirm the gem name and try again.',
|
9
|
+
deploy_heroku: 'Deploying to heroku.',
|
10
|
+
commit_github: 'Commiting to github.',
|
11
|
+
}
|
12
|
+
|
13
|
+
# Commits to git
|
14
|
+
# @return [nil]
|
15
|
+
def commit_git
|
16
|
+
puts MESSAGES[:commit_git]
|
17
|
+
puts `git add -u`
|
18
|
+
puts `git commit -m "Build gem version"`
|
19
|
+
end
|
20
|
+
|
21
|
+
# Builds the named gem locally, in case of provided options pushes and installs the gem
|
22
|
+
# @param [String] gem_name
|
23
|
+
# @param [Hash] options, supported options: :push for pushing to rubygems.org, :install for installing the gem locally
|
24
|
+
# @return [nil]
|
25
|
+
def build_gem(gem_name, options = {})
|
26
|
+
puts MESSAGES[:build_gem]
|
27
|
+
puts(gem_built_name = `gem build "#{gem_name}.gemspec"`)
|
28
|
+
gem_built_name = gem_built_name.match(/File: /).post_match
|
29
|
+
if gem_built_name && !gem_built_name.empty?
|
30
|
+
push_rubygems(gem_built_name) if options[:push]
|
31
|
+
install_gem(gem_built_name) if options[:install]
|
32
|
+
else
|
33
|
+
puts MESSAGES[:build_gem_failed]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Pushes the named gem to rubygems.org
|
38
|
+
# @param [String] gem_built_name
|
39
|
+
# @return [nil]
|
40
|
+
def push_rubygems(gem_built_name)
|
41
|
+
puts MESSAGES[:push_rubygems]
|
42
|
+
puts `gem push #{gem_built_name}`
|
43
|
+
end
|
44
|
+
|
45
|
+
# Installs the named gem locally
|
46
|
+
# @param [String] gem_built_name
|
47
|
+
# @return [nil]
|
48
|
+
def install_gem(gem_built_name)
|
49
|
+
puts MESSAGES[:install_gem]
|
50
|
+
puts `gem install #{gem_built_name}`
|
51
|
+
puts `jgem install #{gem_built_name}`
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [nil]
|
55
|
+
def commit_github
|
56
|
+
puts MESSAGES[:commit_github]
|
57
|
+
puts `git push origin master`
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [nil]
|
61
|
+
def deploy_heroku
|
62
|
+
puts MESSAGES[:deploy_heroku]
|
63
|
+
puts `git push heroku master`
|
64
|
+
end
|
65
|
+
end
|
data/lib/joe_utils.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joe_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Erneker
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
description: Overall personal utils gem
|
28
28
|
email: josef.erneker@gmail.com
|
29
29
|
executables:
|
30
|
-
-
|
30
|
+
- project_utility.rb
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
@@ -40,10 +40,11 @@ files:
|
|
40
40
|
- .idea/scopes/scope_settings.xml
|
41
41
|
- .idea/vcs.xml
|
42
42
|
- Rakefile
|
43
|
-
- bin/
|
43
|
+
- bin/project_utility.rb
|
44
44
|
- joe_utils.gemspec
|
45
45
|
- lib/joe_utils.rb
|
46
46
|
- lib/joe_utils/Script.rb
|
47
|
+
- lib/joe_utils/cli_helper.rb
|
47
48
|
- lib/joe_utils/config_helper.rb
|
48
49
|
- lib/joe_utils/console_helper.rb
|
49
50
|
- lib/joe_utils/files_helper.rb
|
data/bin/gem_utility.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
HELP_TEXT = 'Provide me with the name of the gem, you also can add options:
|
4
|
-
i for installing the gem locally, p for pushing the gem to rubygems.org, h for help.'
|
5
|
-
|
6
|
-
def print_help
|
7
|
-
puts HELP_TEXT
|
8
|
-
end
|
9
|
-
|
10
|
-
gem_name = install = push = nil
|
11
|
-
|
12
|
-
ARGV.each do |arg|
|
13
|
-
case arg
|
14
|
-
when '-i', '--install'
|
15
|
-
install = true
|
16
|
-
when '-p', '--push'
|
17
|
-
push = true
|
18
|
-
when '-h', '--help'
|
19
|
-
print_help
|
20
|
-
when '-ip'
|
21
|
-
install = true
|
22
|
-
push = true
|
23
|
-
else
|
24
|
-
gem_name = arg
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
puts 'Commiting...'
|
29
|
-
|
30
|
-
`git add -u`
|
31
|
-
`git commit -m "Build gem version"`
|
32
|
-
|
33
|
-
puts 'Building...'
|
34
|
-
|
35
|
-
# if the gem name has not been defined, print error message and exit
|
36
|
-
if gem_name
|
37
|
-
# run the gem build and parse for the gem release filename
|
38
|
-
gem_build_name = `gem build "#{gem_name}.gemspec"`
|
39
|
-
gem_build_name = gem_build_name.match(/File: /).post_match
|
40
|
-
|
41
|
-
# if the build failed (i.e. no file name obtained above), print error message and exit
|
42
|
-
if gem_build_name
|
43
|
-
puts 'Built successful'
|
44
|
-
# if above succeeded, then push to rubygems.org using the gem that was compiled
|
45
|
-
if push
|
46
|
-
puts 'Pushing...'
|
47
|
-
`gem push #{gem_build_name}`
|
48
|
-
end
|
49
|
-
# install it locally
|
50
|
-
if install
|
51
|
-
puts 'Installing...'
|
52
|
-
`gem install #{gem_build_name}`
|
53
|
-
`jgem install #{gem_build_name}`
|
54
|
-
end
|
55
|
-
else
|
56
|
-
puts 'The gem build failed. Please confirm the gem name and try again.'
|
57
|
-
end
|
58
|
-
else
|
59
|
-
puts 'You did not enter a gem name.
|
60
|
-
Please include it as an argument to the script or hard code it as a variable in the script.'
|
61
|
-
end
|