bundlegem 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +35 -3
  3. data/bin/bundlegem +1 -0
  4. data/changelog +48 -24
  5. data/config/config +4 -0
  6. data/lib/bundlegem/cli/gem.rb +156 -154
  7. data/lib/bundlegem/configurator.rb +21 -4
  8. data/lib/bundlegem/template_manager.rb +59 -0
  9. data/{tmp_gem/tmp_gem.gemspec → lib/bundlegem/templates/c_extension_gem/#{name}.gemspec.tt} +15 -7
  10. data/lib/bundlegem/templates/c_extension_gem/.travis.yml.tt +3 -0
  11. data/lib/bundlegem/templates/c_extension_gem/CODE_OF_CONDUCT.md.tt +13 -0
  12. data/lib/bundlegem/templates/c_extension_gem/Gemfile.tt +4 -0
  13. data/lib/bundlegem/templates/c_extension_gem/LICENSE.txt.tt +21 -0
  14. data/{tmp_gem/README.md → lib/bundlegem/templates/c_extension_gem/README.md.tt} +6 -6
  15. data/lib/bundlegem/templates/c_extension_gem/Rakefile.tt +25 -0
  16. data/lib/bundlegem/templates/c_extension_gem/bin/#{name}.tt +3 -0
  17. data/{tmp_gem/bin/console → lib/bundlegem/templates/c_extension_gem/bin/console.tt} +1 -1
  18. data/{tmp_gem/changelog → lib/bundlegem/templates/c_extension_gem/changelog.tt} +0 -0
  19. data/lib/bundlegem/templates/{newgem → c_extension_gem}/ext/#{name}/#{newgem}.c.tt +0 -0
  20. data/lib/bundlegem/templates/{newgem → c_extension_gem}/ext/#{name}/#{newgem}.h.tt +0 -0
  21. data/lib/bundlegem/templates/{newgem → c_extension_gem}/ext/#{name}/extconf.rb.tt +0 -0
  22. data/lib/bundlegem/templates/{newgem → c_extension_gem}/gitignore.tt +0 -0
  23. data/lib/bundlegem/templates/c_extension_gem/lib/#{name}/version.rb.tt +7 -0
  24. data/lib/bundlegem/templates/c_extension_gem/lib/#{name}.rb.tt +12 -0
  25. data/{tmp_gem/.rspec → lib/bundlegem/templates/c_extension_gem/rspec.tt} +0 -0
  26. data/{tmp_gem/spec/tmp_gem_spec.rb → lib/bundlegem/templates/c_extension_gem/spec/#{name}_spec.rb.tt} +2 -2
  27. data/{tmp_gem/spec/spec_helper.rb → lib/bundlegem/templates/c_extension_gem/spec/spec_helper.rb.tt} +1 -1
  28. data/lib/bundlegem/templates/cli_gem/#{name}.gemspec.tt +35 -0
  29. data/lib/bundlegem/templates/cli_gem/.travis.yml.tt +3 -0
  30. data/lib/bundlegem/templates/cli_gem/CODE_OF_CONDUCT.md.tt +13 -0
  31. data/lib/bundlegem/templates/cli_gem/Gemfile.tt +4 -0
  32. data/lib/bundlegem/templates/cli_gem/LICENSE.txt.tt +21 -0
  33. data/lib/bundlegem/templates/cli_gem/README.md.tt +39 -0
  34. data/lib/bundlegem/templates/cli_gem/Rakefile.tt +25 -0
  35. data/lib/bundlegem/templates/cli_gem/bin/#{name}.tt +3 -0
  36. data/lib/bundlegem/templates/cli_gem/bin/console.tt +14 -0
  37. data/lib/bundlegem/templates/cli_gem/changelog.tt +7 -0
  38. data/lib/bundlegem/templates/cli_gem/exe/#{name}.tt +5 -0
  39. data/lib/bundlegem/templates/cli_gem/ext/#{name}/#{newgem}.c.tt +9 -0
  40. data/lib/bundlegem/templates/cli_gem/ext/#{name}/#{newgem}.h.tt +6 -0
  41. data/lib/bundlegem/templates/cli_gem/ext/#{name}/extconf.rb.tt +3 -0
  42. data/{tmp_gem/.gitignore → lib/bundlegem/templates/cli_gem/gitignore.tt} +7 -0
  43. data/lib/bundlegem/templates/cli_gem/lib/#{name}/version.rb.tt +7 -0
  44. data/lib/bundlegem/templates/cli_gem/lib/#{name}.rb.tt +9 -0
  45. data/lib/bundlegem/templates/cli_gem/rspec.tt +2 -0
  46. data/lib/bundlegem/templates/cli_gem/spec/#{name}_spec.rb.tt +11 -0
  47. data/lib/bundlegem/templates/cli_gem/spec/spec_helper.rb.tt +2 -0
  48. data/lib/bundlegem/templates/newgem/#{name}.gemspec.tt +2 -6
  49. data/lib/bundlegem/templates/newgem/.gitignore.tt +16 -0
  50. data/lib/bundlegem/templates/newgem/Rakefile.tt +32 -17
  51. data/lib/bundlegem/templates/service/lib/#{name}.rb.tt +1 -1
  52. data/lib/bundlegem/version.rb +1 -1
  53. data/lib/bundlegem.rb +29 -2
  54. data/spec/bundlegem_spec.rb +8 -2
  55. data/spec/spec_helper.rb +18 -8
  56. metadata +44 -19
  57. data/tmp_gem/.travis.yml +0 -3
  58. data/tmp_gem/Gemfile +0 -4
  59. data/tmp_gem/Rakefile +0 -1
  60. data/tmp_gem/lib/tmp_gem/version.rb +0 -3
  61. data/tmp_gem/lib/tmp_gem.rb +0 -5
data/lib/bundlegem.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require "bundlegem/version"
2
2
  require 'bundlegem/configurator'
3
+ require 'bundlegem/template_manager'
4
+
5
+ SOURCE_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
3
6
 
4
7
  module Bundlegem
5
8
 
@@ -21,7 +24,7 @@ module Bundlegem
21
24
  available_templates = group_hashes_by_key(available_templates)
22
25
  output_string = convert_grouped_hashes_to_output(available_templates)
23
26
 
24
- output_string
27
+ mark_default_template(output_string, configurator.default_template)
25
28
  end
26
29
 
27
30
  def gem(options, gem_name)
@@ -30,7 +33,20 @@ module Bundlegem
30
33
 
31
34
  Bundlegem::CLI::Gem.new(options, gem_name).run
32
35
  end
33
-
36
+
37
+ def new_template(args)
38
+ template_name = args[1]
39
+ template_name = prompt_for_template_name if template_name.nil?
40
+
41
+ # Copy newgem from within the repo to ~/.bundlegem/gem_templates/#{template_name}
42
+ TemplateManager.create_new_template(template_name)
43
+ end
44
+
45
+ def prompt_for_template_name
46
+ puts "Please specify a name for your template: "
47
+ template_name = STDIN.gets.chomp.strip.gsub(" ", "_")
48
+ end
49
+
34
50
  # input: [ { "predefined" => "default" },
35
51
  # { "MISC" => "my_thing" },
36
52
  # { "prdefined" => "service" }
@@ -68,6 +84,17 @@ module Bundlegem
68
84
  s
69
85
  end
70
86
 
87
+ def mark_default_template(output_string, default_template)
88
+ output_string.lines.reverse.map do |l|
89
+ if l.strip == default_template
90
+ l[1]= "*"
91
+ "#{l.chomp} (default)\n"
92
+ else
93
+ l
94
+ end
95
+ end.reverse.join
96
+ end
97
+
71
98
  def which(executable)
72
99
  if File.file?(executable) && File.executable?(executable)
73
100
  executable
@@ -3,7 +3,12 @@ require 'spec_helper'
3
3
  describe Bundlegem do
4
4
 
5
5
  before :each do
6
- clear_templates
6
+ @mocked_home = "/tmp/bundlegem_mock_home"
7
+ @template_root = "#{@mocked_home}/.bundlegem/gem_templates"
8
+ @dst_dir = "/tmp/bundle_gem_dst_dir"
9
+
10
+ reset_test_env
11
+ FileUtils.chdir("/tmp/bundle_gem_dst_dir")
7
12
  end
8
13
 
9
14
  it 'has a version number' do
@@ -19,7 +24,7 @@ describe Bundlegem do
19
24
 
20
25
  list_output = Bundlegem.list
21
26
 
22
- expect(list_output).to eq " PREDEFINED:\n newgem\n service\n\n MISC:\n empty_template\n\n"
27
+ expect(list_output).to eq " PREDEFINED:\n * newgem (default)\n service\n\n MISC:\n empty_template\n\n"
23
28
  expect(File.exists?("#{ENV['HOME']}/.bundlegem")).to be true
24
29
  end
25
30
 
@@ -35,6 +40,7 @@ describe Bundlegem do
35
40
  it "can generate the built-in gems fine" do
36
41
  options = {"bin"=>false, "ext"=>false, :coc=> false}
37
42
  gem_name = "tmp_gem" # gem name
43
+
38
44
  Bundlegem.gem(options, gem_name)
39
45
  end
40
46
 
data/spec/spec_helper.rb CHANGED
@@ -4,20 +4,30 @@ require 'fileutils'
4
4
  require 'pry'
5
5
 
6
6
  # Mock our home directory
7
- ENV['HOME'] = "/tmp/bundlegem_mock_home"
7
+
8
+ ENV['HOME'] = "/tmp/bundlegem_mock_home"
9
+
10
+
8
11
 
9
12
 
10
13
  def create_user_defined_template(category = nil)
11
- template_root = "/tmp/bundlegem_mock_home/.bundlegem/gem_templates/empty_template"
12
- FileUtils.mkdir_p template_root
14
+ new_templates_dir = "#{@template_root}/empty_template"
15
+
16
+ # Creates the gem template (empty folder)
17
+ FileUtils.mkdir_p new_templates_dir
13
18
 
14
- File.open("#{template_root}/.bundlegem", "w+") do |f|
19
+ # Writes the category
20
+ File.open("#{new_templates_dir}/.bundlegem", "w+") do |f|
15
21
  f.puts "category: #{category}" unless category.nil?
16
22
  end
17
-
18
23
  end
19
24
 
20
25
 
21
- def clear_templates
22
- FileUtils.rm_rf "/tmp/bundlegem_mock_home/.bundlegem"
23
- end
26
+ def reset_test_env
27
+ FileUtils.rm_rf @mocked_home
28
+ FileUtils.rm_rf @dst_dir
29
+
30
+ FileUtils.mkdir_p @dst_dir
31
+ FileUtils.mkdir_p @template_root
32
+ end
33
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundlegem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - TheNotary
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -98,15 +98,57 @@ files:
98
98
  - bin/bundlegem
99
99
  - bundlegem.gemspec
100
100
  - changelog
101
+ - config/config
101
102
  - lib/bundlegem.rb
102
103
  - lib/bundlegem/cli.rb
103
104
  - lib/bundlegem/cli/gem.rb
104
105
  - lib/bundlegem/configurator.rb
105
106
  - lib/bundlegem/friendly_errors.rb
107
+ - lib/bundlegem/template_manager.rb
106
108
  - lib/bundlegem/templates/Executable
107
109
  - lib/bundlegem/templates/Executable.standalone
108
110
  - lib/bundlegem/templates/Gemfile
111
+ - lib/bundlegem/templates/c_extension_gem/#{name}.gemspec.tt
112
+ - lib/bundlegem/templates/c_extension_gem/.travis.yml.tt
113
+ - lib/bundlegem/templates/c_extension_gem/CODE_OF_CONDUCT.md.tt
114
+ - lib/bundlegem/templates/c_extension_gem/Gemfile.tt
115
+ - lib/bundlegem/templates/c_extension_gem/LICENSE.txt.tt
116
+ - lib/bundlegem/templates/c_extension_gem/README.md.tt
117
+ - lib/bundlegem/templates/c_extension_gem/Rakefile.tt
118
+ - lib/bundlegem/templates/c_extension_gem/bin/#{name}.tt
119
+ - lib/bundlegem/templates/c_extension_gem/bin/console.tt
120
+ - lib/bundlegem/templates/c_extension_gem/changelog.tt
121
+ - lib/bundlegem/templates/c_extension_gem/ext/#{name}/#{newgem}.c.tt
122
+ - lib/bundlegem/templates/c_extension_gem/ext/#{name}/#{newgem}.h.tt
123
+ - lib/bundlegem/templates/c_extension_gem/ext/#{name}/extconf.rb.tt
124
+ - lib/bundlegem/templates/c_extension_gem/gitignore.tt
125
+ - lib/bundlegem/templates/c_extension_gem/lib/#{name}.rb.tt
126
+ - lib/bundlegem/templates/c_extension_gem/lib/#{name}/version.rb.tt
127
+ - lib/bundlegem/templates/c_extension_gem/rspec.tt
128
+ - lib/bundlegem/templates/c_extension_gem/spec/#{name}_spec.rb.tt
129
+ - lib/bundlegem/templates/c_extension_gem/spec/spec_helper.rb.tt
130
+ - lib/bundlegem/templates/cli_gem/#{name}.gemspec.tt
131
+ - lib/bundlegem/templates/cli_gem/.travis.yml.tt
132
+ - lib/bundlegem/templates/cli_gem/CODE_OF_CONDUCT.md.tt
133
+ - lib/bundlegem/templates/cli_gem/Gemfile.tt
134
+ - lib/bundlegem/templates/cli_gem/LICENSE.txt.tt
135
+ - lib/bundlegem/templates/cli_gem/README.md.tt
136
+ - lib/bundlegem/templates/cli_gem/Rakefile.tt
137
+ - lib/bundlegem/templates/cli_gem/bin/#{name}.tt
138
+ - lib/bundlegem/templates/cli_gem/bin/console.tt
139
+ - lib/bundlegem/templates/cli_gem/changelog.tt
140
+ - lib/bundlegem/templates/cli_gem/exe/#{name}.tt
141
+ - lib/bundlegem/templates/cli_gem/ext/#{name}/#{newgem}.c.tt
142
+ - lib/bundlegem/templates/cli_gem/ext/#{name}/#{newgem}.h.tt
143
+ - lib/bundlegem/templates/cli_gem/ext/#{name}/extconf.rb.tt
144
+ - lib/bundlegem/templates/cli_gem/gitignore.tt
145
+ - lib/bundlegem/templates/cli_gem/lib/#{name}.rb.tt
146
+ - lib/bundlegem/templates/cli_gem/lib/#{name}/version.rb.tt
147
+ - lib/bundlegem/templates/cli_gem/rspec.tt
148
+ - lib/bundlegem/templates/cli_gem/spec/#{name}_spec.rb.tt
149
+ - lib/bundlegem/templates/cli_gem/spec/spec_helper.rb.tt
109
150
  - lib/bundlegem/templates/newgem/#{name}.gemspec.tt
151
+ - lib/bundlegem/templates/newgem/.gitignore.tt
110
152
  - lib/bundlegem/templates/newgem/.travis.yml.tt
111
153
  - lib/bundlegem/templates/newgem/CODE_OF_CONDUCT.md.tt
112
154
  - lib/bundlegem/templates/newgem/Gemfile.tt
@@ -116,10 +158,6 @@ files:
116
158
  - lib/bundlegem/templates/newgem/bin/#{name}.tt
117
159
  - lib/bundlegem/templates/newgem/bin/console.tt
118
160
  - lib/bundlegem/templates/newgem/changelog.tt
119
- - lib/bundlegem/templates/newgem/ext/#{name}/#{newgem}.c.tt
120
- - lib/bundlegem/templates/newgem/ext/#{name}/#{newgem}.h.tt
121
- - lib/bundlegem/templates/newgem/ext/#{name}/extconf.rb.tt
122
- - lib/bundlegem/templates/newgem/gitignore.tt
123
161
  - lib/bundlegem/templates/newgem/lib/#{name}.rb.tt
124
162
  - lib/bundlegem/templates/newgem/lib/#{name}/version.rb.tt
125
163
  - lib/bundlegem/templates/newgem/rspec.tt
@@ -143,19 +181,6 @@ files:
143
181
  - lib/bundlegem/version.rb
144
182
  - spec/bundlegem_spec.rb
145
183
  - spec/spec_helper.rb
146
- - tmp_gem/.gitignore
147
- - tmp_gem/.rspec
148
- - tmp_gem/.travis.yml
149
- - tmp_gem/Gemfile
150
- - tmp_gem/README.md
151
- - tmp_gem/Rakefile
152
- - tmp_gem/bin/console
153
- - tmp_gem/changelog
154
- - tmp_gem/lib/tmp_gem.rb
155
- - tmp_gem/lib/tmp_gem/version.rb
156
- - tmp_gem/spec/spec_helper.rb
157
- - tmp_gem/spec/tmp_gem_spec.rb
158
- - tmp_gem/tmp_gem.gemspec
159
184
  homepage: ''
160
185
  licenses:
161
186
  - MIT
data/tmp_gem/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.3
data/tmp_gem/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in tmp_gem.gemspec
4
- gemspec
data/tmp_gem/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,3 +0,0 @@
1
- module TmpGem
2
- VERSION = "0.1.0"
3
- end
@@ -1,5 +0,0 @@
1
- require "tmp_gem/version"
2
-
3
- module TmpGem
4
- # Your code goes here...
5
- end