bio-gem 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem "bundler", "~> 1.0.18"
6
6
  gem "jeweler", "~> 1.6.4"
7
+ gem "rdoc"
7
8
 
8
9
 
9
10
  # Add dependencies to develop your gem here.
@@ -13,4 +14,5 @@ group :development do
13
14
  gem "bundler", "~> 1.0.18"
14
15
  gem "jeweler", "~> 1.6.4"
15
16
  gem "rcov", ">= 0"
17
+ gem "rdoc"
16
18
  end
@@ -6,8 +6,11 @@ GEM
6
6
  bundler (~> 1.0)
7
7
  git (>= 1.2.5)
8
8
  rake
9
+ json (1.6.1)
9
10
  rake (0.9.2)
10
11
  rcov (0.9.10)
12
+ rdoc (3.11)
13
+ json (~> 1.4)
11
14
  shoulda (2.11.3)
12
15
 
13
16
  PLATFORMS
@@ -17,4 +20,5 @@ DEPENDENCIES
17
20
  bundler (~> 1.0.18)
18
21
  jeweler (~> 1.6.4)
19
22
  rcov
23
+ rdoc
20
24
  shoulda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bio-gem}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Raoul J.P. Bonnal}]
12
- s.date = %q{2011-09-26}
12
+ s.date = %q{2011-11-09}
13
13
  s.description = %q{BioGem is a scaffold generator for those Bioinformaticans who want to start coding an application or a library for using/extending BioRuby core library and sharing it through rubygems.org .
14
14
  The basic idea is to simplify and promote a modular approach to the BioRuby package.}
15
15
  s.email = %q{ilpuccio.febo@gmail.com}
@@ -35,9 +35,16 @@ Gem::Specification.new do |s|
35
35
  "lib/bio-gem/mod/jeweler/options.rb",
36
36
  "lib/bio-gem/templates/bin",
37
37
  "lib/bio-gem/templates/database",
38
+ "lib/bio-gem/templates/engine",
39
+ "lib/bio-gem/templates/foos_controller",
40
+ "lib/bio-gem/templates/foos_view_example",
41
+ "lib/bio-gem/templates/foos_view_index",
42
+ "lib/bio-gem/templates/foos_view_show",
38
43
  "lib/bio-gem/templates/lib",
44
+ "lib/bio-gem/templates/library",
39
45
  "lib/bio-gem/templates/migration",
40
46
  "lib/bio-gem/templates/rakefile",
47
+ "lib/bio-gem/templates/routes",
41
48
  "lib/bio-gem/templates/seeds",
42
49
  "test/helper.rb",
43
50
  "test/test_bio-gem.rb"
@@ -54,25 +61,31 @@ Gem::Specification.new do |s|
54
61
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
62
  s.add_runtime_dependency(%q<bundler>, ["~> 1.0.18"])
56
63
  s.add_runtime_dependency(%q<jeweler>, ["~> 1.6.4"])
64
+ s.add_runtime_dependency(%q<rdoc>, [">= 0"])
57
65
  s.add_development_dependency(%q<shoulda>, [">= 0"])
58
66
  s.add_development_dependency(%q<bundler>, ["~> 1.0.18"])
59
67
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
60
68
  s.add_development_dependency(%q<rcov>, [">= 0"])
69
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
61
70
  else
62
71
  s.add_dependency(%q<bundler>, ["~> 1.0.18"])
63
72
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
73
+ s.add_dependency(%q<rdoc>, [">= 0"])
64
74
  s.add_dependency(%q<shoulda>, [">= 0"])
65
75
  s.add_dependency(%q<bundler>, ["~> 1.0.18"])
66
76
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
67
77
  s.add_dependency(%q<rcov>, [">= 0"])
78
+ s.add_dependency(%q<rdoc>, [">= 0"])
68
79
  end
69
80
  else
70
81
  s.add_dependency(%q<bundler>, ["~> 1.0.18"])
71
82
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
83
+ s.add_dependency(%q<rdoc>, [">= 0"])
72
84
  s.add_dependency(%q<shoulda>, [">= 0"])
73
85
  s.add_dependency(%q<bundler>, ["~> 1.0.18"])
74
86
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
75
87
  s.add_dependency(%q<rcov>, [">= 0"])
88
+ s.add_dependency(%q<rdoc>, [">= 0"])
76
89
  end
77
90
  end
78
91
 
@@ -3,6 +3,16 @@
3
3
  require 'bio-gem/mod/jeweler/options'
4
4
  require 'bio-gem/mod/jeweler/github_mixin'
5
5
 
