dm-gen 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGELOG.rdoc +6 -0
  3. data/LICENSE +1 -1
  4. data/README.rdoc +2 -3
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/dm-gen.gemspec +105 -0
  8. data/lib/dm-gen/generators/adapter.rb +3 -30
  9. data/lib/dm-gen/generators/is.rb +2 -26
  10. data/lib/dm-gen/generators/plugin_generator.rb +44 -0
  11. data/lib/dm-gen/templates/adapter/.gitignore +35 -0
  12. data/lib/dm-gen/templates/adapter/Gemfile +82 -0
  13. data/lib/dm-gen/templates/adapter/LICENSE +1 -1
  14. data/lib/dm-gen/templates/adapter/README.rdoc +3 -0
  15. data/lib/dm-gen/templates/adapter/Rakefile +17 -24
  16. data/lib/dm-gen/templates/adapter/lib/%gem_name%.rb +1 -0
  17. data/lib/dm-gen/templates/adapter/lib/{%adapter_file%.rb → %gem_name%/adapter.rb} +8 -17
  18. data/lib/dm-gen/templates/adapter/lib/%gem_name%/spec/setup.rb +21 -0
  19. data/lib/dm-gen/templates/adapter/spec/adapter_spec.rb +21 -0
  20. data/lib/dm-gen/templates/adapter/spec/rcov.opts +5 -0
  21. data/lib/dm-gen/templates/adapter/spec/spec.opts +2 -0
  22. data/lib/dm-gen/templates/adapter/spec/spec_helper.rb +4 -9
  23. data/lib/dm-gen/templates/adapter/tasks/local_gemfile.rake +18 -0
  24. data/lib/dm-gen/templates/adapter/tasks/spec.rake +38 -0
  25. data/lib/dm-gen/templates/adapter/tasks/yard.rake +9 -0
  26. data/lib/dm-gen/templates/adapter/tasks/yardstick.rake +19 -0
  27. data/lib/dm-gen/templates/is/.gitignore +36 -0
  28. data/lib/dm-gen/templates/is/Gemfile +143 -0
  29. data/lib/dm-gen/templates/is/LICENSE +1 -1
  30. data/lib/dm-gen/templates/is/README.rdoc +2 -0
  31. data/lib/dm-gen/templates/is/Rakefile +16 -24
  32. data/lib/dm-gen/templates/is/VERSION +1 -0
  33. data/lib/dm-gen/templates/is/lib/%gem_name%.rb +1 -8
  34. data/lib/dm-gen/templates/is/lib/%gem_name%/is/%name%.rb +30 -0
  35. data/lib/dm-gen/templates/is/spec/integration/%name%_spec.rb +16 -0
  36. data/lib/dm-gen/templates/is/spec/rcov.opts +6 -0
  37. data/lib/dm-gen/templates/is/spec/spec.opts +3 -0
  38. data/lib/dm-gen/templates/is/spec/spec_helper.rb +7 -21
  39. data/lib/dm-gen/templates/is/tasks/ci.rake +1 -0
  40. data/lib/dm-gen/templates/is/tasks/local_gemfile.rake +18 -0
  41. data/lib/dm-gen/templates/is/tasks/metrics.rake +36 -0
  42. data/lib/dm-gen/templates/is/tasks/spec.rake +38 -0
  43. data/lib/dm-gen/templates/is/tasks/yard.rake +9 -0
  44. data/lib/dm-gen/templates/is/tasks/yardstick.rake +19 -0
  45. data/lib/dm-gen/templates/one_file.rb +3 -2
  46. data/lib/dm_gen.rb +1 -1
  47. data/spec/adapter_spec.rb +34 -52
  48. data/spec/is_plugin_spec.rb +13 -28
  49. metadata +59 -30
  50. data/lib/dm-gen/templates/adapter/History.txt +0 -4
  51. data/lib/dm-gen/templates/adapter/Manifest.txt +0 -1
  52. data/lib/dm-gen/templates/adapter/README.txt +0 -3
  53. data/lib/dm-gen/templates/adapter/TODO +0 -0
  54. data/lib/dm-gen/templates/adapter/lib/%adapter_file%/version.rb +0 -5
  55. data/lib/dm-gen/templates/adapter/spec/integration/%adapter_file%_spec.rb +0 -36
  56. data/lib/dm-gen/templates/adapter/tasks/install.rb +0 -13
  57. data/lib/dm-gen/templates/adapter/tasks/spec.rb +0 -25
  58. data/lib/dm-gen/templates/is/History.txt +0 -4
  59. data/lib/dm-gen/templates/is/Manifest.txt +0 -1
  60. data/lib/dm-gen/templates/is/README.txt +0 -3
  61. data/lib/dm-gen/templates/is/TODO +0 -0
  62. data/lib/dm-gen/templates/is/lib/%gem_name%/is/%snake_name%.rb +0 -38
  63. data/lib/dm-gen/templates/is/lib/%gem_name%/is/version.rb +0 -7
  64. data/lib/dm-gen/templates/is/spec/integration/%snake_name%_spec.rb +0 -8
  65. data/lib/dm-gen/templates/is/tasks/install.rb +0 -13
  66. data/lib/dm-gen/templates/is/tasks/spec.rb +0 -25
