ggem 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,8 +4,6 @@
4
4
  .bundle
5
5
  .config
6
6
  .yardoc
7
- .rvmrc
8
- .rbenv-version
9
7
  Gemfile.lock
10
8
  InstalledFiles
11
9
  _yardoc
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'bundler', '~>1.1'
6
- gem 'rake', '~>0.9.2'
5
+ gem 'rake'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-Present Kelly D. Redding
1
+ Copyright (c) 2008-Present Kelly Redding
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,33 +1,31 @@
1
1
  # GGem
2
2
 
3
- Quickly, easily, consistantly generate a ruby gem project ready to build, test, and deploy. Uses and emulates most of Bundler's gem building features.
4
-
5
- ## Installation
6
-
7
- ```
8
- $ gem install ggem
9
- ```
3
+ Consistantly generate a ruby gem project ready to test, build, and deploy. Uses and emulates most of Bundler's gem building features.
10
4
 
11
5
  ## Usage
12
6
 
13
7
  ```
8
+ $ ggem --help
14
9
  $ ggem my-gem
10
+ $ git commit -m "Gem created with ggem"
15
11
  ```
16
12
 
17
- This creates a folder and some files for developing, testing, and building a gem. The command is pretty forgiving with the name you supply, it will automatically transform anything that is CamelCased into something more rubyish. If you have existing folders/files it will just add/overwrite where necessary and not remove anything.
13
+ GGem creates a folder and files for developing, testing, and releasing a gem. It is safe to run on existing gem folders, adding/overwriting where necessary.
18
14
 
19
- GGem assumes you are using git for version control. It uses information in you git config and git commands to generate some default information and to build the gem. When creating new gems, GGem will also initialize a git repo and add the newly created files for committing.
15
+ ## Features
20
16
 
