bio-gem 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +54 -191
- data/Rakefile +1 -0
- data/Tutorial.rdoc +122 -25
- data/VERSION +1 -1
- data/bio-gem.gemspec +3 -2
- metadata +20 -23
data/README.rdoc
CHANGED
@@ -1,24 +1,33 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
|
4
|
-
start coding an application or a library for using/extending
|
5
|
-
core library and sharing
|
6
|
-
listed at
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
= Biogem
|
2
|
+
|
3
|
+
Biogem provides a set of tools for those Bioinformaticans who want to
|
4
|
+
start coding an application, or a library for using/extending
|
5
|
+
BioRuby's core library and sharing the code as a gem through
|
6
|
+
http://rubygems.org. Biogems are automatically listed at
|
7
|
+
http://biogems.info
|
8
|
+
|
9
|
+
The basic idea is to promote a modular approach to the BioRuby
|
10
|
+
package, and simplify creating such modules. Biogem creates the
|
11
|
+
necessary directory structure for a gem, and generates files, based on
|
12
|
+
templates. Biogem includes templates for parsing the command line,
|
13
|
+
logging, libraries,
|
14
|
+
documentation, tests. Also there is Ruby on Rails support, BioSQL and
|
15
|
+
FFI (for binding to C libraries).
|
16
|
+
|
17
|
+
Biogem does not reinvent the wheel, but puts together different
|
18
|
+
tools and modifies their original behavior, when needed. The tool
|
19
|
+
jeweler is used to create the initial scaffold, setting up git for
|
20
|
+
versioning, releasing it to github.com and/or rubygems.org and
|
21
|
+
packaging. Bundler is used used for setting up a predefined developing
|
22
|
+
environment.
|
23
|
+
|
24
|
+
Also Biogem makes use of webservices. E.g.
|
16
25
|
|
17
26
|
* GitHub.com and RubyGems.org
|
18
27
|
are two different services and you need to create different accounts for them
|
19
|
-
if you already use GitHub.com you are
|
28
|
+
if you already use GitHub.com you are set for using Biogem
|
20
29
|
|
21
|
-
==
|
30
|
+
== Biogems Official Archive
|
22
31
|
|
23
32
|
* http://biogems.info/
|
24
33
|
|
@@ -26,80 +35,39 @@ Remind that
|
|
26
35
|
|
27
36
|
The latest version is on https://github.com/helios/bioruby-gem/blob/master/Tutorial.rdoc
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
*
|
43
|
-
|
44
|
-
|
45
|
-
* bundle install
|
46
|
-
* rake version:write
|
47
|
-
* rake gemspec
|
48
|
-
* rake install
|
49
|
-
|
50
|
-
Some of these steps have been condensed:
|
51
|
-
|
52
|
-
* gem install bio-gem
|
53
|
-
* $ biogem mystuff
|
54
|
-
* pass just the simple name, it will add bioruby- for the first level directory and for the github repository
|
55
|
-
BUT you'll require the library with bio-mystuff (and this will be the name used on rubygems)
|
56
|
-
* creates a basic gem structure with a default dependencies for bioruby (bio) version 1.4.2
|
57
|
-
|-- bin [optional = --with-bin]
|
58
|
-
| `-- biomystuff (executable)
|
59
|
-
|-- Gemfile
|
60
|
-
|-- Gemfile.lock
|
61
|
-
|-- LICENSE.txt
|
62
|
-
|-- README.rdoc
|
63
|
-
|-- Rakefile
|
64
|
-
|-- lib
|
65
|
-
| `-- bio-mystuff.rb
|
66
|
-
|-- conf[optional = --with-db]
|
67
|
-
| `-- database.yml put here the configuration of your database like in a rails app
|
68
|
-
|-- db [optional = --with-db] empty but put here your datasets or database(SQLite3?)
|
69
|
-
| |-- seeds.rb a file containing the preloaded datasets, they will be loaded during db setup process
|
70
|
-
| `-- migrate directory for migration, you must create migrations by hand, there is a template inside.
|
71
|
-
`-- test
|
72
|
-
|-- data [optional = --with-test-data]
|
73
|
-
|-- helper.rb
|
74
|
-
`-- test_bio-mystuff.rb
|
75
|
-
|
76
|
-
* $ cd bioruby-mystuff
|
77
|
-
* $ rake version:write (Initial Updated version: 0.0.0)
|
78
|
-
* $ rake gemspec
|
79
|
-
* $ rake install (for local test)
|
80
|
-
* hack, git add and commit
|
81
|
-
* NOTE: It's very important that you add new and changed files so they can be included in the gem you will create, otherwise the files will not be include and you'll end up with a broken gem with missing files.
|
82
|
-
* $ rake git:release (Before releasing on github or rubygems please see the Notes For Developers). Note: the brand new project is automatically uploaded on GitHub at creation time.
|
83
|
-
* WHEN you have finished with the hacking you can release the gem by typing:
|
84
|
-
* $ rake release
|
85
|
-
|
86
|
-
* if you want to make a new release version: major, minor or patch version you can use
|
87
|
-
* $ rake version:bump:(major | minor | patch)
|
88
|
-
the release will be increased by 1 and when you'll release it'll be updated. Note that in GitHub, bumping the version will create a tag with this version and your repository.So for every version you release there is a tag associated.
|
89
|
-
|
90
|
-
== Options
|
91
|
-
These are the available options, they come from biogem and from jeweler. I don't know if in the future I'll keep all of them.
|
38
|
+
== Contributing to Biogem
|
39
|
+
|
40
|
+
The source code repositories for Biogem and http://biogems.info
|
41
|
+
website are on github. If you want to contribute, feel free! Clone the
|
42
|
+
project!
|
43
|
+
|
44
|
+
=== StepByStep
|
45
|
+
|
46
|
+
Toshiaki Katayama wrote a step by step guide for a bio-foobar plugin @ http://bioruby.open-bio.org/wiki/BiogemInstallation.
|
47
|
+
|
48
|
+
== BioRuby's Wiki Official Documentation
|
49
|
+
|
50
|
+
* http://bioruby.open-bio.org/wiki/Plugins
|
51
|
+
* http://biogems.info/ official collector for BioRuby plugins
|
52
|
+
|
53
|
+
== Biogem options
|
92
54
|
|
93
55
|
Usage: biogem [options] reponame
|
56
|
+
|
94
57
|
e.g. biogem the-perfect-gem
|
58
|
+
|
95
59
|
--directory [DIRECTORY] specify the directory to generate into
|
60
|
+
|
96
61
|
These options are for BioGem
|
97
|
-
|
62
|
+
|
63
|
+
--meta create a meta package, just the Rakefile, Gemfile, Licence, Readme. This options takes the precedence over every other option.
|
98
64
|
--with-bin create the bin directory and an executable template script called bioreponame
|
99
|
-
--with-db create the database directory for a db application-library
|
65
|
+
--with-db create the database directory for a db application-library.
|
100
66
|
--with-test-data create the data directory inside the test directory if the user need to set up a test with its own dataset
|
101
|
-
--with-engine [NAMESPACE] create a Rails engine with the namespace given in input.
|
67
|
+
--with-engine [NAMESPACE] create a Rails engine with the namespace given in input. Set default database creation
|
68
|
+
|
102
69
|
These options are for Jeweler
|
70
|
+
|
103
71
|
--rspec generate rspec code examples
|
104
72
|
--shoulda generate shoulda tests
|
105
73
|
--testunit generate test/unit tests
|
@@ -128,120 +96,15 @@ These options are for Jeweler
|
|
128
96
|
GitHub token to use for interacting with the GitHub API
|
129
97
|
--git-remote [GIT_REMOTE] URI to set the git origin remote to
|
130
98
|
--homepage [HOMEPAGE] the homepage for your project (defaults to the GitHub repo)
|
131
|
-
--no-create-repo
|
99
|
+
--no-create-repo create the repository on GitHub
|
132
100
|
|
133
101
|
--yard use yard for documentation
|
134
102
|
--rdoc use rdoc for documentation
|
135
103
|
-h, --help display this help and exit
|
136
104
|
|
137
|
-
== Tasks
|
138
|
-
|
139
|
-
rake build # Build gem into pkg/
|
140
|
-
rake clobber_rcov # Remove rcov products for rcov
|
141
|
-
rake clobber_rdoc # Remove rdoc products
|
142
|
-
rake console[script] # Start IRB with all runtime dependencies loaded
|
143
|
-
rake db:create # Create the database from config/database.yml for the current default (use db:create:all to create all dbs in the config)
|
144
|
-
rake db:drop # Drops the database for the current default (use db:drop:all to drop all databases)
|
145
|
-
rake db:fixtures:load # Load fixtures into the current environment's database.
|
146
|
-
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false).
|
147
|
-
rake db:migrate:status # Display status of migrations
|
148
|
-
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n).
|
149
|
-
rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by AR
|
150
|
-
rake db:schema:load # Load a schema.rb file into the database
|
151
|
-
rake db:seed # Load the seed data from db/seeds.rb
|
152
|
-
rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
|
153
|
-
rake db:structure:dump # Dump the database structure to an SQL file
|
154
|
-
rake db:version # Retrieves the current schema version number
|
155
|
-
rake gemcutter:release # Release gem to Gemcutter
|
156
|
-
rake gemspec # Generate and validate gemspec
|
157
|
-
rake gemspec:debug # Display the gemspec for debugging purposes, as jeweler knows it (not from the filesystem)
|
158
|
-
rake gemspec:generate # Regenerate the gemspec on the filesystem
|
159
|
-
rake gemspec:release # Regenerate and validate gemspec, and then commits and pushes to git
|
160
|
-
rake gemspec:validate # Validates the gemspec on the filesystem
|
161
|
-
rake git:release # Tag and push release to git.
|
162
|
-
rake install # Build and install gem using `gem install`
|
163
|
-
rake rcov # Analyze code coverage with tests
|
164
|
-
rake rdoc # Build the rdoc HTML Files
|
165
|
-
rake release # Release gem
|
166
|
-
rake rerdoc # Force a rebuild of the RDOC files
|
167
|
-
rake test # Run tests
|
168
|
-
rake version # Displays the current version
|
169
|
-
rake version:bump:major # Bump the major version by 1
|
170
|
-
rake version:bump:minor # Bump the a minor version by 1
|
171
|
-
rake version:bump:patch # Bump the patch version by 1
|
172
|
-
rake version:write # Writes out an explicit version.
|
173
|
-
|
174
|
-
|
175
|
-
== NoTes For Developers
|
176
|
-
|
177
|
-
* A GitHub Account is required. The name of the repository follows this rules:
|
178
|
-
bioruby-mystuff
|
179
|
-
on your local directory you will see bioruby-mystuff but on rubygems you will publish bio-mystuff. This is a clash of namespaces but I think in this way makes more sense.
|
180
|
-
* It's VERY IMPORTANT you set up your GitHub environment correctly, please follow the official guide http://help.github.com/set-your-user-name-email-and-github-token/ (USERNAME, EMAIL, TOKEN are very very important)
|
181
|
-
* Before start developing open Rakefile and modify the gem.summary and gem.description. These parameters are fundamental because let you describe your gem and why we need it. If you let them by default the gem will not be packed, it's just a countermeasure :-)
|
182
|
-
* Update your rubygems environment
|
183
|
-
* Keep in mind that Jeweler handles everything using the local git repository, so there is no need to modify the Rakefile or the tasks for including files, directories; just git add your_file_or_directory. Remember to modify .gitignore to exclude unwanted files.
|
184
|
-
* Explore the rake tasks with
|
185
|
-
* $ bundle exec rake -T
|
186
|
-
* Help
|
187
|
-
* please use help $ biogem -h to discover other options for creating rspec or cucumber tests
|
188
|
-
|
189
|
-
=== DataBaseConnection
|
190
|
-
Is a best practices, at least for me, to have a dummy class which establishes the connection with the database and inherit that class by the models. The benefit of this approach is to have multiple connections available at the same time in case you are developing/using multiple gems with different databases. This file is located in lib/bio/kb
|
191
|
-
|
192
|
-
module Bio
|
193
|
-
module KB
|
194
|
-
class DummyMySpecialDB < ActiveRecord::Base
|
195
|
-
self.abstract_class = true
|
196
|
-
establish_connection(:adapter =>'sqlite3',:database =>"#{File.dirname(__FILE__)}/../../../db/yourdb.sqlite3")
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
or you can use the configuration file db/database.yml and add this code to the module above. Note I don't like very much to add every time this code so in a future release I'll find out a way to add it automatically, probably overwriting the configurations call.
|
202
|
-
|
203
|
-
root_path = File.join(File.dirname(__FILE__),"../../../")
|
204
|
-
configurations = YAML.load_file(File.join(root_path,"conf/database.yml"))
|
205
|
-
configurations.each_pair do |key, db_info|
|
206
|
-
db_info["database"] = File.join(root_path, db_info["database"]) if db_info["adapter"]=='sqlite3'
|
207
|
-
end
|
208
|
-
establish_connection(configurations["default"])
|
209
|
-
|
210
|
-
This code is necessary because the db is inside the gem and you can't know where the file will be installed ( using the YAML config file.)
|
211
|
-
|
212
|
-
The model must be located in a directory structure like lib/bio/kb/yourclass this is important because ActiveRecord can map the namespace with the directory tree.
|
213
|
-
|
214
|
-
module Bio
|
215
|
-
module KB
|
216
|
-
module MySpecialDB
|
217
|
-
class Mytable < Bio::KB::DummyMySpecialDB
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
=== Seeds
|
224
|
-
Before populate you seeds.rb file you must declare a model. The model is declared in the usual Rails' way, see above.
|
225
|
-
|
226
|
-
#Use this file to load a default dataset into your database
|
227
|
-
%w(Raoul Toshiaki Francesco).each do |coder|
|
228
|
-
Bio::KB::MySpecialDB::Example.create(:name=>coder, :tag=>"bioruby", :type=>"developer")
|
229
|
-
end
|
230
|
-
|
231
|
-
=== StepByStep
|
232
|
-
Toshiaki Katayama wrote a step by step guide for a bio-foobar plugin @ http://bioruby.open-bio.org/wiki/BiogemInstallation.
|
233
|
-
|
234
|
-
== BioRuby's Wiki Official Documentation
|
235
|
-
|
236
|
-
* http://bioruby.open-bio.org/wiki/Plugins
|
237
|
-
* http://biogems.info/ official collector for BioRuby plugins
|
238
|
-
|
239
|
-
== TODO
|
240
|
-
* better command line, wrap or re-implement some of the funcionalities provided by Bundler and Jeweler
|
241
|
-
* use YAML for database configuration
|
242
|
-
|
243
105
|
== Copyright
|
244
106
|
|
245
|
-
Copyright (c) 2010 Raoul J.P. Bonnal. See LICENSE.txt for
|
107
|
+
Copyright (c) 2010, 2011 Raoul J.P. Bonnal. See LICENSE.txt for
|
246
108
|
further details.
|
247
109
|
|
110
|
+
|
data/Rakefile
CHANGED
@@ -23,6 +23,7 @@ Jeweler::Tasks.new do |gem|
|
|
23
23
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
24
24
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
25
25
|
#gem.version='0.0.1'
|
26
|
+
gem.required_ruby_version = "~>1.9"
|
26
27
|
end
|
27
28
|
Jeweler::RubygemsDotOrgTasks.new
|
28
29
|
|
data/Tutorial.rdoc
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
= Biogem Tutorial
|
2
2
|
|
3
|
-
The latest version is on https://github.com/helios/bioruby-gem/blob/master/Tutorial.rdoc
|
3
|
+
The latest version of this document is on https://github.com/helios/bioruby-gem/blob/master/Tutorial.rdoc
|
4
4
|
|
5
5
|
== Installation
|
6
|
+
|
6
7
|
=== Pre-requisites
|
7
|
-
|
8
|
-
*
|
8
|
+
|
9
|
+
* Ruby: at least 1.9.x, current tested version is 1.9.2, moving to 1.9.3
|
10
|
+
|
11
|
+
* RVM: RVM http://beginrescueend.com/ is optional, but suggested. Not only can you specify the Ruby interpreter version that works best with Biogem, RVM also allows multiple ruby interpreters in your home directory for testing purposes. When using RVM, make sure to compile with openssl support, e.g. on Debian
|
12
|
+
|
13
|
+
$ sudo apt-get install libssl-dev
|
14
|
+
$ rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr
|
15
|
+
|
9
16
|
* GitHub & RubyGems: In order to use Biogem to its fullest potential, you must create a regular GitHub http://github.com and RubyGems http://rubygems.org account. Why? Because for sharing and keeping track of source code we (currenlty) use github and for distributing the plugin we rely on RubyGems, the reference Ruby gem repository. To configure github and automate most of Biogem's tasks:
|
17
|
+
|
10
18
|
$ git config --global user.name "Firstname Lastname" Sets the name of the user for all git instances on the system
|
11
19
|
$ git config --global user.email "your_email@youremail.com"
|
12
20
|
$ git config --global github.user "user_id"
|
@@ -16,19 +24,51 @@ Note: another Ruby version management system used in BioRuby community is https:
|
|
16
24
|
|
17
25
|
=== Download
|
18
26
|
|
19
|
-
Install the
|
27
|
+
Install the Biogem toolset with
|
20
28
|
|
21
29
|
$ gem install bio-gem
|
22
30
|
|
23
31
|
all the required dependencies will be downloaded and installed automatically.
|
24
32
|
|
33
|
+
Fetching: bundler-1.0.21.gem (100%)
|
34
|
+
Fetching: git-1.2.5.gem (100%)
|
35
|
+
Fetching: jeweler-1.6.4.gem (100%)
|
36
|
+
Fetching: json-1.6.3.gem (100%)
|
37
|
+
Building native extensions. This could take a while...
|
38
|
+
Fetching: rdoc-3.11.gem (100%)
|
39
|
+
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
|
40
|
+
<= 1.8.6 : unsupported
|
41
|
+
= 1.8.7 : gem install rdoc-data; rdoc-data --install
|
42
|
+
= 1.9.1 : gem install rdoc-data; rdoc-data --install
|
43
|
+
>= 1.9.2 : nothing to do! Yay!
|
44
|
+
Fetching: bio-gem-1.1.2.gem (100%)
|
45
|
+
Successfully installed bundler-1.0.21
|
46
|
+
Successfully installed git-1.2.5
|
47
|
+
Successfully installed jeweler-1.6.4
|
48
|
+
Successfully installed json-1.6.3
|
49
|
+
Successfully installed rdoc-3.11
|
50
|
+
Successfully installed bio-gem-1.1.2
|
51
|
+
6 gems installed
|
52
|
+
Installing ri documentation for bundler-1.0.21...
|
53
|
+
Installing ri documentation for git-1.2.5...
|
54
|
+
Installing ri documentation for jeweler-1.6.4...
|
55
|
+
Installing ri documentation for json-1.6.3...
|
56
|
+
Installing ri documentation for rdoc-3.11...
|
57
|
+
Installing ri documentation for bio-gem-1.1.2...
|
58
|
+
Installing RDoc documentation for bundler-1.0.21...
|
59
|
+
Installing RDoc documentation for git-1.2.5...
|
60
|
+
Installing RDoc documentation for jeweler-1.6.4...
|
61
|
+
Installing RDoc documentation for json-1.6.3...
|
62
|
+
Installing RDoc documentation for rdoc-3.11...
|
63
|
+
Installing RDoc documentation for bio-gem-1.1.2...
|
64
|
+
|
25
65
|
== Create your first BioRuby Plugin
|
66
|
+
|
26
67
|
=== Standard
|
27
68
|
|
28
69
|
To create a BioRuby plugin named bio-foo in the bioruby-foo directory
|
29
70
|
|
30
|
-
$
|
31
|
-
|
71
|
+
$ biogem foo
|
32
72
|
create .gitignore
|
33
73
|
create Rakefile
|
34
74
|
create Gemfile
|
@@ -61,15 +101,21 @@ In case you are not connected to internet the following message will appear:
|
|
61
101
|
Seems you are not connected to Internet, can't create a remote repository.
|
62
102
|
Do not forget to create it by hand, from GitHub, and sync it with this project.
|
63
103
|
|
64
|
-
Note the name of the plugin is important. Plugins are published as Ruby gems on http://rubygems.org/. All plugins that start with the name bio dash (bio-) are automatically listed on the
|
104
|
+
Note the name of the plugin is important. Plugins are published as Ruby gems on http://rubygems.org/. All plugins that start with the name bio dash (bio-) are automatically listed on the Biogem website http://biogems.info/ !
|
65
105
|
|
66
|
-
The first step is to open Rakefile and modify the gem.summary and gem.description.
|
106
|
+
The first step is to open Rakefile and modify the gem.summary and gem.description.
|
107
|
+
|
108
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
109
|
+
gem.description = %Q{TODO: longer description of your gem}
|
110
|
+
|
111
|
+
These parameters are necessary, because they describe your gem and its importance. If you let them as default the gem, will not publish. Examples of summary and description can be found on http://biogems.info/
|
67
112
|
|
68
113
|
|
69
114
|
=== With a DataBase
|
70
|
-
If you want to distribute a library which uses a local database Biogem creates for you a database template and add features coming from Ruby on Rails to manage the database. You can define Models, Fixtures and Migrations like a regular Rails application. SQLite3 is the default database engine in order to have a portable library, is also possible to configure the library to use different RDBMS like PostgreSQL, MySQL; please refer to ActiveRecord for further details.
|
71
115
|
|
72
|
-
|
116
|
+
If you want to distribute a library which uses a local database biogem creates for you a database template and add features coming from Ruby on Rails to manage the database. You can define Models, Fixtures and Migrations like a regular Rails application. SQLite3 is the default database engine in order to have a portable library, is also possible to configure the library to use different RDBMS like PostgreSQL, MySQL; please refer to ActiveRecord for further details.
|
117
|
+
|
118
|
+
$ biogem --with-db foo
|
73
119
|
create .gitignore
|
74
120
|
create Rakefile
|
75
121
|
create Gemfile
|
@@ -113,8 +159,8 @@ If you want to distribute a library which uses a local database Biogem creates f
|
|
113
159
|
|
114
160
|
Rows with symbol + are differences between the standard command
|
115
161
|
|
116
|
-
|
117
162
|
==== DataBaseConnection
|
163
|
+
|
118
164
|
Is a best practice, at least for me, to have a dummy class which establishes the connection with the database and then inherit that class by models. The benefit of this approach is to have multiple connections available at the same time, just in case you are developing/using multiple gems with different databases. This file is located in lib/bio/your_module/connect.rb
|
119
165
|
|
120
166
|
module Bio
|
@@ -138,6 +184,7 @@ or you can use configuration file located in config/database.yml and add the fol
|
|
138
184
|
Note: The latter is the default method.
|
139
185
|
|
140
186
|
===== DBConfiguration
|
187
|
+
|
141
188
|
In file config/database.yml
|
142
189
|
|
143
190
|
# SQLite version 3.x
|
@@ -149,10 +196,13 @@ In file config/database.yml
|
|
149
196
|
timeout: 5000
|
150
197
|
|
151
198
|
===== Create the database
|
199
|
+
|
152
200
|
bundle exec rake db:create
|
201
|
+
|
153
202
|
Create the database from config/database.yml for the current default (use db:create:all to create all dbs in the config
|
154
203
|
|
155
204
|
==== Create A Table Using Migration
|
205
|
+
|
156
206
|
In file db/migrate/001_create_example.rb
|
157
207
|
|
158
208
|
The code below create a table name example. As best practice name this file with a prefix index like 001_create_example.rb and the next migration 002.... and so on, this will help you to keep track over the time.
|
@@ -176,10 +226,13 @@ Please refer to Rails' documentation
|
|
176
226
|
end
|
177
227
|
|
178
228
|
Once you have defined the table you can create it
|
229
|
+
|
179
230
|
$ bundle exec rake db:migrate
|
231
|
+
|
180
232
|
Migrate the database (options: VERSION=x, VERBOSE=false)
|
181
233
|
|
182
234
|
===== Defining a Model
|
235
|
+
|
183
236
|
The model must be located in a directory structure like lib/bio/your_module/your_class this is important because ActiveRecord map the namespace with the directory tree.
|
184
237
|
|
185
238
|
module Bio
|
@@ -188,9 +241,11 @@ The model must be located in a directory structure like lib/bio/your_module/your
|
|
188
241
|
end
|
189
242
|
end
|
190
243
|
end
|
191
|
-
|
244
|
+
|
245
|
+
Then using the [FIXME]
|
192
246
|
|
193
247
|
===== Seeds
|
248
|
+
|
194
249
|
Before populate your databse file you must declare a model. The model is declared in the usual Rails' way, see above.
|
195
250
|
Use file db/seeds.rb to load a default dataset into your database
|
196
251
|
|
@@ -199,25 +254,34 @@ Use file db/seeds.rb to load a default dataset into your database
|
|
199
254
|
end
|
200
255
|
|
201
256
|
=== Rails Engine With Database a BioPlugin
|
257
|
+
|
202
258
|
Biogem is intended to help you also in advanced task like create a gem that can be reused in multiple rails applications, serving for instance a database, libraries and/or controllers,models,views.
|
259
|
+
|
203
260
|
==== Why Rails Engine
|
261
|
+
|
204
262
|
In bioinformatics is very common to presents data using a web application, and often you find are re using the same libraries and database for the same purpose, with a just a small difference in applications or your need to put together different functionalities which are spread along multiple database and libraries.
|
263
|
+
|
205
264
|
==== HowToEngines
|
206
|
-
|
265
|
+
|
266
|
+
To example this Biogem's features we want to create a Rails application which provides a form to users. Data are submitted to TogoWS http://togows.dbcls.jp/ and the result is returned in a web page. In the mean time we want to store suers queries and return them in the page of TogoWS' result. We'll create a Rails application and a separated Biogem to store queries and provide connection to TogoWS, following "man in the middle" pattern.
|
207
267
|
|
208
268
|
$ biogem --with-engine Foo foo
|
269
|
+
|
209
270
|
Note: a database is automatically configure for the newly created gem
|
210
271
|
|
211
272
|
$ rails new Webfoo
|
212
273
|
|
213
274
|
You can test your application just inserting into Rails application Gemfile the newly created gem:
|
275
|
+
|
214
276
|
gem 'bio-foo', :path=>'path_gem_dir'
|
215
277
|
|
216
278
|
update the installation running:
|
279
|
+
|
217
280
|
cd Webfoo
|
218
281
|
bundle install
|
219
282
|
|
220
283
|
Enable the route for the added gem (in biouby-foo/config/routes.rb) uncomment:
|
284
|
+
|
221
285
|
yourPathToTheControllerFiles = 'foopath'
|
222
286
|
controllerName = :foos
|
223
287
|
otherControllerName = :samples
|
@@ -232,6 +296,7 @@ Enable the route for the added gem (in biouby-foo/config/routes.rb) uncomment:
|
|
232
296
|
end #scope
|
233
297
|
|
234
298
|
In bioruby-foo/lib/bio/foo/example.rb be sure the example class is uncommented:
|
299
|
+
|
235
300
|
module Bio
|
236
301
|
module Foo
|
237
302
|
class Example < DummyConn
|
@@ -240,17 +305,20 @@ In bioruby-foo/lib/bio/foo/example.rb be sure the example class is uncommented:
|
|
240
305
|
end
|
241
306
|
|
242
307
|
Create and migrate bioruby-foo database:
|
308
|
+
|
243
309
|
cd bioruby-foo
|
244
310
|
bundle exec rake db:create
|
245
311
|
bundle exec rake db:migrate
|
246
312
|
|
247
313
|
Run your Rails server and load the web page
|
314
|
+
|
248
315
|
cd Webfoo
|
249
316
|
rails s
|
250
317
|
|
251
318
|
open your browser to http://localhost:3000/foos/new
|
252
319
|
|
253
320
|
Controller,Views and Module are located in bioruby-foo:
|
321
|
+
|
254
322
|
* app/controllers
|
255
323
|
* app/views
|
256
324
|
* app/helpers
|
@@ -259,10 +327,10 @@ Controller,Views and Module are located in bioruby-foo:
|
|
259
327
|
The latter path has modified by purpose from standard Rails configuration to keep a consistency with a normal ruby/gem library, in case developer wants to use a database but not a rails engine.
|
260
328
|
|
261
329
|
=== A Meta Plugin
|
262
|
-
A meta package or plugin is a very simple gem, essentially a configuration's gem. This particular plugin is used to aggregate other plugins or gems taking advantage of RubyGems dependencies. An example of this feature are: bio-core, bio-ext, bio-biollinux plugins which have different purposes and they can contain the same plugins but in different versions.
|
263
330
|
|
264
|
-
|
331
|
+
A meta package or plugin is a very simple gem, essentially a configuration's gem. This particular plugin is used to aggregate other plugins or gems taking advantage of RubyGems dependencies. An example of this feature are: bio-core, bio-ext, bio-biollinux plugins which have different purposes and they can contain the same plugins but in different versions.
|
265
332
|
|
333
|
+
$ biogem --meta foo
|
266
334
|
create .gitignore
|
267
335
|
create Rakefile
|
268
336
|
create Gemfile
|
@@ -273,7 +341,9 @@ A meta package or plugin is a very simple gem, essentially a configuration's gem
|
|
273
341
|
Those are the only files created by Biogem and are the only required to work as a meta-package. The user can add its libraries to the Gemfile and update information in Rakefile
|
274
342
|
|
275
343
|
===== Gemfile
|
344
|
+
|
276
345
|
This is Gemfile's content
|
346
|
+
|
277
347
|
source "http://rubygems.org"
|
278
348
|
# Add dependencies required to use your gem here.
|
279
349
|
# Example:
|
@@ -291,47 +361,69 @@ This is Gemfile's content
|
|
291
361
|
|
292
362
|
In general if you add gems to the development section that gems will be installed only if you want to contribute the the original plugin source code. Otherwise you must add your gem requirements outside development group.
|
293
363
|
Note: because this file is used by bundler as well, you can specify multiple source. For development purposes is also possible to specify different location than rubygems, local or github:
|
364
|
+
|
294
365
|
gem "the_perfect_gem", :path=>"your_local_path_on_your_hard_drive"
|
295
366
|
gem "JohnDoe_perfect_gem", :git=>"http://github.com/johndow/the_perfect_gem"
|
296
367
|
|
297
368
|
== Manage Plugin Versions
|
369
|
+
|
298
370
|
$ rake version:bump:(major | minor | patch)
|
371
|
+
|
299
372
|
will increase the level of your actual version by 1. A version is composed by X.Y.Z where X = major, Y = minor, Z = patch and we suggest the following approach for bumping the version:
|
373
|
+
|
300
374
|
* major: new features or modifications which introduce incompatibilities with older version
|
301
375
|
* minor: new features which keep backward compatibility
|
302
376
|
* patch: fix a bug keeping backward compatibility
|
377
|
+
|
303
378
|
Note: every time you want to publish your plugin on RubyGems the version must be bumped by 1 in at least one of the X.Y.Z otherwise RubyGems will give your an error. If you want to remove a specific version from RubyGems you must yank it but remember that version number, will not be available anymore
|
379
|
+
|
304
380
|
gem yank GEM -v VERSION [-p PLATFORM] [--undo] [options]
|
381
|
+
|
305
382
|
=== Bumping Minor Version
|
383
|
+
|
306
384
|
$ bundle exec rake version:bump:minor
|
307
385
|
Current version: 0.0.0
|
308
386
|
Updated version: 0.1.0
|
309
387
|
|
310
388
|
== Releasing the Plugin
|
389
|
+
|
311
390
|
After hack, git add and commit you may be ready to distribute the plugin and now you have two ways
|
391
|
+
|
312
392
|
* Only GitHub
|
313
393
|
* GitHub and RubyGems
|
394
|
+
|
314
395
|
=== Only on GitHub
|
396
|
+
|
315
397
|
$ bundle exec rake git:release
|
398
|
+
|
316
399
|
=== GitHub and Rubygems at the same time
|
400
|
+
|
317
401
|
$ bundle exec rake release
|
318
402
|
|
403
|
+
=== Prerelease
|
404
|
+
|
405
|
+
To create a prerelease of your plugin, set the version to include a letter (e.g. alpha). This way the gem is registered as prerelease, listed on http://biogems.info/, but not listed in the standard gem lists.
|
319
406
|
|
320
407
|
== Options
|
321
|
-
These are the available options, they come from Biogem and from jeweler. I don't know if in the future I'll keep all of them.
|
322
408
|
|
323
|
-
|
324
|
-
|
409
|
+
These are the available options, they come from biogem and from jeweler. I don't know if in the future I'll keep all of them.
|
410
|
+
|
411
|
+
Usage: biogem [options] reponame, e.g.
|
325
412
|
|
413
|
+
$ biogem the-perfect-gem
|
326
414
|
|
327
415
|
--directory [DIRECTORY] specify the directory to generate into
|
416
|
+
|
328
417
|
These options are for Biogem
|
418
|
+
|
329
419
|
--meta create a meta package, just the Rakefile, Gemfile, Licence, Readme. This options takes the precedence over every other option.
|
330
420
|
--with-bin create the bin directory and an executable template script called bioreponame
|
331
421
|
--with-db create the database directory for a db application-library
|
332
422
|
--with-test-data create the data directory inside the test directory if the user need to set up a test with its own dataset
|
333
423
|
--with-engine [NAMESPACE] create a Rails engine with the namespace given in input. Dy default set up the environment to use an SQLite3 database
|
424
|
+
|
334
425
|
These options are for Jeweler
|
426
|
+
|
335
427
|
--rspec generate rspec code examples
|
336
428
|
--shoulda generate shoulda tests
|
337
429
|
--testunit generate test/unit tests
|
@@ -367,10 +459,15 @@ These options are for Jeweler
|
|
367
459
|
-h, --help display this help and exit
|
368
460
|
|
369
461
|
== Tasks
|
370
|
-
|
462
|
+
|
463
|
+
Biogem, like other frameworks, offers a bunch of predefined and common operations for the developers. These are so called tasks and can be listed simply typing:
|
464
|
+
|
371
465
|
$ rake -T
|
466
|
+
|
372
467
|
but because we are in a "development environment" is strongly suggested to use a very similar command
|
468
|
+
|
373
469
|
$ bundle exec rake -T
|
470
|
+
|
374
471
|
which guarantees that all the called programs/tasks will be executed inside the current development environment (bound to specific libraries versions). Follows the list of all available tasks for Biogem
|
375
472
|
|
376
473
|
rake build # Build gem into pkg/
|
@@ -416,21 +513,21 @@ which guarantees that all the called programs/tasks will be executed inside the
|
|
416
513
|
== BioRuby's Wiki Official Documentation
|
417
514
|
|
418
515
|
* http://bioruby.open-bio.org/wiki/Plugins
|
419
|
-
=== StepByStep
|
420
|
-
Toshiaki Katayama wrote a step by step guide for a bio-foobar plugin @ http://bioruby.open-bio.org/wiki/BiogemInstallation; note this information could be older than this.
|
421
516
|
|
517
|
+
=== StepByStep
|
422
518
|
|
423
|
-
|
519
|
+
Toshiaki Katayama wrote a step by step guide for a bio-foobar plugin @ http://bioruby.open-bio.org/wiki/BiogemInstallation; note this information could be older than this.
|
424
520
|
|
425
|
-
|
521
|
+
== Biogem Official Plugin Archive
|
426
522
|
|
523
|
+
* http://biogems.info/
|
427
524
|
|
428
525
|
== TODO
|
526
|
+
|
429
527
|
* better command line, wrap or re-implement some of the funcionalities provided by Bundler and Jeweler
|
430
528
|
* use YAML for database configuration
|
431
529
|
|
432
530
|
== Copyright
|
433
531
|
|
434
|
-
Copyright (c) 2010 Raoul J.P. Bonnal, Toshiaki Katayama, and Pjotr Prins. See LICENSE.txt for
|
435
|
-
further details.
|
532
|
+
Copyright (c) 2010 Raoul J.P. Bonnal, Toshiaki Katayama, and Pjotr Prins. See LICENSE.txt for further details.
|
436
533
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/bio-gem.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bio-gem}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.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{
|
12
|
+
s.date = %q{2012-01-04}
|
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}
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
s.homepage = %q{http://github.com/helios/bioruby-gem}
|
57
57
|
s.licenses = [%q{MIT}]
|
58
58
|
s.require_paths = [%q{lib}]
|
59
|
+
s.required_ruby_version = Gem::Requirement.new("~> 1.9")
|
59
60
|
s.rubygems_version = %q{1.8.6}
|
60
61
|
s.summary = %q{BioGem helps Bioinformaticians start developing plugins/modules for BioRuby creating a scaffold and a gem package}
|
61
62
|
|
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.
|
4
|
+
version: 1.2.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:
|
12
|
+
date: 2012-01-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154411360 !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: *
|
24
|
+
version_requirements: *2154411360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154410260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.6.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154410260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154399520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154399520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: shoulda
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154398380 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154398380
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154395340 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.18
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2154395340
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &2154393980 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.6.4
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2154393980
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rcov
|
82
|
-
requirement: &
|
82
|
+
requirement: &2154392880 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2154392880
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rdoc
|
93
|
-
requirement: &
|
93
|
+
requirement: &2154391820 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2154391820
|
102
102
|
description: ! "BioGem is a scaffold generator for those Bioinformaticans who want
|
103
103
|
to start coding an application or a library for using/extending BioRuby core library
|
104
104
|
and sharing it through rubygems.org .\n The basic idea is to simplify and promote
|
@@ -154,12 +154,9 @@ require_paths:
|
|
154
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ~>
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
160
|
-
segments:
|
161
|
-
- 0
|
162
|
-
hash: 823213589522284135
|
159
|
+
version: '1.9'
|
163
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
161
|
none: false
|
165
162
|
requirements:
|