@@ -0,0 +1,4 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ *.gem
@@ -1,3 +1,9 @@
1
+ === 0.5.0 /
2
+
3
+ * Updated adapter generator to 1.0
4
+ * Updated is generator to 1.0
5
+ * Updated one file to 1.0
6
+
1
7
  === 0.4.2 / 2009-11-06
2
8
 
3
9
  * Updated is plugin generator
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Jonathan Stott
1
+ Copyright (c) 2008-2010 Jonathan Stott
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -39,9 +39,8 @@ adaptor API.
39
39
 
40
40
  dm-gen adapter example
41
41
 
42
- NB: This generates adapters with the 0.10.x API NOT the 0.9.x API. So make sure
43
- you're running a recent DataMapper release.
42
+ NB: This generates adapters with the 1.0 API, so make sure you're running that
44
43
 
45
44
  == COPYRIGHT
46
45
 
47
- Copyright (c) 2008-2009 Jonathan Stott. See LICENSE for details.
46
+ Copyright (c) 2008-2010 Jonathan Stott. See LICENSE for details.
@@ -0,0 +1,53 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = "dm-gen"
9
+ s.summary = "Simple commandline tool for generating DataMapper related files"
10
+ s.email = "jonathan.stott@gmail.com"
11
+ s.homepage = "http://github.com/namelessjon/dm-gen"
12
+ s.description = <<-eos
13
+ dm-gen is a simple commandline tool for generating DataMapper related files.
14
+ It includes generators for standalone or one file examples, is plugins, adapters
15
+ and may eventually be expanded to do more.
16
+ eos
17
+ s.authors = ["Jonathan Stott"]
18
+ s.executables = 'dm-gen'
19
+ s.rdoc_options = %w{--exclude lib/dm-gen/templates --title dm-gen --line-numbers --inline-source --main README.rdoc}
20
+ s.add_dependency('templater', '~> 1.0')
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
25
+ puts "Or just 'gem build dm-gen.gemspec' and then install the gem."
26
+ end
27
+
28
+ Rake::TestTask.new(:spec) do |t|
29
+ t.libs << 'lib'
30
+ t.pattern = 'spec/**/*_spec.rb'
31
+ t.verbose = false
32
+ end
33
+
34
+ Rake::RDocTask.new do |rdoc|
35
+ rdoc.rdoc_dir = 'rdoc'
36
+ rdoc.title = 'dm-gen'
37
+ rdoc.options << '--line-numbers' << '--inline-source'
38
+ rdoc.rdoc_files.include('README*')
39
+ rdoc.rdoc_files.include('lib/**/*.rb')
40
+ end
41
+
42
+ begin
43
+ require 'rcov/rcovtask'
44
+ Rcov::RcovTask.new do |t|
45
+ t.libs << "spec"
46
+ t.test_files = FileList['spec/**/*_spec.rb']
47
+ t.verbose = true
48
+ end
49
+ rescue LoadError
50
+ # just do nothing
51
+ end
52
+
53
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -0,0 +1,105 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dm-gen}
8
+ s.version = "0.5.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jonathan Stott"]
12
+ s.date = %q{2010-06-09}
13
+ s.default_executable = %q{dm-gen}
14
+ s.description = %q{dm-gen is a simple commandline tool for generating DataMapper related files.
15
+ It includes generators for standalone or one file examples, is plugins, adapters
16
+ and may eventually be expanded to do more.
17
+ }
18
+ s.email = %q{jonathan.stott@gmail.com}
19
+ s.executables = ["dm-gen"]
20
+ s.extra_rdoc_files = [
21
+ "LICENSE",
22
+ "README.rdoc"
23
+ ]
24
+ s.files = [
25
+ ".gitignore",
26
+ "CHANGELOG.rdoc",
27
+ "LICENSE",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "bin/dm-gen",
32
+ "dm-gen.gemspec",
33
+ "lib/dm-gen/generators/adapter.rb",
34
+ "lib/dm-gen/generators/is.rb",
35
+ "lib/dm-gen/generators/one_file.rb",
36
+ "lib/dm-gen/generators/plugin_generator.rb",
37
+ "lib/dm-gen/templates/adapter/.gitignore",
38
+ "lib/dm-gen/templates/adapter/Gemfile",
39
+ "lib/dm-gen/templates/adapter/LICENSE",
40
+ "lib/dm-gen/templates/adapter/README.rdoc",
41
+ "lib/dm-gen/templates/adapter/Rakefile",
42
+ "lib/dm-gen/templates/adapter/lib/%gem_name%.rb",
43
+ "lib/dm-gen/templates/adapter/lib/%gem_name%/adapter.rb",
44
+ "lib/dm-gen/templates/adapter/lib/%gem_name%/spec/setup.rb",
45
+ "lib/dm-gen/templates/adapter/spec/adapter_spec.rb",
46
+ "lib/dm-gen/templates/adapter/spec/rcov.opts",
47
+ "lib/dm-gen/templates/adapter/spec/spec.opts",
48
+ "lib/dm-gen/templates/adapter/spec/spec_helper.rb",
49
+ "lib/dm-gen/templates/adapter/tasks/local_gemfile.rake",
50
+ "lib/dm-gen/templates/adapter/tasks/spec.rake",
51
+ "lib/dm-gen/templates/adapter/tasks/yard.rake",
52
+ "lib/dm-gen/templates/adapter/tasks/yardstick.rake",
53
+ "lib/dm-gen/templates/is/.gitignore",
54
+ "lib/dm-gen/templates/is/Gemfile",
55
+ "lib/dm-gen/templates/is/LICENSE",
56
+ "lib/dm-gen/templates/is/README.rdoc",
57
+ "lib/dm-gen/templates/is/Rakefile",
58
+ "lib/dm-gen/templates/is/VERSION",
59
+ "lib/dm-gen/templates/is/lib/%gem_name%.rb",
60
+ "lib/dm-gen/templates/is/lib/%gem_name%/is/%name%.rb",
61
+ "lib/dm-gen/templates/is/spec/integration/%name%_spec.rb",
62
+ "lib/dm-gen/templates/is/spec/rcov.opts",
63
+ "lib/dm-gen/templates/is/spec/spec.opts",
64
+ "lib/dm-gen/templates/is/spec/spec_helper.rb",
65
+ "lib/dm-gen/templates/is/tasks/ci.rake",
66
+ "lib/dm-gen/templates/is/tasks/local_gemfile.rake",
67
+ "lib/dm-gen/templates/is/tasks/metrics.rake",
68
+ "lib/dm-gen/templates/is/tasks/spec.rake",
69
+ "lib/dm-gen/templates/is/tasks/yard.rake",
70
+ "lib/dm-gen/templates/is/tasks/yardstick.rake",
71
+ "lib/dm-gen/templates/one_file.rb",
72
+ "lib/dm_gen.rb",
73
+ "spec/adapter_spec.rb",
74
+ "spec/dm_gen_spec.rb",
75
+ "spec/is_plugin_spec.rb",
76
+ "spec/one_file_spec.rb",
77
+ "spec/spec_helper.rb"
78
+ ]
79
+ s.homepage = %q{http://github.com/namelessjon/dm-gen}
80
+ s.rdoc_options = ["--exclude", "lib/dm-gen/templates", "--title", "dm-gen", "--line-numbers", "--inline-source", "--main", "README.rdoc"]
81
+ s.require_paths = ["lib"]
82
+ s.rubygems_version = %q{1.3.7}
83
+ s.summary = %q{Simple commandline tool for generating DataMapper related files}
84
+ s.test_files = [
85
+ "spec/spec_helper.rb",
86
+ "spec/adapter_spec.rb",
87
+ "spec/dm_gen_spec.rb",
88
+ "spec/one_file_spec.rb",
89
+ "spec/is_plugin_spec.rb"
90
+ ]
91
+
92
+ if s.respond_to? :specification_version then
93
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
94
+ s.specification_version = 3
95
+
96
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
97
+ s.add_runtime_dependency(%q<templater>, ["~> 1.0"])
98
+ else
99
+ s.add_dependency(%q<templater>, ["~> 1.0"])
100
+ end
101
+ else
102
+ s.add_dependency(%q<templater>, ["~> 1.0"])
103
+ end
104
+ end
105
+
@@ -1,6 +1,7 @@
1
+ require 'dm-gen/generators/plugin_generator'
1
2
  module DMGen
2
3
  class Adapter < Templater::Generator
3
- first_argument :name, :required => true
4
+ include PluginGenerator
4
5
 
5
6
  desc <<-eos
6
7
  Generates a DataMapper Adapter skeleton.
@@ -12,42 +13,14 @@ module DMGen
12
13
  well as a Rakefile. All it needs is a README and some real functionality.
13
14
  eos
14
15
 
15
- def self.source_root
16
- File.join(File.dirname(__FILE__), '..', 'templates', 'adapter')
17
- end
18
-
19
16
  def gem_name
20
- "dm-#{adapter_name}"
21
- end
22
-
23
- def adapter_name
24
- "#{snake_name}-adapter"
25
- end
26
-
27
- def adapter_file
28
- "#{snake_name}_adapter"
29
- end
30
-
31
- def snake_name
32
- name.snake_case
17
+ "dm-#{snake_name}-adapter"
33
18
  end
34
19
 
35
20
  def class_name
36
21
  "#{name.camel_case}Adapter"
37
22
  end
38
23
 
39
- def destination_root
40
- File.join(@destination_root, gem_name)
41
- end
42
-
43
- # glob the template dir for all templates.
44
- # since we want text files processed, we have to replace the default
45
- # extension list.
46
- glob!('', %w[rb txt Rakefile LICENSE TODO])
47
-
48
- def manifest_files
49
- self.all_actions.map {|t| t.destination.gsub(/#{destination_root}\//,'') }.sort
50
- end
51
24
  end
52
25
 
53
26
  add :adapter, Adapter
@@ -1,6 +1,7 @@
1
+ require 'dm-gen/generators/plugin_generator'
1
2
  module DMGen
2
3
  class Is < Templater::Generator
3
- first_argument :name, :required => true
4
+ include PluginGenerator
4
5
 
5
6
  desc <<-eos
6
7
  Generates an 'is' plugin for DataMapper, such as dm-is-list.
@@ -13,34 +14,9 @@ module DMGen
13
14
 
14
15
  eos
15
16
 
16
- def self.source_root
17
- File.join(File.dirname(__FILE__), '..', 'templates', 'is')
18
- end
19
-
20
17
  def gem_name
21
18
  "dm-is-#{snake_name}"
22
19
  end
23
-
24
- def snake_name
25
- name.snake_case
26
- end
27
-
28
- def class_name
29
- name.camel_case
30
- end
31
-
32
- def destination_root
33
- File.join(@destination_root, gem_name)
34
- end
35
-
36
- # glob the template dir for all templates.
37
- # since we want text files processed, we have to replace the default
38
- # extension list.
39
- glob!('', %w[rb txt Rakefile LICENSE TODO])
40
-
41
- def manifest_files
42
- self.all_actions.map {|t| t.destination.gsub(/#{destination_root}\//,'') }.sort
43
- end
44
20
  end
45
21
 
46
22
  add :is, Is
@@ -0,0 +1,44 @@
1
+ module DMGen
2
+ module PluginGenerator
3
+
4
+ def self.included(model)
5
+ model.extend(ClassMethods)
6
+
7
+ # all plugins need a name
8
+ model.first_argument :name, :required => true
9
+
10
+ # glob the template dir for all templates.
11
+ # since we want text files processed, we have to replace the default
12
+ # extension list.
13
+ model.glob!('', %w[rb txt Rakefile LICENSE README.rdoc])
14
+
15
+ model.file :gitignore, '.gitignore'
16
+ end
17
+
18
+ def gem_name
19
+ raise NotImplementedError
20
+ end
21
+
22
+ def snake_name
23
+ name.snake_case
24
+ end
25
+
26
+ def class_name
27
+ name.camel_case
28
+ end
29
+
30
+ def destination_root
31
+ File.join(@destination_root, gem_name)
32
+ end
33
+
34
+ module ClassMethods
35
+ def template_dir
36
+ name.snake_case.split('::').last
37
+ end
38
+
39
+ def source_root
40
+ File.join(File.dirname(__FILE__), '..', 'templates', template_dir)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## Rubinius
17
+ *.rbc
18
+
19
+ ## PROJECT::GENERAL
20
+ *.gem
21
+ coverage
22
+ rdoc
23
+ pkg
24
+ tmp
25
+ doc
26
+ log
27
+ .yardoc
28
+ measurements
29
+
30
+ ## BUNDLER
31
+ .bundle
32
+ Gemfile.local
33
+
34
+ ## PROJECT::SPECIFIC
35
+ spec/db/
@@ -0,0 +1,82 @@
1
+ # If you're working on more than one datamapper gem at a time, then it's
2
+ # recommended to create a local Gemfile and use this instead of the git
3
+ # sources. This will make sure that you are developing against your
4
+ # other local datamapper sources that you currently work on. Gemfile.local
5
+ # will behave identically to the standard Gemfile apart from the fact that
6
+ # it fetches the gems from local paths. This means that you can use the
7
+ # same environment variables, like ADAPTER when running bundle commands.
8
+ # Gemfile.local is added to .gitignore, so you don't need to worry about
9
+ # accidentally checking local development paths into git.
10
+ #
11
+ # bundle exec rake local_gemfile
12
+ #
13
+ # will give you a Gemfile.local file that points to your local clones of
14
+ # the various datamapper gems. It's assumed that all datamapper repo clones
15
+ # reside in the same directory. You can use the Gemfile.local like so for
16
+ # running any bundle command:
17
+ #
18
+ # BUNDLE_GEMFILE=Gemfile.local bundle foo
19
+ #
20
+ # To speed up running bundle tasks, it's recommended to run
21
+ #
22
+ # bundle lock
23
+ #
24
+ # after running 'bundle install' for the first time. This will make 'bundle exec' run
25
+ # a lot faster compared to the unlocked version. With an unlocked bundle you would
26
+ # typically just run 'bundle install' from time to time to fetch the latest sources from
27
+ # upstream. When you locked your bundle, you need to run
28
+ #
29
+ # bundle install --relock
30
+ #
31
+ # to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
32
+ # is added to the .gitignore file, so you don't need to worry about accidentally checking
33
+ # it into version control.
34
+
35
+ source 'http://rubygems.org'
36
+
37
+ DATAMAPPER = 'git://github.com/datamapper'
38
+ DM_VERSION = '~> <%= DMGen::DM_VERSION %>'
39
+
40
+ group :runtime do # Runtime dependencies (as in the gemspec)
41
+
42
+ gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
43
+
44
+ end
45
+
46
+ group(:development) do # Development dependencies (as in the gemspec)
47
+
48
+ gem 'dm-migrations', DM_VERSION, :git => "#{DATAMAPPER}/dm-migrations.git"
49
+
50
+ gem 'rake', '~> 0.8.7'
51
+ gem 'rspec', '~> 1.3'
52
+ gem 'yard', '~> 0.5'
53
+ gem 'rcov', '~> 0.9.7'
54
+ gem 'jeweler', '~> 1.4'
55
+
56
+ end
57
+
58
+ group :datamapper do # We need this because we want to pin these dependencies to their git master sources
59
+
60
+ if ENV['EXTLIB']
61
+ gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git", :require => nil
62
+ else
63
+ gem 'activesupport', '~> 3.0.0.beta3', :git => 'git://github.com/rails/rails.git', :require => nil
64
+ end
65
+
66
+ plugins = ENV['PLUGINS'] || ENV['PLUGIN']
67
+ plugins = (plugins.to_s.gsub(',',' ').split(' ') + ['dm-migrations']).uniq
68
+
69
+ plugins.each do |plugin|
70
+ gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
71
+ end
72
+
73
+ end
74
+
75
+ group :quality do # These gems contain rake tasks that check the quality of the source code
76
+
77
+ gem 'yardstick', '~> 0.1'
78
+ gem 'metric_fu', '~> 1.3'
79
+ gem 'reek', '~> 1.2.7'
80
+ gem 'roodi', '~> 2.1'
81
+
82
+ end