21
- The gem will generate with bundler (http://github.com/carlhuda/bundler/) and assert (http://github.com/teaminsight/assert) gems as development dependencies. They are brought in automatically to make unit testing and releasing your new gem easy. Remove their calls from the generated Rakefile and test helper if you don't want to use them.
17
+ * creates `lib` and gem files similar to `bundle gem` (as of Bundler 1.2.4)
18
+ * creates `test` files
19
+ * source control using Git
20
+ * test using Assert
21
+ * release using Bundler
22
+ * adds `TODO` entries in files where user input is needed
22
23
 
23
- After generating your gem, add information about your gem to both the gemspec and README files. The default version number is "0.0.1", but if you want to change that, take a look at `lib/my_gem/version.rb` to make the change - this will automatically be picked up when you rebuild your gem.
24
-
25
- Your new gem provides some Rake tasks for convenience:
26
-
27
- * all the bundler gem rake tasks (http://github.com/carlhuda/bundler/)
28
- * all the testing rake task stuff from assert (http://github.com/teaminsight/assert)
24
+ ## Installation
29
25
 
30
- That's it. Enjoy.
26
+ ```
27
+ $ gem install ggem
28
+ ```
31
29
 
32
30
  ## Contributing
33
31
 
data/Rakefile CHANGED
@@ -1,8 +1 @@
1
- #!/usr/bin/env rake
2
-
3
- require 'assert/rake_tasks'
4
- Assert::RakeTasks.install
5
-
6
- require 'bundler/gem_tasks'
7
-
8
- task :default => :build
1
+ require "bundler/gem_tasks"
data/bin/ggem CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2008-Present Kelly Redding
4
+ #
2
5
 
3
6
  require 'ggem/cli'
4
- GGemCLI::Ggem.run(ARGV, __FILE__)
7
+ GGem::CLI.run *ARGV
@@ -1,21 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/ggem/version', __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ggem/version"
3
5
 
4
6
  Gem::Specification.new do |gem|
5
7
  gem.name = "ggem"
6
8
  gem.version = GGem::VERSION
7
- gem.summary = %q{"Juh Gem", baby! (this makes gems)}
8
- gem.description = %q{"Juh Gem", baby! (this makes gems)}
9
-
10
9
  gem.authors = ["Kelly Redding"]
11
10
  gem.email = ["kelly@kellyredding.com"]
11
+ gem.description = %q{"Juh Gem", baby! (this makes gems)}
12
+ gem.summary = %q{"Juh Gem", baby! (this makes gems)}
12
13
  gem.homepage = "http://github.com/kellyredding/ggem"
13
14
 
14
- gem.files = `git ls-files`.split("\n")
15
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
18
  gem.require_paths = ["lib"]
18
19
 
19
20
  gem.add_development_dependency("assert")
20
- gem.add_dependency("quickl")
21
+
21
22
  end
@@ -1 +1,2 @@
1
- require 'ggem/gem'
1
+ require 'ggem/version'
2
+ require 'ggem/gem'
@@ -1,48 +1,106 @@
1
- require 'quickl'
2
1
  require 'ggem'
3
- require "ggem/version"
2
+ require 'ggem/version'
4
3
 
5
- module GGemCLI
4
+ module GGem
6
5
 
7
- #
8
- # ggem command line tool
9
- #
10
- # SYNOPSIS
11
- # #{command_name} [options] GEM_NAME
12
- #
13
- # OPTIONS
14
- # #{summarized_options}
15
- #
16
- # DESCRIPTION
17
- # This is a command line tool for using ggem
18
- #
19
- class Ggem < Quickl::Command(__FILE__, __LINE__)
6
+ class CLI
20
7
 
21
- VERSION = GGem::VERSION
8
+ def self.run(*args)
9
+ self.new.run(*args)
10
+ end
22
11
 
23
- # Install options
24
- options do |opt|
12
+ def initialize
13
+ @cli = CLIRB.new do
14
+ option 'debug', 'run in debug mode'
15
+ end
16
+ end
25
17
 
26
- @ggem_cli_opts = {}
18
+ def run(*args)
19
+ begin
20
+ # parse manually in the case that parsing fails before the debug arg
21
+ debug_mode ||= args.include?('-d') || args.include?('--debug')
22
+ @cli.parse!(args)
23
+ raise CLIRB::Error, "please provide a gem name" if @cli.args.size < 1
27
24
 
28
- opt.on_tail('-h', '--help', "Show this help message") do
29
- raise Quickl::Help
25
+ path = GGem::Gem.new(Dir.pwd, *args).save!.path
26
+ puts "created gem and initialized git repo in #{path}"
27
+ rescue CLIRB::HelpExit
28
+ puts help
29
+ rescue CLIRB::VersionExit
30
+ puts GGem::VERSION
31
+ rescue CLIRB::Error => exception
32
+ puts "#{exception.message}\n\n"
33
+ puts debug_mode ? exception.backtrace.join("\n") : help
34
+ exit(1)
35
+ rescue Exception => exception
36
+ puts "#{exception.class}: #{exception.message}"
37
+ puts exception.backtrace.join("\n") if debug_mode
38
+ exit(1)
30
39
  end
40
+ exit(0)
41
+ end
31
42
 
32
- opt.on_tail('-v', '--version', 'Show version and exit') do
33
- raise Quickl::Exit, "#{Quickl.program_name} #{VERSION}"
34
- end
43
+ def help
44
+ "Usage: ggem GEM-NAME\n\n"\
45
+ "Options:"\
46
+ "#{@cli}"
47
+ end
48
+
49
+ end
50
+
51
+ class CLIRB # Version 1.0.0, https://github.com/redding/cli.rb
52
+ Error = Class.new(RuntimeError);
53
+ HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
54
+ attr_reader :argv, :args, :opts, :data
35
55
 
56
+ def initialize(&block)
57
+ @options = []; instance_eval(&block) if block
58
+ require 'optparse'
59
+ @data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
60
+ p.banner = ''; @options.each do |o|
61
+ @opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
62
+ end
63
+ p.on_tail('--version', ''){ |v| raise VersionExit, v.to_s }
64
+ p.on_tail('--help', ''){ |v| raise HelpExit, v.to_s }
65
+ end
36
66
  end
37
67
 
38
- # Run the command
39
- def execute(args)
40
- raise Quickl::Help if args.size < 1
41
- g = GGem::Gem.new(`pwd`.strip, *args)
42
- g.save
43
- puts "created gem and initialized git repo in #{g.path}"
68
+ def option(*args); @options << Option.new(*args); end
69
+ def parse!(argv)
70
+ @args = (argv || []).dup.tap do |args_list|
71
+ begin; @parser.parse!(args_list)
72
+ rescue OptionParser::ParseError => err; raise Error, err.message; end
73
+ end; @data = @args + [@opts]
74
+ end
75
+ def to_s; @parser.to_s; end
76
+ def inspect
77
+ "#<#{self.class}:#{'0x0%x' % (object_id << 1)} @data=#{@data.inspect}>"
44
78
  end
45
79
 
80
+ class Option
81
+ attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
82
+
83
+ def initialize(name, *args)
84
+ settings, @desc = args.last.kind_of?(::Hash) ? args.pop : {}, args.pop || ''
85
+ @name, @opt_name, @abbrev = parse_name_values(name, settings[:abbrev])
86
+ @value, @klass = gvalinfo(settings[:value])
87
+ @parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
88
+ ["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
89
+ else
90
+ ["-#{@abbrev}", "--#{@opt_name} #{@opt_name.upcase}", @klass, @desc]
91
+ end
92
+ end
93
+
94
+ private
95
+
96
+ def parse_name_values(name, custom_abbrev)
97
+ [ (processed_name = name.to_s.strip.downcase), processed_name.gsub('_', '-'),
98
+ custom_abbrev || processed_name.gsub(/[^a-z]/, '').chars.first || 'a'
99
+ ]
100
+ end
101
+ def gvalinfo(v); v.kind_of?(Class) ? [nil,gklass(v)] : [v,gklass(v.class)]; end
102
+ def gklass(k); k == Fixnum ? Integer : k; end
103
+ end
46
104
  end
47
105
 
48
106
  end
@@ -2,55 +2,51 @@ require 'fileutils'
2
2
  require 'ggem/template'
3
3
 
4
4
  module GGem
5
+
5
6
  class Gem
6
7
 
7
8
  attr_reader :root_path, :name
8
9
 
9
10
  def initialize(path, name)
10
- @root_path = path
11
- self.name = name
11
+ @root_path, self.name = path, name
12
12
  end
13
13
 
14
- def path
15
- File.join(root_path, name)
14
+ def save!
15
+ Template.new(self).tap{ |t| t.save; t.init }
16
+ self
16
17
  end
17
18
 
18
- def name=(name)
19
- @name = name.
20
- gsub(/([A-Z])([a-z])/, '_\1\2').
21
- gsub(/_+/, '_').
22
- sub(/^_/, '').
23
- downcase
24
- end
19
+ def path; File.join(@root_path, @name); end
20
+ def name=(name); @name = normalize_name(name); end
25
21
 
26
22
  def module_name
27
- @module_name ||= transform_name('_' => '', '-' => '') {|part| part.capitalize }
23
+ transforms = {'_' => '', '-' => ''}
24
+ @module_name ||= transform_name(transforms){ |part| part.capitalize }
28
25
  end
29
26
 
30
27
  def ruby_name
31
- @ruby_name ||= transform_name{|part| part.downcase }
32
- end
33
-
34
- def save
35
- Template.new(self).tap do |t|
36
- t.save
37
- t.init
38
- end
28
+ @ruby_name ||= transform_name{ |part| part.downcase }
39
29
  end
40
30
 
41
31
  private
42
32
 
33
+ def normalize_name(name)
34
+ und_camelcs = [ /([A-Z])([a-z])/, '_\1\2' ]
35
+ rm_dup_und = [ /_+/, '_' ]
36
+ rm_lead_und = [ /^_/, '' ]
37
+ name.gsub(*und_camelcs).gsub(*rm_dup_und).sub(*rm_lead_und).downcase
38
+ end
39
+
43
40
  def transform_name(conditions={}, &block)
44
41
  n = (block ? block.call(self.name) : self.name)
45
42
  conditions.each do |on, glue|
46
43
  if (a = n.split(on)).size > 1
47
- n = a.collect do |part|
48
- block.call(part) if block
49
- end.join(glue)
44
+ n = a.map{ |part| block.call(part) if block }.join(glue)
50
45
  end
51
46
  end
52
47
  n
53
48
  end
54
49
 
55
50
  end
51
+
56
52
  end
@@ -9,34 +9,47 @@ module GGem
9
9
  end
10
10
 
11
11
  def save
12
- save_folder # (gems root path)
12
+ save_folder # (gem root path)
13
13
  save_folder "lib/#{@gem.ruby_name}"
14
- save_folder "test"
14
+ save_folder "test/support"
15
+ save_folder "test/system"
16
+ save_folder "test/unit"
17
+ save_folder "log"
18
+ save_folder "tmp"
15
19
 
16
- save_file('gitignore.erb', '.gitignore')
17
- save_file('Gemfile.erb', 'Gemfile')
18
- save_file('gemspec.erb', "#{@gem.name}.gemspec")
19
- save_file('Rakefile.erb', 'Rakefile')
20
- save_file('README.md.erb', 'README.md')
21
- save_file('LICENSE.erb', 'LICENSE')
20
+ save_file('gitignore.erb', '.gitignore')
21
+ save_file('Gemfile.erb', 'Gemfile')
22
+ save_file('gemspec.erb', "#{@gem.name}.gemspec")
23
+ save_file('Rakefile.erb', 'Rakefile')
24
+ save_file('README.md.erb', 'README.md')
25
+ save_file('LICENSE.txt.erb', 'LICENSE.txt')
22
26
 
23
27
  save_file('lib.rb.erb', "lib/#{@gem.ruby_name}.rb")
24
28
  save_file('lib_version.rb.erb', "lib/#{@gem.ruby_name}/version.rb")
25
29
 
26
- save_file('test_irb.rb.erb', 'test/irb.rb')
27
30
  save_file('test_helper.rb.erb', 'test/helper.rb')
31
+
32
+ save_empty_file('log/.gitkeep')
33
+ save_empty_file('tmp/.gitkeep')
28
34
  end
29
35
 
30
36
  def init
31
- `cd #{@gem.path} && git init && git add --all`
37
+ cmd = "cd #{@gem.path} &&"\
38
+ " git init && git add --all &&"\
39
+ " git add -f log/.gitkeep && git add -f tmp/.gitkeep"
40
+ `#{cmd}`
32
41
  end
33
42
 
34
43
  private
35
44
 
36
45
  def save_folder(relative_path=nil)
37
- FileUtils.mkdir_p(File.join([
38
- @gem.path, relative_path
39
- ].compact))
46
+ path = File.join([@gem.path, relative_path].compact)
47
+ FileUtils.mkdir_p(path)
48
+ end
49
+
50
+ def save_empty_file(relative_path)
51
+ path = File.join(@gem.path, relative_path)
52
+ FileUtils.touch(path)
40
53
  end
41
54
 
42
55
  def save_file(source, output)
@@ -1,6 +1,5 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'bundler', '~>1.1'
6
- gem 'rake', '~>0.9.2'
5
+ gem 'rake'
@@ -1,4 +1,4 @@
1
- Copyright (c) <%= Time.now.year %> <TODO: copyright holders>
1
+ Copyright (c) <%= Time.now.year %>-Present <TODO: copyright holders>
2
2
 
3
3
  MIT License
4
4
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  TODO: Write a gem description
4
4
 
5
+ ## Usage
6
+
7
+ TODO: Write code samples and usage instructions here
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -16,10 +20,6 @@ Or install it yourself as:
16
20
 
17
21
  $ gem install <%= @gem.name %>
18
22
 
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
23
  ## Contributing
24
24
 
25
25
  1. Fork it
@@ -1,8 +1 @@
1
- #!/usr/bin/env rake
2
-
3
- require 'assert/rake_tasks'
4
- Assert::RakeTasks.install
5
-
6
- require 'bundler/gem_tasks'
7
-
8
- task :default => :build
1
+ require "bundler/gem_tasks"
@@ -1,21 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/<%= @gem.ruby_name %>/version', __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "<%= @gem.ruby_name %>/version"
3
5
 
4
6
  Gem::Specification.new do |gem|
5
7
  gem.name = "<%= @gem.name %>"
6
8
  gem.version = <%= @gem.module_name %>::VERSION
7
- gem.description = %q{TODO: Write a gem description}
8
- gem.summary = %q{TODO: Write a gem summary}
9
-
10
9
  gem.authors = ["TODO: authors"]
11
10
  gem.email = ["TODO: emails"]
11
+ gem.description = %q{TODO: Write a gem description}
12
+ gem.summary = %q{TODO: Write a gem summary}
12
13
  gem.homepage = "http://github.com/__/<%= @gem.name %>"
13
14
 
14
- gem.files = `git ls-files`.split("\n")
15
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
18
  gem.require_paths = ["lib"]
18
19
 
19
20
  gem.add_development_dependency("assert")
20
- # gem.add_dependency("gem-name", ["~> 0.0"])
21
+ # TODO: gem.add_dependency("gem-name", ["~> 0.0"])
22
+
21
23
  end
@@ -4,8 +4,6 @@
4
4
  .bundle
5
5
  .config
6
6
  .yardoc
7
- .rvmrc
8
- .rbenv-version
9
7
  Gemfile.lock
10
8
  InstalledFiles
11
9
  _yardoc
@@ -1,3 +1,5 @@
1
- module <%= @gem.module_name %>
1
+ require "<%= @gem.ruby_name %>/version"
2
2
 
3
- end
3
+ module <%= @gem.module_name %>
4
+ # TODO: your code goes here...
5
+ end
@@ -1,5 +1,7 @@
1
- # this file is automatically required in when you require 'assert' in your tests
2
- # put test helpers here
1
+ # this file is automatically required when you run `assert`
2
+ # put any test helpers here
3
3
 
4
- # add root dir to the load path
4
+ # add the root dir to the load path
5
5
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
+
7
+ # TODO: put test helpers here...
@@ -1,3 +1,3 @@
1
1
  module GGem
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -1,14 +1,12 @@
1
- # this file is automatically required in when you require 'assert' in your tests
2
- # put test helpers here
1
+ # this file is automatically required when you run `assert`
2
+ # put any test helpers here
3
3
 
4
- # add test dir to the load path
5
- $LOAD_PATH.unshift(File.expand_path("..", __FILE__))
4
+ # add the root dir to the load path
5
+ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
6
 
7
7
  class Assert::Context
8
8
 
9
- TMP_PATH = File.expand_path("#{File.dirname(__FILE__)}/../tmp")
10
-
11
-
9
+ TMP_PATH = File.expand_path "../../tmp", __FILE__
12
10
 
13
11
  def self.create_paths(name_set)
14
12
  called_from = caller.first
@@ -20,13 +18,12 @@ class Assert::Context
20
18
 
21
19
  Assert::Macro.new(macro_name) do
22
20
  paths.flatten.each do |path|
23
-
24
21
  should "create the path '#{path}'", called_from do
25
22
  assert File.exists?(path), "'#{path}' does not exist"
26
23
  end
27
-
28
24
  end
29
25
  end
26
+
30
27
  end
31
28
 
32
29
  def self.generate_name_set(name_set)
@@ -36,15 +33,14 @@ class Assert::Context
36
33
  Assert::Macro.new(macro_name) do
37
34
  name_set.variations.each do |variation|
38
35
  [:name, :module_name, :ruby_name].each do |name_type|
39
-
40
36
  should "know its :#{name_type} given '#{variation}'", called_from do
41
37
  the_gem = GGem::Gem.new(TMP_PATH, variation)
42
38
  assert_equal name_set.send(name_type), the_gem.send(name_type)
43
39
  end
44
-
45
40
  end
46
41
  end
47
42
  end
43
+
48
44
  end
49
45
 
50
46
  end
@@ -1,7 +1,6 @@
1
1
  module GGem
2
2
  module NameSet
3
3
 
4
-
5
4
  class Base
6
5
  attr_reader :variations, :name, :module_name, :ruby_name
7
6
 
@@ -9,7 +8,12 @@ module GGem
9
8
  [ '',
10
9
  'lib',
11
10
  "lib/#{@ruby_name}",
12
- 'test'
11
+ 'test',
12
+ 'test/support',
13
+ 'test/system',
14
+ 'test/unit',
15
+ 'log',
16
+ 'tmp'
13
17
  ]
14
18
  end
15
19
 
@@ -19,18 +23,19 @@ module GGem
19
23
  "#{@name}.gemspec",
20
24
  "Rakefile",
21
25
  "README.md",
22
- "LICENSE",
26
+ "LICENSE.txt",
23
27
 
24
28
  "lib/#{@ruby_name}.rb",
25
29
  "lib/#{@ruby_name}/version.rb",
26
30
 
27
31
  "test/helper.rb",
28
- "test/irb.rb",
32
+
33
+ "log/.gitkeep",
34
+ "tmp/.gitkeep",
29
35
  ]
30
36
  end
31
37
  end
32
38
 
33
-
34
39
  class Simple < Base
35
40
  def initialize
36
41
  @variations = ['simple']
@@ -40,7 +45,6 @@ module GGem
40
45
  end
41
46
  end
42
47
 
43
-
44
48
  class Underscored < Base
45
49
  def initialize
46
50
  @variations = ['my_gem', 'my__gem', 'MyGem', 'myGem', 'My_Gem']
@@ -50,7 +54,6 @@ module GGem
50
54
  end
51
55
  end
52
56
 
53
-
54
57
  class HyphenatedOther < Base
55
58
  def initialize
56
59
  @variations = ['my-gem']
@@ -60,6 +63,5 @@ module GGem
60
63
  end
61
64
  end
62
65
 
63
-
64
66
  end
65
67
  end
@@ -0,0 +1,44 @@
1
+ require 'assert'
2
+ require 'test/support/name_set'
3
+ require 'ggem'
4
+
5
+ module GGem
6
+
7
+ class BaseTests < Assert::Context
8
+ desc "GGem"
9
+
10
+ NS_SIMPLE = GGem::NameSet::Simple
11
+ NS_UNDER = GGem::NameSet::Underscored
12
+ NS_HYPHEN = GGem::NameSet::HyphenatedOther
13
+
14
+ [ NS_SIMPLE, NS_UNDER, NS_HYPHEN ].each do |ns|
15
+ should generate_name_set(ns.new)
16
+ end
17
+
18
+ end
19
+
20
+ class SaveTests < BaseTests
21
+ desc "when saving gems"
22
+ setup_once do
23
+ FileUtils.rm_rf(TMP_PATH)
24
+ FileUtils.mkdir_p(TMP_PATH)
25
+ GGem::Gem.new(TMP_PATH, NS_SIMPLE.new.variations.first).save!
26
+ GGem::Gem.new(TMP_PATH, NS_UNDER.new.variations.first).save!
27
+ GGem::Gem.new(TMP_PATH, NS_HYPHEN.new.variations.first).save!
28
+ end
29
+ teardown_once do
30
+ FileUtils.rm_rf(TMP_PATH)
31
+ end
32
+
33
+ should create_paths(NS_SIMPLE.new)
34
+ should create_paths(NS_UNDER.new)
35
+ should create_paths(NS_HYPHEN.new)
36
+
37
+ should "init a git repo in the gem path" do
38
+ exp_path = File.join(TMP_PATH, NS_SIMPLE.new.name, '.git')
39
+ assert File.exists?(exp_path), ".git repo config doesn't exist"
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,23 @@
1
+ require "assert"
2
+ require "ggem/gem"
3
+
4
+ class GGem::Gem
5
+
6
+ class BaseTests < Assert::Context
7
+ desc "GGem::Gem"
8
+ setup do
9
+ @gem = GGem::Gem.new(TMP_PATH, 'a-gem')
10
+ end
11
+ subject { @gem }
12
+
13
+ should have_readers :root_path, :name
14
+ should have_imeths :save!, :path, :name=, :module_name, :ruby_name
15
+
16
+ should "know its root path and path" do
17
+ assert_equal TMP_PATH, subject.root_path
18
+ assert_equal File.join(TMP_PATH, 'a-gem'), subject.path
19
+ end
20
+
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ggem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 1.3.0
10
+ version: 1.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-15 00:00:00 Z
18
+ date: 2013-02-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: assert
@@ -31,20 +31,6 @@ dependencies:
31
31
  type: :development
32
32
  requirement: *id001
33
33
  prerelease: false
34
- - !ruby/object:Gem::Dependency
35
- name: quickl
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- type: :runtime
46
- requirement: *id002
47
- prerelease: false
48
34
  description: "\"Juh Gem\", baby! (this makes gems)"
49
35
  email:
50
36
  - kelly@kellyredding.com
@@ -57,7 +43,7 @@ extra_rdoc_files: []
57
43
  files:
58
44
  - .gitignore
59
45
  - Gemfile
60
- - LICENSE
46
+ - LICENSE.txt
61
47
  - README.md
62
48
  - Rakefile
63
49
  - bin/ggem
@@ -67,7 +53,7 @@ files:
67
53
  - lib/ggem/gem.rb
68
54
  - lib/ggem/template.rb
69
55
  - lib/ggem/template_file/Gemfile.erb
70
- - lib/ggem/template_file/LICENSE.erb
56
+ - lib/ggem/template_file/LICENSE.txt.erb
71
57
  - lib/ggem/template_file/README.md.erb
72
58
  - lib/ggem/template_file/Rakefile.erb
73
59
  - lib/ggem/template_file/gemspec.erb
@@ -75,12 +61,11 @@ files:
75
61
  - lib/ggem/template_file/lib.rb.erb
76
62
  - lib/ggem/template_file/lib_version.rb.erb
77
63
  - lib/ggem/template_file/test_helper.rb.erb
78
- - lib/ggem/template_file/test_irb.rb.erb
79
64
  - lib/ggem/version.rb
80
- - test/gem_tests.rb
81
65
  - test/helper.rb
82
- - test/irb.rb
83
- - test/name_set.rb
66
+ - test/support/name_set.rb
67
+ - test/system/ggem_tests.rb
68
+ - test/unit/gem_tests.rb
84
69
  homepage: http://github.com/kellyredding/ggem
85
70
  licenses: []
86
71
 
@@ -115,7 +100,7 @@ signing_key:
115
100
  specification_version: 3
116
101
  summary: "\"Juh Gem\", baby! (this makes gems)"
117
102
  test_files:
118
- - test/gem_tests.rb
119
103
  - test/helper.rb
120
- - test/irb.rb
121
- - test/name_set.rb
104
+ - test/support/name_set.rb
105
+ - test/system/ggem_tests.rb
106
+ - test/unit/gem_tests.rb
@@ -1,9 +0,0 @@
1
- require 'assert/setup'
2
-
3
- # this file is required in when the 'irb' rake test is run.
4
- # b/c 'assert/setup' is required above, the test helper will be
5
- # required in as well.
6
-
7
- # put any IRB setup code here
8
-
9
- require '<%= @gem.ruby_name %>'
@@ -1,57 +0,0 @@
1
- require "assert"
2
- require "name_set"
3
-
4
- require "ggem/gem"
5
-
6
- module GGem
7
- class GGemTests < Assert::Context
8
- desc "GGem::Gem"
9
- end
10
-
11
- class RootPathTests < GGemTests
12
- before { @gem = Gem.new(TMP_PATH, 'a-gem') }
13
-
14
- should "know its root path" do
15
- assert_equal TMP_PATH, @gem.root_path
16
- end
17
-
18
- should "know its path" do
19
- assert_equal File.join(TMP_PATH, 'a-gem'), @gem.path
20
- end
21
- end
22
-
23
- class NameTests < GGemTests
24
- [ GGem::NameSet::Simple,
25
- GGem::NameSet::Underscored,
26
- GGem::NameSet::HyphenatedOther
27
- ].each do |ns|
28
- should generate_name_set(ns.new)
29
- end
30
- end
31
-
32
- class SaveTests < GGemTests
33
- NS_SIMPLE = GGem::NameSet::Simple.new
34
- NS_UNDER = GGem::NameSet::Underscored.new
35
- NS_HYPHEN = GGem::NameSet::HyphenatedOther.new
36
-
37
- desc "after it's been saved"
38
- setup_once do
39
- FileUtils.mkdir_p(TMP_PATH)
40
- Gem.new(TMP_PATH, NS_SIMPLE.variations.first).save
41
- Gem.new(TMP_PATH, NS_UNDER.variations.first).save
42
- Gem.new(TMP_PATH, NS_HYPHEN.variations.first).save
43
- end
44
- teardown_once do
45
- FileUtils.rm_rf(TMP_PATH)
46
- end
47
-
48
- should create_paths(NS_SIMPLE)
49
- should create_paths(NS_UNDER)
50
- should create_paths(NS_HYPHEN)
51
-
52
- should "init a git repo in the gem path" do
53
- assert File.exists?(File.join(TMP_PATH, NS_SIMPLE.name, '.git')), ".git repo config doesn't exist"
54
- end
55
- end
56
-
57
- end
@@ -1,9 +0,0 @@
1
- require 'assert/setup'
2
-
3
- # this file is required in when the 'irb' rake test is run.
4
- # b/c 'assert' is required above, the test helper will be
5
- # required in.
6
-
7
- # put any IRB setup code here
8
-
9
- require 'ggem'