gram 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -23,6 +23,24 @@ The `my_blogpost.markdown` file should be a regular markdown file with some head
23
23
  # My awesome header
24
24
  ## More markdown goodness, etc.
25
25
 
26
+ ##Gem component
27
+
28
+ To bootstrap a new gem, type this:
29
+
30
+ $ gram gem create my_gem
31
+
32
+ By default, the new gem will be using Minitest & Mocha. If you prefer RSpec:
33
+
34
+ $ gram gem create my_gem --rspec
35
+
36
+ And if you want to create a Rails extension or anything requiring ActiveRecord,
37
+ just use the `--rails` option:
38
+
39
+ $ gram gem create my_gem --rails
40
+
41
+ This will add the required dependencies and enable the test suite to use
42
+ ActiveRecord with in-memory sqlite :)
43
+
26
44
  ## Copyright
27
45
 
28
46
  Copyright (c) 2011 Codegram. See LICENSE for details.
@@ -11,13 +11,19 @@ module Gram
11
11
  no_tasks do
12
12
  def generate(name, options)
13
13
  @rails = true if options.include?("--rails")
14
+ @rspec = true if options.include?("--rspec")
15
+
14
16
  @underscored = name.underscore
15
17
  @camelized = name.camelize
16
18
 
17
19
  run "bundle gem #{@underscored}"
18
20
 
19
21
  remove_file("#{@underscored}/Rakefile")
20
- template('templates/Rakefile.tt', "#{@underscored}/Rakefile")
22
+ if rspec
23
+ template('templates/Rakefile_rspec.tt', "#{@underscored}/Rakefile")
24
+ else
25
+ template('templates/Rakefile.tt', "#{@underscored}/Rakefile")
26
+ end
21
27
 
22
28
  remove_file("#{@underscored}/.gitignore")
23
29
  template('templates/gitignore.tt', "#{@underscored}/.gitignore")
@@ -26,7 +32,12 @@ module Gram
26
32
  template('templates/rvmrc.tt', "#{@underscored}/.rvmrc")
27
33
 
28
34
  empty_directory "#{@underscored}/spec"
29
- template('templates/spec/spec_helper.tt', "#{@underscored}/spec/spec_helper.rb")
35
+
36
+ if rspec
37
+ template('templates/spec/rspec_helper.tt', "#{@underscored}/spec/spec_helper.rb")
38
+ else
39
+ template('templates/spec/minispec_helper.tt', "#{@underscored}/spec/spec_helper.rb")
40
+ end
30
41
 
31
42
  inject_into_file "#{@underscored}/#{@underscored}.gemspec", :after => "s.rubyforge_project = \"#{@underscored}\"" do
32
43
  runtime_dependencies = []
@@ -34,8 +45,13 @@ module Gram
34
45
 
35
46
  development_dependencies = []
36
47
  development_dependencies << " s.add_runtime_dependency 'sqlite3'" if rails
48
+ if rspec
49
+ development_dependencies << " s.add_development_dependency 'rspec', '~> 2.5.0'"
50
+ else
51
+ development_dependencies << " s.add_development_dependency 'minitest'"
52
+ end
53
+ development_dependencies << " s.add_development_dependency 'mocha'" unless rspec
37
54
  development_dependencies += [
38
- " s.add_development_dependency 'rspec', '~> 2.5.0'",
39
55
  " s.add_development_dependency 'yard'",
40
56
  " s.add_development_dependency 'bluecloth'" ]
41
57
 
@@ -57,6 +73,10 @@ module Gram
57
73
  def rails
58
74
  @rails
59
75
  end
76
+
77
+ def rspec
78
+ @rspec
79
+ end
60
80
  end
61
81
  end
62
82
  end
@@ -1,9 +1,13 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
4
+ require 'rake/testtask'
5
5
  desc "Run <%= underscored %> specs"
6
- RSpec::Core::RakeTask.new
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "spec"
8
+ t.test_files = FileList['spec/**/*_spec.rb']
9
+ t.verbose = true
10
+ end
7
11
 
8
12
  require 'yard'
9
13
  YARD::Rake::YardocTask.new(:docs) do |t|
@@ -44,4 +48,4 @@ task :graph do |t|
44
48
  `bundle exec yard graph -d --full --no-private | dot -Tpng -o graph.png && open graph.png`
45
49
  end
46
50
 
47
- task :default => [:spec]
51
+ task :default => [:test]
@@ -0,0 +1,47 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ desc "Run <%= underscored %> specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ require 'yard'
9
+ YARD::Rake::YardocTask.new(:docs) do |t|
10
+ t.files = ['lib/**/*.rb']
11
+ t.options = ['-m', 'markdown', '--no-private', '-r', 'Readme.md', '--title', '<%= camelized %> documentation']
12
+ end
13
+
14
+ site = 'doc'
15
+ source_branch = 'master'
16
+ deploy_branch = 'gh-pages'
17
+
18
+ desc "generate and deploy documentation website to github pages"
19
+ multitask :pages do
20
+ puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
21
+ require 'git'
22
+ repo = Git.open('.')
23
+ puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
24
+ repo.branch("#{deploy_branch}").checkout
25
+ (Dir["*"] - [site]).each { |f| rm_rf(f) }
26
+ Dir["#{site}/*"].each {|f| mv(f, "./")}
27
+ rm_rf(site)
28
+ puts "\n>>> Moving generated site files <<<\n"
29
+ Dir["**/*"].each {|f| repo.add(f) }
30
+ repo.status.deleted.each {|f, s| repo.remove(f)}
31
+ puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
32
+ message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}"
33
+ repo.commit(message)
34
+ puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
35
+ repo.push
36
+ puts "\n>>> Github Pages deploy complete <<<\n"
37
+ repo.branch("#{source_branch}").checkout
38
+ end
39
+
40
+ task :doc => [:docs]
41
+
42
+ desc "Generate and open class diagram (needs Graphviz installed)"
43
+ task :graph do |t|
44
+ `bundle exec yard graph -d --full --no-private | dot -Tpng -o graph.png && open graph.png`
45
+ end
46
+
47
+ task :default => [:spec]
@@ -0,0 +1,22 @@
1
+ gem 'minitest'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require 'mocha'
5
+
6
+ require '<%= underscored %>'
7
+ <% if rails %>
8
+
9
+ ActiveRecord::Base.establish_connection(
10
+ :adapter => 'sqlite3',
11
+ :database => ':memory:'
12
+ )
13
+
14
+ ActiveRecord::Schema.define do
15
+ create_table :articles do |t|
16
+ t.string :name
17
+ t.integer :price
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module Gram
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -38,7 +38,8 @@ module Gram
38
38
  file ".rvmrc"