6
+ class String
7
+ def underscore
8
+ self.gsub(/::/, '/').
9
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
10
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
11
+ tr("-", "_").
12
+ downcase
13
+ end
14
+ end
15
+
6
16
  class Jeweler
7
17
  class Generator
8
18
 
@@ -55,7 +65,31 @@ class Jeweler
55
65
  def bin_name
56
66
  "bio#{original_project_name}"
57
67
  end
58
-
68
+
69
+ def engine_dirs
70
+ %w{app app/controllers app/views app/helpers config app/views/foos}
71
+ end
72
+
73
+ def engine_name
74
+ "#{project_name}-engine"
75
+ end
76
+
77
+ def engine_filename
78
+ "#{engine_name}.rb"
79
+ end
80
+
81
+ def engine_module_name
82
+ project_name.split('-').map{|module_sub_name| module_sub_name.capitalize}.join
83
+ end
84
+
85
+ def engine_name_prefix
86
+ project_name.split('-').gsub(/-/,'_')<<'_'
87
+ end
88
+
89
+ def engine_namespace
90
+ "/#{options[:biogem_engine]}"
91
+ end
92
+
59
93
  def render_template_generic(source, template_dir = template_dir_biogem)
60
94
  template_contents = File.read(File.join(template_dir, source))
61
95
  template = ERB.new(template_contents, nil, '<>')
@@ -75,6 +109,15 @@ class Jeweler
75
109
  end
76
110
  $stdout.puts "\t#{status}\t#{destination}"
77
111
  end
112
+
113
+ def output_template_in_target_generic_update(source, destination = source, template_dir = template_dir_biogem)
114
+ final_destination = File.join(target_dir, destination)
115
+ template_result = render_template_generic(source, template_dir)
116
+
117
+ File.open(final_destination, 'a') {|file| file.write(template_result)}
118
+
119
+ $stdout.puts "\tcreate\t#{destination}"
120
+ end
78
121
 
79
122
  def template_dir_biogem
80
123
  File.join(File.dirname(__FILE__),'..', 'templates')
@@ -128,6 +171,20 @@ class Jeweler
128
171
 
129
172
  # Fill lib/bio-plugin.rb with some default comments
130
173
  output_template_in_target_generic 'lib', File.join(lib_dir, lib_filename)
174
+
175
+ #creates the strutures and files needed to have a ready to go Rails' engine
176
+ if namespace=options[:biogem_engine]
177
+ engine_dirs.each do |dir|
178
+ mkdir_in_target dir
179
+ end
180
+ output_template_in_target_generic 'engine', File.join('lib', engine_filename )
181
+ output_template_in_target_generic_update 'library', File.join('lib', lib_filename)
182
+ output_template_in_target_generic 'routes', File.join('config', "routes.rb" )
183
+ output_template_in_target_generic 'foos_controller', File.join('app',"controllers", "foos_controller.rb" )
184
+ output_template_in_target_generic 'foos_view_index', File.join('app',"views","foos", "inedx.html.erb" )
185
+ output_template_in_target_generic 'foos_view_show', File.join('app',"views","foos", "show.html.erb" )
186
+ output_template_in_target_generic 'foos_view_example', File.join('app',"views","foos", "example.html.erb" )
187
+ end
131
188
  end #not_bio_gem_meta
132
189
  end
133
190
 
@@ -137,8 +194,22 @@ class Jeweler
137
194
  'token' => github_token,
138
195
  'description' => summary,
139
196
  'name' => github_repo_name
197
+ # BY DEFAULT THE REPO IS CREATED
198
+ # DO NOT PUSH THE REPO BECAUSE USER MUST ADD INFO TO CONFIGURATION FILES
140
199
  # TODO do a HEAD request to see when it's ready?
141
- @repo.push('origin')
200
+ #@repo.push('origin')
201
+ end
202
+
203
+
204
+ def puts_template_message(message, length=70, padding=4)
205
+ puts "*"*(length+padding*2+2)
206
+ puts "*"+" "*(length+padding*2)+"*"
207
+ message=message.join("\n") if message.kind_of? Array
208
+ message.scan(/.{1,70}/).map do |sub_message|
209
+ puts "*"+" "*padding+sub_message+" "*(length-sub_message.size+padding)+"*"
210
+ end
211
+ puts "*"+" "*(length+padding*2)+"*"
212
+ puts "*"*(length+padding*2+2)
142
213
  end
143
214
  end #Generator
144
215
  end #Jeweler
@@ -10,6 +10,7 @@ class Jeweler
10
10
  self[:testing_framework] = :shoulda
11
11
  self[:documentation_framework] = :rdoc
