reagent-simple-gem 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,7 +23,7 @@ But GitHub doesn't seem to consistently build gems, so use this as a fallback:
23
23
 
24
24
  This will create a gem structure under the 'my-gem' directory. The command is pretty forgiving with the name you supply, it will automatically transform anything that is camelcased into something more ruby-like.
25
25
 
26
- After generating your gem, go ahead and add information about your gem to both the <tt>Rakefile</tt> and <tt>README.markdown</tt> files. The default version number is "0.1.0", but if you want to change that, take a look at <tt>lib/my_gem/version.rb</tt> to make the change - this will automatically be picked up when you rebuild your gem.
26
+ After generating your gem, go ahead and add information about your gem to both the <tt>Rakefile</tt> and <tt>README.rdoc</tt> files. The default version number is "0.1.0", but if you want to change that, take a look at <tt>lib/my_gem/version.rb</tt> to make the change - this will automatically be picked up when you rebuild your gem.
27
27
 
28
28
  Your new gem provides some Rake tasks for convenience:
29
29
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17
17
  s.email = 'reaganpr@gmail.com'
18
18
  s.homepage = 'http://sneaq.net'
19
19
  s.executables = ['simple-gem']
20
- s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test,templates}/**/*")
20
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test,templates}/**/.?*")
21
21
  end
22
22
 
23
23
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -0,0 +1,3 @@
1
+ /pkg/
2
+ /doc/
3
+ /coverage/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reagent-simple-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Reagan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-12 00:00:00 -08:00
12
+ date: 2009-01-05 00:00:00 -08:00
13
13
  default_executable: simple-gem
14
14
  dependencies: []
15
15
 
@@ -24,18 +24,12 @@ extra_rdoc_files:
24
24
  files:
25
25
  - README.rdoc
26
26
  - Rakefile
27
- - lib/simple_gem
28
- - lib/simple_gem/gem.rb
29
- - lib/simple_gem/version.rb
30
- - lib/simple_gem.rb
31
- - test/simple_gem
32
- - test/simple_gem/gem_test.rb
33
- - templates/lib.rb.erb
34
- - templates/lib_version.rb.erb
35
- - templates/Rakefile.erb
36
- - templates/README.rdoc.erb
37
- - templates/test.rb.erb
38
- - templates/test_helper.rb.erb
27
+ - lib/..
28
+ - lib/simple_gem/..
29
+ - test/..
30
+ - test/simple_gem/..
31
+ - templates/..
32
+ - templates/.gitignore.erb
39
33
  - bin/simple-gem
40
34
  has_rdoc: true
41
35
  homepage: http://sneaq.net