39
39
  file "Readme.md"
40
40
  file "my_gem.gemspec" do
41
- contains "rspec"
41
+ contains "minitest"
42
+ contains "mocha"
42
43
  contains "yard"
43
44
  contains "bluecloth"
44
45
  end
@@ -49,45 +50,80 @@ module Gram
49
50
  end
50
51
  end
51
52
  directory "spec" do
52
- file "spec_helper.rb"
53
+ file "spec_helper.rb" do
54
+ contains "minitest/spec"
55
+ end
53
56
  end
54
57
  end
55
58
  }
56
59
  end
60
+ end
57
61
 
58
- context 'with --rails' do
59
- it 'creates a new rails-ready gem' do
60
- FileUtils.chdir File.expand_path('../../../../tmp', __FILE__)
61
- Generator.new.generate('my_gem', ['--rails'])
62
- destination_root.should have_structure {
63
- directory "my_gem" do
64
- file "Gemfile"
65
- file "Rakefile"
66
- file ".gitignore"
67
- file ".rvmrc"
68
- file "Readme.md"
69
- file "my_gem.gemspec" do
70
- contains "activerecord"
71
- contains "sqlite3"
62
+ context 'with --rails' do
63
+ it 'creates a new rails-ready gem' do
64
+ FileUtils.chdir File.expand_path('../../../../tmp', __FILE__)
65
+ Generator.new.generate('my_gem', ['--rails'])
66
+ destination_root.should have_structure {
67
+ directory "my_gem" do
68
+ file "Gemfile"
69
+ file "Rakefile"
70
+ file ".gitignore"
71
+ file ".rvmrc"
72
+ file "Readme.md"
73
+ file "my_gem.gemspec" do
74
+ contains "activerecord"
75
+ contains "sqlite3"
72
76
 
73
- contains "rspec"
74
- contains "yard"
75
- contains "bluecloth"
77
+ contains "minitest"
78
+ contains "mocha"
79
+ contains "bluecloth"
80
+ end
81
+ directory "lib" do
82
+ file "my_gem.rb"
83
+ directory "my_gem" do
84
+ file "version.rb"
76
85
  end
77
- directory "lib" do
78
- file "my_gem.rb"
79
- directory "my_gem" do
80
- file "version.rb"
81
- end
86
+ end
87
+ directory "spec" do
88
+ file "spec_helper.rb" do
89
+ contains "minitest/spec"
90
+ contains "ActiveRecord"
91
+ end
92
+ end
93
+ end
94
+ }
95
+ end
96
+ end
97
+
98
+ context 'with --rspec' do
99
+ it 'creates a new rspec-ready gem' do
100
+ FileUtils.chdir File.expand_path('../../../../tmp', __FILE__)
101
+ Generator.new.generate('my_gem', ['--rspec'])
102
+ destination_root.should have_structure {
103
+ directory "my_gem" do
104
+ file "Gemfile"
105
+ file "Rakefile"
106
+ file ".gitignore"
107
+ file ".rvmrc"
108
+ file "Readme.md"
109
+ file "my_gem.gemspec" do
110
+ contains "rspec"
111
+ contains "yard"
112
+ contains "bluecloth"
113
+ end
114
+ directory "lib" do
115
+ file "my_gem.rb"
116
+ directory "my_gem" do
117
+ file "version.rb"
82
118
  end
83
- directory "spec" do
84
- file "spec_helper.rb" do
85
- contains "ActiveRecord"
86
- end
119
+ end
120
+ directory "spec" do
121
+ file "spec_helper.rb" do
122
+ contains "rspec"
87
123
  end
88
124
  end
89
- }
90
- end
125
+ end
126
+ }
91
127
  end
92
128
  end
93
129
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gram
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josep M. Bach
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-03-21 00:00:00 +01:00
15
+ date: 2011-04-04 00:00:00 +02:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -128,10 +128,12 @@ files:
128
128
  - lib/gram/gem.rb
129
129
  - lib/gram/gem/generator.rb
130
130
  - lib/gram/gem/templates/Rakefile.tt
131
+ - lib/gram/gem/templates/Rakefile_rspec.tt
131
132
  - lib/gram/gem/templates/Readme.tt
132
133
  - lib/gram/gem/templates/gitignore.tt
133
134
  - lib/gram/gem/templates/rvmrc.tt
134
- - lib/gram/gem/templates/spec/spec_helper.tt
135
+ - lib/gram/gem/templates/spec/minispec_helper.tt
136
+ - lib/gram/gem/templates/spec/rspec_helper.tt
135
137
  - lib/gram/version.rb
136
138
  - spec/gram/blog/parser_spec.rb
137
139
  - spec/gram/blog_spec.rb