12
12
  self[:use_bundler] = true
13
+ self[:create_repo] = true
13
14
 
14
15
  git_config = if Pathname.new("~/.gitconfig").expand_path.exist?
15
16
  Git.global_config
@@ -44,14 +45,19 @@ class Jeweler
44
45
  self[:biogem_bin] = true
45
46
  end
46
47
 
47
- o.on("--with-db", 'create the database directory for a db application-library') do
48
+ o.on('--with-db', 'create the database directory for a db application-library.') do
48
49
  self[:biogem_db] = true
49
50
  end
50
51
 
51
- o.on("--with-test-data",'create the data directory inside the test directory if the user need to set up a test with its own dataset') do
52
+ o.on('--with-test-data','create the data directory inside the test directory if the user need to set up a test with its own dataset') do
52
53
  self[:biogem_test_data] = true
53
54
  end
54
55
 
56
+ o.on('--with-engine [NAMESPACE]', 'create a Rails engine with the namespace given in input. Set default database creation') do |namespace|
57
+ self[:biogem_engine] = namespace
58
+ self[:biogem_db] = true
59
+ end
60
+
55
61
  o.separator ""
56
62
 
57
63
  o.separator "These options are for Jeweler"
@@ -0,0 +1,43 @@
1
+ require '<%= require_name %>'
2
+ require 'rails'
3
+
4
+ module <%= engine_module_name %>
5
+ class Engine < Rails::Engine
6
+
7
+ # Config defaults
8
+ # DEPRECATED
9
+ config.widget_factory_name = "default factory name"
10
+ config.mount_at = '/'
11
+
12
+ # # Load rake tasks
13
+ # rake_tasks do
14
+ # load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
15
+ # end
16
+
17
+ # Check the gem config
18
+ initializer "check config" do |app|
19
+ # make sure mount_at ends with trailing slash
20
+ config.mount_at += '/' unless config.mount_at.last == '/'
21
+ end
22
+
23
+ initializer "static assets" do |app|
24
+ app.middleware.use ::ActionDispatch::Static, "#{root}/public"
25
+ end
26
+
27
+ # consider the possibility to keep the modules in the lib directory, which is more compatible
28
+ # with a normal gem/package
29
+ paths["app/models"] << "lib"
30
+ end
31
+ end
32
+
33
+ # #In your Rails application into
34
+ # # config/initializers
35
+ # # create a file called <%= require_name %>.rb
36
+ # # you can change the mount point of you engine, using option
37
+ # # --with_engine=namespace like http://YourDomain:port/YourMountPoint
38
+ # # Otherwise, if you want your RailsEngine to be called at root level, leave everything as it now, without that file.
39
+ # module <%= engine_module_name %>
40
+ # class Engine < Rails::Engine
41
+ # engine_name = '<%= engine_namespace %>'
42
+ # end
43
+ # end
@@ -0,0 +1,13 @@
1
+ class FoosController < ApplicationController
2
+ def example
3
+ @shuttle = "TEST CASE"
4
+ end
5
+
6
+ def index
7
+ @index = "Something relevant"
8
+ end
9
+
10
+ def show
11
+ @item = "It's me"
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ This is just an example of a call from a controller <%%= @shuttle %>
@@ -0,0 +1 @@
1
+ This could be a list of item but for now I just read from a fake index <%%= @index %>
@@ -0,0 +1,3 @@
1
+ <H1>
2
+ Who is the item ? <%%= @item %>
3
+ <H1>
@@ -0,0 +1,6 @@
1
+
2
+ if (defined?(Rails) && Rails::VERSION::MAJOR == 3)
3
+ require '<%= engine_name %>'
4
+ else
5
+ #require the usual dependencies here
6
+ end
@@ -0,0 +1,40 @@
1
+ Rails.application.routes.draw do
2
+
3
+ #DEPRECATED
4
+ mount_at = <%= engine_module_name %>::Engine.engine_name== "<%= engine_module_name.underscore %>_engine" ? "" : <%= engine_module_name %>::Engine.engine_name
5
+
6
+
7
+ #ROUTES from code below:
8
+ # YourPathToTheControllerFiles = bio/kb/gex
9
+ # OtherControllerName = slice
10
+ #
11
+ # gex /gex(.:format) {:controller=>"bio/kb/gex/populations", :action=>"index"}
12
+ # filter_population GET /gex/populations/:id/filter(.:format) {:action=>"filter", :controller=>"bio/kb/gex/populations"}
13
+ # populations GET /gex/populations(.:format) {:action=>"index", :controller=>"bio/kb/gex/populations"}
14
+ # population GET /gex/populations/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/populations"}
15
+ # samples GET /gex/samples(.:format) {:action=>"index", :controller=>"bio/kb/gex/samples"}
16
+ # sample GET /gex/samples/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/samples"}
17
+ # slices GET /gex/slices(.:format) {:action=>"index", :controller=>"bio/kb/gex/slices"}
18
+ # slice GET /gex/slices/:id(.:format) {:action=>"show", :controller=>"bio/kb/gex/slices"}
19
+ #
20
+ # Uncomment to activate the resources
21
+ ## or you can reconfigure mount_at
22
+ ## mount <%= engine_module_name %>::Engine=>"your_mount_point", :as=>'your_personal_engine_name' # but is better to redefine the mount point in the Rails application.
23
+ # yourPathToTheControllerFiles = 'foopath'
24
+ # controllerName = :foos
25
+ # otherControllerName = :sampels
26
+ # ---
27
+ # scope mount_at, yourPathToTheControllerFiles do
28
+ # resources controllerName, :only => [ :index, :show] do
29
+ # member do
30
+ # get :example
31
+ # end
32
+ # end
33
+ # resources otherControllerName, :only =>[:index, :show]
34
+ # end #scope
35
+
36
+ <% puts_template_message ["Remember to require this library in the Gemfile of your Rails application.",
37
+ "Please take a look at #{target_dir}/lib/#{require_name}-engine.rb file for an example of how integrate your engine into a rails application.",
38
+ "Thanks!"] %>
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-26 00:00:00.000000000Z
12
+ date: 2011-11-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2164719420 !ruby/object:Gem::Requirement
16
+ requirement: &2161194560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.18
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164719420
24
+ version_requirements: *2161194560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jeweler
27
- requirement: &2164717980 !ruby/object:Gem::Requirement
27
+ requirement: &2161193880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: 1.6.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164717980
35
+ version_requirements: *2161193880
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &2161193260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2161193260
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: shoulda
38
- requirement: &2164716880 !ruby/object:Gem::Requirement
49
+ requirement: &2161192420 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2164716880
57
+ version_requirements: *2161192420
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: bundler
49
- requirement: &2164716080 !ruby/object:Gem::Requirement
60
+ requirement: &2161191600 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: 1.0.18
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2164716080
68
+ version_requirements: *2161191600
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: jeweler
60
- requirement: &2164714920 !ruby/object:Gem::Requirement
71
+ requirement: &2161190920 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,10 +76,21 @@ dependencies:
65
76
  version: 1.6.4
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2164714920
79
+ version_requirements: *2161190920
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: rcov
71
- requirement: &2164713220 !ruby/object:Gem::Requirement
82
+ requirement: &2161190240 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2161190240
91
+ - !ruby/object:Gem::Dependency
92
+ name: rdoc
93
+ requirement: &2161189240 !ruby/object:Gem::Requirement
72
94
  none: false