@@ -1,2 +0,0 @@
1
- require 'simple_gem/version'
2
- require 'simple_gem/gem'
@@ -1,60 +0,0 @@
1
- require 'erb'
2
-
3
- module SimpleGem
4
- class Gem
5
-
6
- attr_reader :root_path, :name
7
-
8
- def initialize(path, name)
9
- @root_path = path
10
- self.name = name
11
- end
12
-
13
- def name=(name)
14
- @name = name.gsub(/([A-Z])([a-z])/, '_\1\2').sub(/^_/, '').downcase
15
- end
16
-
17
- def module_name
18
- transform_name {|part| part.capitalize }
19
- end
20
-
21
- def ruby_name
22
- transform_name('_') {|part| part.downcase }
23
- end
24
-
25
- def generate
26
- generate_root_directory
27
- generate_subdirectories
28
- generate_file('lib.rb.erb', "lib/#{self.ruby_name}.rb")
29
- generate_file('lib_version.rb.erb', "lib/#{self.ruby_name}/version.rb")
30
- generate_file('Rakefile.erb', 'Rakefile')
31
- generate_file('README.rdoc.erb', 'README.rdoc')
32
- generate_file('test_helper.rb.erb', 'test/test_helper.rb')
33
- generate_file('test.rb.erb', "test/unit/#{self.ruby_name}_test.rb")
34
- end
35
-
36
- private
37
- def transform_name(glue = nil, &block)
38
- self.name.split(/[_-]/).map {|part| block.call(part) }.join(glue)
39
- end
40
-
41
- def generate_root_directory
42
- FileUtils.mkdir("#{self.root_path}/#{self.name}")
43
- end
44
-
45
- def generate_subdirectories
46
- ['lib', 'test', "lib/#{self.ruby_name}", 'test/unit'].each do |dir|
47
- FileUtils.mkdir("#{self.root_path}/#{self.name}/#{dir}")
48
- end
49
- end
50
-
51
- def generate_file(source, output)
52
- source_file = File.dirname(__FILE__) + "/../../templates/#{source}"
53
- output_file = "#{self.root_path}/#{self.name}/#{output}"
54
-
55
- erb = ERB.new(File.read(source_file))
56
- File.open(output_file, 'w') {|f| f << erb.result(binding) }
57
- end
58
-
59
- end
60
- end
@@ -1,13 +0,0 @@
1
- module SimpleGem
2
- module Version
3
-
4
- MAJOR = 0
5
- MINOR = 3
6
- TINY = 0
7
-
8
- def self.to_s
9
- [MAJOR, MINOR, TINY].join('.')
10
- end
11
-
12
- end
13
- end
@@ -1,38 +0,0 @@
1
- = <%= self.module_name %>
2
-
3
- == Description
4
-
5
- Describe your gem here ...
6
-
7
- == Installation
8
-
9
- sudo gem install <%= self.name %>
10
-
11
- == Usage
12
-
13
- require '<%= self.ruby_name %>'
14
-
15
- == License
16
-
17
- Copyright (c) <year> <copyright holders>
18
-
19
- Permission is hereby granted, free of charge, to any person
20
- obtaining a copy of this software and associated documentation
21
- files (the "Software"), to deal in the Software without
22
- restriction, including without limitation the rights to use,
23
- copy, modify, merge, publish, distribute, sublicense, and/or sell
24
- copies of the Software, and to permit persons to whom the
25
- Software is furnished to do so, subject to the following
26
- conditions:
27
-
28
- The above copyright notice and this permission notice shall be
29
- included in all copies or substantial portions of the Software.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
33
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
35
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
36
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
38
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,40 +0,0 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'rake/testtask'
4
-
5
- require 'lib/<%= self.ruby_name %>/version'
6
-
7
- task :default => :test
8
-
9
- spec = Gem::Specification.new do |s|
10
- s.name = '<%= self.name %>'
11
- s.version = <%= self.module_name %>::Version.to_s
12
- s.has_rdoc = true
13
- s.extra_rdoc_files = %w(README.rdoc)
14
- s.rdoc_options = %w(--main README.rdoc)
15
- s.summary = "This gem does ... "
16
- s.author = 'First Last'
17
- s.email = 'user@example.com'
18
- s.homepage = 'http://my-site.net'
19
- s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test}/**/*")
20
- # s.executables = ['<%= self.name %>']
21
-
22
- # s.add_dependency('gem_name', '~> 0.0.1')
23
- end
24
-
25
- Rake::GemPackageTask.new(spec) do |pkg|
26
- pkg.gem_spec = spec
27
- end
28
-
29
- Rake::TestTask.new do |t|
30
- t.libs << 'test'
31
- t.test_files = FileList["test/**/*_test.rb"]
32
- t.verbose = true
33
- end
34
-
35
- desc 'Generate the gemspec to serve this Gem from Github'
36
- task :github do
37
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
38
- File.open(file, 'w') {|f| f << spec.to_ruby }
39
- puts "Created gemspec: #{file}"
40
- end
@@ -1 +0,0 @@
1
- # require '<%= self.ruby_name %>/...'
@@ -1,13 +0,0 @@
1
- module <%= self.module_name %>
2
- module Version
3
-
4
- MAJOR = 0
5
- MINOR = 1
6
- TINY = 0
7
-
8
- def self.to_s # :nodoc:
9
- [MAJOR, MINOR, TINY].join('.')
10
- end
11
-
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class <%= self.module_name %>Test < Test::Unit::TestCase
4
-
5
- describe "An instance of the <%= self.module_name %> class" do
6
-
7
- it "should flunk" do
8
- flunk "Please provide some tests"
9
- end
10
-
11
- end
12
-
13
- end
@@ -1,7 +0,0 @@
1
- # http://sneaq.net/textmate-wtf
2
- $:.reject! { |e| e.include? 'TextMate' }
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'matchy'
7
- require 'context'
@@ -1,108 +0,0 @@
1
- require 'rubygems'
2
- require 'context'
3
- require 'matchy'
4
-
5
- require File.dirname(__FILE__) + '/../../lib/simple_gem/gem'
6
-
7
- module SimpleGem
8
- class GemTest < Test::Unit::TestCase
9
-
10
- def self.should_generate(expectations)
11
- describe "An instance of Gem when given a #{expectations[:from]} name" do
12
- before do
13
- path = '/this/path'
14
- @name = expectations[:from]
15
- @gem = Gem.new(path, @name)
16
- end
17
-
18
- expectations.each do |k,v|
19
- unless k == :from
20
- it "should know its #{k}" do
21
- @gem.send(k).should == v
22
- end
23
- end
24
- end
25
- end
26
- end
27
-
28
- should_generate :name => 'simple_gem',
29
- :module_name => 'SimpleGem',
30
- :ruby_name => 'simple_gem',
31
- :from => 'SimpleGem'
32
-
33
-
34
- should_generate :name => 'simple-gem',
35
- :module_name => 'SimpleGem',
36
- :ruby_name => 'simple_gem',
37
- :from => 'simple-gem'
38
-
39
- should_generate :name => 'simple_gem',
40
- :module_name => 'SimpleGem',
41
- :ruby_name => 'simple_gem',
42
- :from => 'simple_gem'
43
-
44
- should_generate :name => 'simple_gem',
45
- :module_name => 'SimpleGem',
46
- :ruby_name => 'simple_gem',
47
- :from => 'simpleGem'
48
-
49
- describe "An instance of Gem" do
50
- before { @path = '/this/path' }
51
-
52
- it "should know its root path" do
53
- Gem.new(@path, 'name').root_path.should == @path
54
- end
55
-
56
- context "when generating the directory structure" do
57
-
58
- before do
59
- @tmp_dir = File.dirname(__FILE__) + '/../../tmp'
60
- FileUtils.mkdir(@tmp_dir) unless File.exist?(@tmp_dir)
61
-
62
- @name = 'simple-gem'
63
- Gem.new(@tmp_dir, @name).generate
64
- end
65
-
66
- after do
67
- FileUtils.rm_rf(@tmp_dir)
68
- end
69
-
70
- it "should be able to make the root directory" do
71
- File.exist?("#{@tmp_dir}/#{@name}").should == true
72
- end
73
-
74
- %w(lib test lib/simple_gem test/unit).each do |dir|
75
- it "should create the #{dir} subdirectory" do
76
- File.exist?("#{@tmp_dir}/#{@name}/#{dir}").should == true
77
- end
78
- end
79
-
80
- it "should create the main library file" do
81
- File.exist?("#{@tmp_dir}/#{@name}/lib/simple_gem.rb").should == true
82
- end
83
-
84
- it "should create the version file" do
85
- File.exist?("#{@tmp_dir}/#{@name}/lib/simple_gem/version.rb").should == true
86
- end
87
-
88
- it "should create the main Rakefile" do
89
- File.exist?("#{@tmp_dir}/#{@name}/Rakefile").should == true
90
- end
91
-
92
- it "should create the README file" do
93
- File.exist?("#{@tmp_dir}/#{@name}/README.rdoc").should == true
94
- end
95
-
96
- it "should generate the test helper file" do
97
- File.exist?("#{@tmp_dir}/#{@name}/test/test_helper.rb").should == true
98
- end
99
-
100
- it "should generate the test file" do
101
- File.exist?("#{@tmp_dir}/#{@name}/test/unit/simple_gem_test.rb").should == true
102
- end
103
-
104
- end
105
-
106
- end
107
- end
108
- end