pad_gem 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pad_gem/generator.rb +30 -16
- data/lib/pad_gem/menu.rb +6 -1
- data/lib/pad_gem/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86af64299404425fa442b9b1f35dcfde64a9e1d3
|
4
|
+
data.tar.gz: 67ef75143e6a9c2812973fe28e30467d02c55520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc21924c0a502d9e282bfc261d56b2549c6abcb46c327346568f68099a982ce01560032d04092a2e30c2c229522abadbeef6d7973c01f541fe78af8608477f48
|
7
|
+
data.tar.gz: 7d3f4d21dd36caac17965592f202e5218f8ddbbf4ea81554e9f8cc8ce69c62283f5bce450e2b5ee35cad61a76bd56ccf9a81de94e9ee1e763eaff9aee32f0f08
|
data/lib/pad_gem/generator.rb
CHANGED
@@ -3,29 +3,41 @@ require 'pad_utils'
|
|
3
3
|
module PadGem
|
4
4
|
module Generator
|
5
5
|
|
6
|
-
def self.generate(options)
|
6
|
+
def self.generate(options, path = nil)
|
7
|
+
target_path = path == nil ? options[:gem_ruby_name] : "#{path}/#{options[:gem_ruby_name]}"
|
8
|
+
|
7
9
|
# Don't start generation if directory exists
|
8
|
-
if PadUtils.file_exist?(
|
10
|
+
if PadUtils.file_exist?(target_path)
|
9
11
|
return "A directory with the name of this gem already exists."
|
10
12
|
end
|
11
13
|
|
12
14
|
# Copy the foundation template
|
13
|
-
copy_foundation(
|
15
|
+
copy_foundation(target_path)
|
14
16
|
|
15
17
|
# Replace the placeholder texts in newly copied foundation
|
16
|
-
replace_placeholders(options)
|
18
|
+
replace_placeholders(options, path)
|
17
19
|
|
18
20
|
# Rename files according to the new gem name
|
19
|
-
rename_files(options)
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
rename_files(options, path)
|
22
|
+
|
23
|
+
if options[:executable]
|
24
|
+
# Make the executable ...well... executable
|
25
|
+
system "chmod +x #{target_path}/bin/#{options[:executable]}"
|
26
|
+
else
|
27
|
+
# Or delete it and remove traces of it in gemspec
|
28
|
+
PadUtils.delete_directory "#{target_path}/bin"
|
29
|
+
PadUtils.replace_line_containing(
|
30
|
+
"spec.executables",
|
31
|
+
in_file: "#{target_path}/#{options[:gem_ruby_name]}.gemspec",
|
32
|
+
new_value: ""
|
33
|
+
)
|
34
|
+
end
|
23
35
|
|
24
36
|
# Return success
|
25
37
|
"success"
|
26
38
|
|
27
39
|
rescue Exception => e
|
28
|
-
PadUtils.
|
40
|
+
PadUtils.set_log_path "#{ENV["HOME"]}/pad_gem_logs"
|
29
41
|
PadUtils.log("An error happened while generating the new gem", e)
|
30
42
|
"failure"
|
31
43
|
end
|
@@ -35,9 +47,10 @@ module PadGem
|
|
35
47
|
PadUtils.copy_all_files("#{padgem_dir}/foundation", dir_name)
|
36
48
|
end
|
37
49
|
|
38
|
-
def self.replace_placeholders(options)
|
50
|
+
def self.replace_placeholders(options, path = nil)
|
39
51
|
# Within the new gem dir
|
40
|
-
|
52
|
+
target_path = path == nil ? options[:gem_ruby_name] : "#{path}/#{options[:gem_ruby_name]}"
|
53
|
+
Dir.chdir "#{target_path}" do
|
41
54
|
|
42
55
|
# README.md
|
43
56
|
PadUtils.replace_in_file("README.md", /PADGEM_GEM_NAME/, options[:gem_name])
|
@@ -54,8 +67,8 @@ module PadGem
|
|
54
67
|
PadUtils.replace_in_file("foundation.gemspec", /PADGEM_EXECUTABLE/, options[:executable])
|
55
68
|
|
56
69
|
# bin/exec
|
57
|
-
PadUtils.replace_in_file("bin/exec", /PADGEM_GEM_NAME/, options[:gem_name])
|
58
|
-
PadUtils.replace_in_file("bin/exec", /PADGEM_GEM_RUBY_NAME/, options[:gem_ruby_name])
|
70
|
+
PadUtils.replace_in_file("bin/exec", /PADGEM_GEM_NAME/, options[:gem_name]) if options[:executable]
|
71
|
+
PadUtils.replace_in_file("bin/exec", /PADGEM_GEM_RUBY_NAME/, options[:gem_ruby_name]) if options[:executable]
|
59
72
|
|
60
73
|
# lib/foundation.rb
|
61
74
|
PadUtils.replace_in_file("lib/foundation.rb", /PADGEM_GEM_NAME/, options[:gem_name])
|
@@ -82,12 +95,13 @@ module PadGem
|
|
82
95
|
end
|
83
96
|
end
|
84
97
|
|
85
|
-
def self.rename_files(options)
|
98
|
+
def self.rename_files(options, path = nil)
|
86
99
|
# Within the new gem dir
|
87
|
-
|
100
|
+
target_path = path == nil ? options[:gem_ruby_name] : "#{path}/#{options[:gem_ruby_name]}"
|
101
|
+
Dir.chdir "#{target_path}" do
|
88
102
|
|
89
103
|
# bin/exec
|
90
|
-
PadUtils.move_file("bin/exec", "bin/#{options[:executable]}")
|
104
|
+
PadUtils.move_file("bin/exec", "bin/#{options[:executable]}") if options[:executable]
|
91
105
|
|
92
106
|
# foundation.gemspec
|
93
107
|
PadUtils.move_file("foundation.gemspec", "#{options[:gem_ruby_name]}.gemspec")
|
data/lib/pad_gem/menu.rb
CHANGED
@@ -15,7 +15,12 @@ module PadGem
|
|
15
15
|
options[:gem_name] = PadUtils.question_menu("Name of your gem")
|
16
16
|
options[:gem_name] = PadUtils.sanitize(options[:gem_name])
|
17
17
|
options[:gem_name] = PadUtils.convert_to_ruby_name(options[:gem_name])
|
18
|
-
|
18
|
+
sets_executable = PadUtils.yes_no_menu(question: "Add an executable?")
|
19
|
+
if sets_executable
|
20
|
+
options[:executable] = PadUtils.question_menu("Gem executable name")
|
21
|
+
else
|
22
|
+
options[:executable] = nil
|
23
|
+
end
|
19
24
|
options[:ruby_version] = PadUtils.question_menu("Minimum Ruby version")
|
20
25
|
options[:author] = PadUtils.question_menu("Your name")
|
21
26
|
options[:email] = PadUtils.question_menu("Your email address")
|
data/lib/pad_gem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pad_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Schuele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pad_utils
|