73
95
  requirements:
74
96
  - - ! '>='
@@ -76,7 +98,7 @@ dependencies:
76
98
  version: '0'
77
99
  type: :development
78
100
  prerelease: false
79
- version_requirements: *2164713220
101
+ version_requirements: *2161189240
80
102
  description: ! "BioGem is a scaffold generator for those Bioinformaticans who want
81
103
  to start coding an application or a library for using/extending BioRuby core library
82
104
  and sharing it through rubygems.org .\n The basic idea is to simplify and promote
@@ -105,9 +127,16 @@ files:
105
127
  - lib/bio-gem/mod/jeweler/options.rb
106
128
  - lib/bio-gem/templates/bin
107
129
  - lib/bio-gem/templates/database
130
+ - lib/bio-gem/templates/engine
131
+ - lib/bio-gem/templates/foos_controller
132
+ - lib/bio-gem/templates/foos_view_example
133
+ - lib/bio-gem/templates/foos_view_index
134
+ - lib/bio-gem/templates/foos_view_show
108
135
  - lib/bio-gem/templates/lib
136
+ - lib/bio-gem/templates/library
109
137
  - lib/bio-gem/templates/migration
110
138
  - lib/bio-gem/templates/rakefile
139
+ - lib/bio-gem/templates/routes
111
140
  - lib/bio-gem/templates/seeds
112
141
  - test/helper.rb
113
142
  - test/test_bio-gem.rb
@@ -126,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
155
  version: '0'
127
156
  segments:
128
157
  - 0
129
- hash: -913022692014142837
158
+ hash: 2864487456249026807
130
159
  required_rubygems_version: !ruby/object:Gem::Requirement
131
160
  none: false
132
161
  requirements: