inochi 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +1 -0
- data/bin/inochi +112 -104
- data/doc/api/classes/Array.html +370 -0
- data/doc/api/classes/File.html +110 -0
- data/doc/api/classes/Inochi.html +1493 -0
- data/doc/api/classes/Inochi/Manual.html +157 -0
- data/doc/api/classes/Inochi/Phrases.html +331 -0
- data/doc/api/classes/Inochi/Version.html +190 -0
- data/doc/api/classes/TempDir.html +164 -0
- data/doc/api/created.rid +1 -0
- data/doc/api/css/main.css +263 -0
- data/doc/api/css/panel.css +383 -0
- data/doc/api/css/reset.css +53 -0
- data/doc/api/files/CREDITS.html +61 -0
- data/doc/api/files/LICENSE.html +76 -0
- data/doc/api/files/lib/inochi/book_rb.html +96 -0
- data/doc/api/files/lib/inochi/init_rb.html +78 -0
- data/doc/api/files/lib/inochi/main_rb.html +52 -0
- data/doc/api/files/lib/inochi/rake_rb.html +52 -0
- data/doc/api/files/lib/inochi/test/bacon_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/context_rb.html +69 -0
- data/doc/api/files/lib/inochi/test/dfect_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/matchy_rb.html +69 -0
- data/doc/api/files/lib/inochi/test/minitest_rb.html +71 -0
- data/doc/api/files/lib/inochi/test/mocha_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/rspec_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/shoulda_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/test_spec_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/test_unit_rb.html +67 -0
- data/doc/api/files/lib/inochi/util/combo_rb.html +59 -0
- data/doc/api/files/lib/inochi/util/tempdir_rb.html +68 -0
- data/doc/api/files/lib/inochi/util_rb.html +59 -0
- data/doc/api/files/lib/inochi_rb.html +78 -0
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/index.html +14 -18
- data/doc/api/js/jquery-1.3.2.min.js +19 -0
- data/doc/api/js/jquery-effect.js +593 -0
- data/doc/api/js/main.js +22 -0
- data/doc/api/js/searchdoc.js +605 -0
- data/doc/api/panel/index.html +63 -0
- data/doc/api/panel/search_index.js +1 -0
- data/doc/api/panel/tree.js +1 -0
- data/doc/history.erb +75 -34
- data/doc/index.erb +10 -5
- data/doc/index.xhtml +806 -1145
- data/doc/intro.erb +33 -27
- data/doc/setup.erb +16 -15
- data/doc/usage.erb +86 -137
- data/lib/inochi.rb +25 -13
- data/lib/inochi/book.rb +13 -6
- data/lib/inochi/init.rb +41 -24
- data/lib/inochi/main.rb +17 -7
- data/lib/inochi/rake.rb +200 -59
- data/lib/inochi/test/bacon.rb +3 -0
- data/lib/inochi/test/context.rb +4 -0
- data/lib/inochi/test/dfect.rb +3 -0
- data/lib/inochi/test/matchy.rb +4 -0
- data/lib/inochi/test/minitest.rb +7 -0
- data/lib/inochi/test/mocha.rb +3 -0
- data/lib/inochi/test/rspec.rb +3 -0
- data/lib/inochi/test/shoulda.rb +3 -0
- data/lib/inochi/test/test_spec.rb +3 -0
- data/lib/inochi/test/test_unit.rb +3 -0
- data/lib/inochi/util.rb +23 -1
- data/lib/inochi/util/combo.rb +191 -0
- data/lib/inochi/util/tempdir.rb +29 -0
- data/rakefile +12 -0
- data/test/inochi.rb +5 -0
- metadata +119 -45
- data/Rakefile +0 -6
- data/doc/api/Inochi.html +0 -2574
- data/doc/api/Inochi/Manual.html +0 -230
- data/doc/api/Inochi/Phrases.html +0 -409
- data/doc/api/Inochi/Version.html +0 -222
- data/doc/api/all-methods.html +0 -180
- data/doc/api/all-namespaces.html +0 -28
- data/doc/api/app.js +0 -18
- data/doc/api/jquery.js +0 -11
- data/doc/api/readme.html +0 -38
- data/doc/api/style.css +0 -68
- data/doc/api/syntax_highlight.css +0 -21
- data/doc/theory.erb +0 -3
data/lib/inochi.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
1
6
|
require 'rubygems'
|
2
7
|
|
3
8
|
module Inochi
|
9
|
+
libs = File.dirname(__FILE__)
|
10
|
+
$LOAD_PATH << libs unless $LOAD_PATH.include? libs
|
4
11
|
end
|
5
12
|
|
6
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
7
13
|
require 'inochi/init'
|
8
14
|
require 'inochi/main'
|
9
15
|
require 'inochi/rake'
|
@@ -11,19 +17,25 @@ require 'inochi/book'
|
|
11
17
|
require 'inochi/util'
|
12
18
|
|
13
19
|
Inochi.init :Inochi,
|
14
|
-
:version => '0.
|
15
|
-
:release => '2009-
|
20
|
+
:version => '1.0.0',
|
21
|
+
:release => '2009-05-03',
|
16
22
|
:website => 'http://snk.tuxfamily.org/lib/inochi',
|
17
23
|
:tagline => 'Gives life to RubyGems-based software',
|
18
24
|
:require => {
|
19
|
-
'
|
20
|
-
'
|
21
|
-
|
22
|
-
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
25
|
+
'trollop' => '~> 1', # for parsing command-line options
|
26
|
+
'launchy' => '>= 0.3.3', # for launching a web browser
|
27
|
+
},
|
28
|
+
:develop => {
|
29
|
+
'rake' => '>= 0.8.4',
|
30
|
+
'rubyforge' => '~> 1', # for publishing gems to RubyForge
|
31
|
+
'mechanize' => '~> 0', # for automating web browsing
|
32
|
+
'voloko-sdoc' => '>= 0.2.10', # for generating API documentation
|
33
|
+
'addressable' => '~> 2', # for parsing URIs properly
|
34
|
+
'erbook' => '~> 7', # for processing the user manual
|
35
|
+
'babelfish' => '~> 0', # for human language translation
|
36
|
+
'spicycode-rcov' => nil, # for code coverage statistics
|
37
|
+
'flay' => nil, # for code quality analysis
|
38
|
+
'reek' => nil, # for code quality analysis
|
39
|
+
'roodi' => nil, # for code quality analysis
|
40
|
+
'ZenTest' => '~> 4', # for the `multiruby` tool
|
29
41
|
}
|
data/lib/inochi/book.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
#--
|
2
|
+
# Copyright 2008 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
6
|
+
module Inochi
|
2
7
|
##
|
3
8
|
# Provides a common configuration for the project's user manual:
|
4
9
|
#
|
@@ -25,14 +30,16 @@ class << Inochi
|
|
25
30
|
# It is assumed that this method is called
|
26
31
|
# from within the Inochi.rake() environment.
|
27
32
|
#
|
28
|
-
#
|
33
|
+
# ==== Parameters
|
34
|
+
#
|
35
|
+
# [project_symbol]
|
29
36
|
# Name of the Ruby constant which serves
|
30
37
|
# as a namespace for the entire project.
|
31
38
|
#
|
32
|
-
#
|
39
|
+
# [book_template]
|
33
40
|
# The eRuby template which serves as the documentation for the project.
|
34
41
|
#
|
35
|
-
def book project_symbol, book_template
|
42
|
+
def Inochi.book project_symbol, book_template
|
36
43
|
project_module = fetch_project_module(project_symbol)
|
37
44
|
|
38
45
|
# provide project constants as global variables to the user manual
|
@@ -60,7 +67,7 @@ class << Inochi
|
|
60
67
|
##
|
61
68
|
# Defines a brief summary of this project.
|
62
69
|
#
|
63
|
-
def
|
70
|
+
def project
|
64
71
|
raise ArgumentError, 'block must be given' unless block_given?
|
65
72
|
|
66
73
|
node do
|
@@ -72,7 +79,7 @@ class << Inochi
|
|
72
79
|
##
|
73
80
|
# Contains release notes for all project releases.
|
74
81
|
#
|
75
|
-
def
|
82
|
+
def history
|
76
83
|
raise ArgumentError, 'block must be given' unless block_given?
|
77
84
|
|
78
85
|
node do
|
data/lib/inochi/init.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
1
6
|
require 'yaml'
|
2
7
|
|
3
|
-
|
8
|
+
module Inochi
|
4
9
|
##
|
5
10
|
# Establishes your project in Ruby's runtime environment by defining
|
6
11
|
# the project module (which serves as a namespace for all code in the
|
@@ -17,63 +22,76 @@ class << Inochi
|
|
17
22
|
# within any of its descendant directories) the project lib/ directory.
|
18
23
|
# Ideally, this method would be invoked from the main project library.
|
19
24
|
#
|
20
|
-
#
|
25
|
+
# ==== Parameters
|
26
|
+
#
|
27
|
+
# [project_symbol]
|
21
28
|
# Name of the Ruby constant which serves
|
22
29
|
# as a namespace for the entire project.
|
23
30
|
#
|
24
|
-
#
|
25
|
-
#
|
31
|
+
# [project_config]
|
32
|
+
# Optional hash of project configuration parameters:
|
26
33
|
#
|
27
|
-
# [
|
34
|
+
# [:project]
|
28
35
|
# Name of the project.
|
29
36
|
#
|
30
37
|
# The default value is the value of the project_symbol parameter.
|
31
38
|
#
|
32
|
-
# [
|
39
|
+
# [:tagline]
|
33
40
|
# An enticing, single line description of the project.
|
34
41
|
#
|
35
42
|
# The default value is an empty string.
|
36
43
|
#
|
37
|
-
# [
|
44
|
+
# [:website]
|
38
45
|
# URL of the published project website.
|
39
46
|
#
|
40
47
|
# The default value is an empty string.
|
41
48
|
#
|
42
|
-
# [
|
49
|
+
# [:docsite]
|
43
50
|
# URL of the published user manual.
|
44
51
|
#
|
45
52
|
# The default value is the same value as the :website parameter.
|
46
53
|
#
|
47
|
-
# [
|
54
|
+
# [:program]
|
48
55
|
# Name of the main project executable.
|
49
56
|
#
|
50
57
|
# The default value is the value of the :project parameter
|
51
58
|
# in lowercase and CamelCase converted into snake_case.
|
52
59
|
#
|
53
|
-
# [
|
60
|
+
# [:version]
|
54
61
|
# Version of the project.
|
55
62
|
#
|
56
63
|
# The default value is "0.0.0".
|
57
64
|
#
|
58
|
-
# [
|
65
|
+
# [:release]
|
59
66
|
# Date when this version was released.
|
60
67
|
#
|
61
68
|
# The default value is the current time.
|
62
69
|
#
|
63
|
-
# [
|
70
|
+
# [:display]
|
64
71
|
# How the project name should be displayed.
|
65
72
|
#
|
66
73
|
# The default value is the project name and version together.
|
67
74
|
#
|
68
|
-
# [
|
75
|
+
# [:install]
|
69
76
|
# Path to the directory which contains the project.
|
70
77
|
#
|
71
78
|
# The default value is one directory above the parent
|
72
79
|
# directory of the file from which this method was called.
|
73
80
|
#
|
74
|
-
# [
|
75
|
-
#
|
76
|
-
# this project. This information must be expressed as follows:
|
81
|
+
# [:require]
|
82
|
+
# Hash containing the names and version constraints of RubyGems required
|
83
|
+
# to run this project. This information must be expressed as follows:
|
84
|
+
#
|
85
|
+
# * Each hash key must be the name of a ruby gem.
|
86
|
+
#
|
87
|
+
# * Each hash value must be either +nil+, a single version number
|
88
|
+
# requirement string (see Gem::Requirement) or an Array thereof.
|
89
|
+
#
|
90
|
+
# The default value is an empty Hash.
|
91
|
+
#
|
92
|
+
# [:develop]
|
93
|
+
# Hash containing the names and version constraints of RubyGems required
|
94
|
+
# to build this project. This information must be expressed as follows:
|
77
95
|
#
|
78
96
|
# * Each hash key must be the name of a ruby gem.
|
79
97
|
#
|
@@ -82,9 +100,11 @@ class << Inochi
|
|
82
100
|
#
|
83
101
|
# The default value is an empty Hash.
|
84
102
|
#
|
85
|
-
#
|
103
|
+
# ==== Returns
|
104
|
+
#
|
105
|
+
# The newly configured project module.
|
86
106
|
#
|
87
|
-
def init project_symbol, project_config = {}
|
107
|
+
def Inochi.init project_symbol, project_config = {}
|
88
108
|
project_module = fetch_project_module(project_symbol)
|
89
109
|
|
90
110
|
# this method is not re-entrant
|
@@ -93,7 +113,7 @@ class << Inochi
|
|
93
113
|
@already_seen << project_module
|
94
114
|
|
95
115
|
# put project on Ruby load path
|
96
|
-
project_file =
|
116
|
+
project_file = first_caller_file
|
97
117
|
project_libs = File.dirname(project_file)
|
98
118
|
$LOAD_PATH << project_libs unless $LOAD_PATH.include? project_libs
|
99
119
|
|
@@ -108,6 +128,7 @@ class << Inochi
|
|
108
128
|
project_config[:program] ||= calc_program_name(project_symbol)
|
109
129
|
project_config[:install] ||= File.dirname(project_libs)
|
110
130
|
project_config[:require] ||= {}
|
131
|
+
project_config[:develop] ||= {}
|
111
132
|
|
112
133
|
# establish gem version dependencies and
|
113
134
|
# sanitize the values while we're at it
|
@@ -115,11 +136,7 @@ class << Inochi
|
|
115
136
|
dst = project_config[:require].clear
|
116
137
|
|
117
138
|
src.each_pair do |gem_name, version_reqs|
|
118
|
-
gem_name
|
119
|
-
version_reqs = [version_reqs].flatten.compact
|
120
|
-
|
121
|
-
dst[gem_name] = version_reqs
|
122
|
-
gem gem_name, *version_reqs
|
139
|
+
dst[gem_name] = require_gem_version(gem_name, version_reqs)
|
123
140
|
end
|
124
141
|
|
125
142
|
# make configuration parameters available as constants
|
data/lib/inochi/main.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
1
6
|
##
|
2
7
|
# Provides a common configuration for the main project executable:
|
3
8
|
#
|
@@ -14,17 +19,19 @@
|
|
14
19
|
# It is assumed that this method is invoked from only within
|
15
20
|
# the main project executable (in the project bin/ directory).
|
16
21
|
#
|
17
|
-
#
|
22
|
+
# ==== Parameters
|
23
|
+
#
|
24
|
+
# [project_symbol]
|
18
25
|
# Name of the Ruby constant which serves
|
19
26
|
# as a namespace for the entire project.
|
20
27
|
#
|
21
|
-
#
|
22
|
-
# Optional arguments for Trollop::options().
|
28
|
+
# [trollop_args]
|
29
|
+
# Optional array of arguments for Trollop::options().
|
23
30
|
#
|
24
|
-
#
|
25
|
-
# Optional block
|
31
|
+
# [trollop_config]
|
32
|
+
# Optional block parameter passed to Trollop::options().
|
26
33
|
#
|
27
|
-
#
|
34
|
+
# Returns the result of Trollop::options().
|
28
35
|
#
|
29
36
|
def Inochi.main project_symbol, *trollop_args, &trollop_config
|
30
37
|
program_file = first_caller_file
|
@@ -63,7 +70,10 @@ def Inochi.main project_symbol, *trollop_args, &trollop_config
|
|
63
70
|
|
64
71
|
if options[:manual]
|
65
72
|
require 'launchy'
|
66
|
-
|
73
|
+
|
74
|
+
manual = File.join(project_module::INSTALL, 'doc', 'index.xhtml')
|
75
|
+
Launchy::Browser.run manual
|
76
|
+
|
67
77
|
exit
|
68
78
|
end
|
69
79
|
|
data/lib/inochi/rake.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
1
6
|
##
|
2
7
|
# Provides Rake tasks for packaging, publishing, and announcing your project.
|
3
8
|
#
|
@@ -18,69 +23,89 @@
|
|
18
23
|
# when the copyright holder first began working on the project, and
|
19
24
|
# EMAIL is (optional) the email address of the copyright holder.
|
20
25
|
#
|
21
|
-
#
|
26
|
+
# ==== Parameters
|
27
|
+
#
|
28
|
+
# [project_symbol]
|
22
29
|
# Name of the Ruby constant which serves
|
23
30
|
# as a namespace for the entire project.
|
24
31
|
#
|
25
|
-
#
|
26
|
-
#
|
32
|
+
# [options]
|
33
|
+
# Optional hash of configuration parameters:
|
34
|
+
#
|
35
|
+
# [:test_with]
|
36
|
+
# Names of Ruby libraries inside the "inochi/test/"
|
37
|
+
# namespace to load before running the test suite.
|
27
38
|
#
|
28
|
-
#
|
39
|
+
# The default value is an empty Array.
|
40
|
+
#
|
41
|
+
# [:authors]
|
29
42
|
# A list of project authors and their contact information. This
|
30
43
|
# list must have the form "[[name, info]]" where "name" is the name
|
31
44
|
# of a project author and "info" is their contact information.
|
32
45
|
#
|
33
|
-
#
|
46
|
+
# The default value is automatically extracted from
|
47
|
+
# your project's license file (see description above).
|
48
|
+
#
|
49
|
+
# [:license_file]
|
34
50
|
# Path (relative to the main project directory which contains the
|
35
|
-
# project
|
51
|
+
# project rakefile) to the file which contains the project license.
|
36
52
|
#
|
37
53
|
# The default value is "LICENSE".
|
38
54
|
#
|
39
|
-
# [
|
55
|
+
# [:logins_file]
|
40
56
|
# Path to the YAML file which contains login
|
41
57
|
# information for publishing release announcements.
|
42
58
|
#
|
43
59
|
# The default value is "~/.config/inochi/logins.yaml"
|
44
60
|
# where "~" is the path to your home directory.
|
45
61
|
#
|
46
|
-
# [
|
62
|
+
# [:rubyforge_project]
|
47
63
|
# Name of the RubyForge project where
|
48
64
|
# release packages will be published.
|
49
65
|
#
|
50
66
|
# The default value is the value of the PROGRAM constant.
|
51
67
|
#
|
52
|
-
# [
|
68
|
+
# [:rubyforge_section]
|
53
69
|
# Name of the RubyForge project's File Release System
|
54
70
|
# section where release packages will be published.
|
55
71
|
#
|
56
72
|
# The default value is the value of the :rubyforge_project parameter.
|
57
73
|
#
|
58
|
-
# [
|
74
|
+
# [:raa_project]
|
59
75
|
# Name of the RAA (Ruby Application Archive) entry for this project.
|
60
76
|
#
|
61
77
|
# The default value is the value of the PROGRAM constant.
|
62
78
|
#
|
63
|
-
# [
|
79
|
+
# [:upload_target]
|
64
80
|
# Where to upload the project documentation.
|
65
81
|
# See "destination" in the rsync manual.
|
66
82
|
#
|
67
83
|
# The default value is nil.
|
68
84
|
#
|
69
|
-
# [
|
85
|
+
# [:upload_delete]
|
70
86
|
# Delete unknown files at the upload target location?
|
71
87
|
#
|
72
88
|
# The default value is false.
|
73
89
|
#
|
74
|
-
# [
|
75
|
-
#
|
90
|
+
# [:upload_options]
|
91
|
+
# Array of command-line arguments to the rsync command.
|
76
92
|
#
|
77
93
|
# The default value is an empty array.
|
78
94
|
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
# for additonal gem configuration.
|
95
|
+
# [:inochi_consumer]
|
96
|
+
# Add Inochi as a runtime dependency to the created gem?
|
82
97
|
#
|
83
|
-
#
|
98
|
+
# The default value is true.
|
99
|
+
#
|
100
|
+
# [:inochi_producer]
|
101
|
+
# Add Inochi as a development dependency to the created gem?
|
102
|
+
#
|
103
|
+
# The default value is true.
|
104
|
+
#
|
105
|
+
# [gem_config]
|
106
|
+
# Optional block that is passed
|
107
|
+
# to Gem::specification.new() for
|
108
|
+
# additonal gem configuration.
|
84
109
|
#
|
85
110
|
def Inochi.rake project_symbol, options = {}, &gem_config
|
86
111
|
program_file = first_caller_file
|
@@ -94,6 +119,8 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
94
119
|
project_module = fetch_project_module(project_symbol)
|
95
120
|
|
96
121
|
# supply default options
|
122
|
+
options[:test_with] ||= []
|
123
|
+
|
97
124
|
options[:rubyforge_project] ||= program_name
|
98
125
|
options[:rubyforge_section] ||= program_name
|
99
126
|
options[:raa_project] ||= program_name
|
@@ -104,9 +131,11 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
104
131
|
'.config', 'inochi', 'logins.yaml'
|
105
132
|
)
|
106
133
|
|
107
|
-
options[:upload_delete] ||= false
|
108
134
|
options[:upload_options] ||= []
|
109
135
|
|
136
|
+
options[:inochi_consumer] = true unless options.key? :inochi_consumer
|
137
|
+
options[:inochi_producer] = true unless options.key? :inochi_producer
|
138
|
+
|
110
139
|
# add AUTHORS constant to the project module
|
111
140
|
copyright_holders = options[:authors] ||
|
112
141
|
File.read(options[:license_file]).
|
@@ -115,6 +144,13 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
115
144
|
|
116
145
|
project_module.const_set :AUTHORS, copyright_holders
|
117
146
|
|
147
|
+
# establish development gem dependencies
|
148
|
+
[project_module, Inochi].uniq.each do |mod|
|
149
|
+
mod::DEVELOP.each_pair do |gem_name, version_reqs|
|
150
|
+
require_gem_version gem_name, version_reqs
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
118
154
|
require 'rake/clean'
|
119
155
|
|
120
156
|
hide_rake_task = lambda do |name|
|
@@ -186,31 +222,39 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
186
222
|
end
|
187
223
|
|
188
224
|
# testing
|
189
|
-
|
190
|
-
|
191
|
-
|
225
|
+
test_runner = lambda do |interpreter|
|
226
|
+
require 'tempfile'
|
227
|
+
script = Tempfile.new($$).path # will be deleted on program exit
|
228
|
+
|
229
|
+
libs = [program_name] + # load the project-under-test's library FIRST!
|
230
|
+
Array(options[:test_with]).map {|lib| "inochi/test/#{lib}" }
|
231
|
+
|
232
|
+
File.write script, %{
|
233
|
+
# the "-I." option lets us load helper libraries inside
|
234
|
+
# the test suite via "test/PROJECT_NAME/LIBRARY_NAME"
|
235
|
+
$LOAD_PATH.unshift '.', 'lib'
|
236
|
+
|
237
|
+
#{libs.inspect}.each do |lib|
|
238
|
+
require lib
|
239
|
+
end
|
240
|
+
|
241
|
+
# set title of test suite
|
242
|
+
$0 = #{project_module.to_s.inspect}
|
243
|
+
|
192
244
|
# dump language phrases *after* exercising all code (and
|
193
245
|
# thereby populating the phrases cache) in the project
|
194
246
|
at_exit do
|
195
247
|
if ENV['dump_lang_phrases'] == '1'
|
196
|
-
file =
|
197
|
-
list =
|
248
|
+
file = #{File.expand_path(lang_dump_file).inspect}
|
249
|
+
list = eval(#{project_symbol.to_s.inspect})::PHRASES.phrases
|
198
250
|
data = list.map {|s| s + ':' }.join("\n")
|
199
251
|
|
200
252
|
File.write file, data
|
201
253
|
|
202
|
-
puts "Extracted
|
254
|
+
puts "Extracted \#{list.length} language phrases into \#{file.inspect}"
|
203
255
|
end
|
204
256
|
end
|
205
257
|
|
206
|
-
# set title of test suite
|
207
|
-
$0 = File.basename(Dir.pwd)
|
208
|
-
|
209
|
-
require 'minitest/unit'
|
210
|
-
require 'minitest/spec'
|
211
|
-
require 'minitest/mock'
|
212
|
-
MiniTest::Unit.autorun
|
213
|
-
|
214
258
|
Dir['test/**/*.rb'].sort.each do |test|
|
215
259
|
unit = test.sub('test/', 'lib/')
|
216
260
|
|
@@ -225,10 +269,73 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
225
269
|
require unit_path
|
226
270
|
require test_path
|
227
271
|
else
|
228
|
-
warn "Skipped test
|
272
|
+
warn "Skipped test \#{test.inspect} because it lacks a corresponding \#{unit.inspect} unit."
|
229
273
|
end
|
230
274
|
end
|
231
|
-
}
|
275
|
+
}
|
276
|
+
|
277
|
+
command = [interpreter.to_s]
|
278
|
+
|
279
|
+
if interpreter == :rcov
|
280
|
+
command.push '--output', 'cov'
|
281
|
+
|
282
|
+
# omit internals from coverage analysis
|
283
|
+
command.push '--exclude-only', script
|
284
|
+
command.push '--exclude', Inochi::INSTALL
|
285
|
+
|
286
|
+
require 'rbconfig'
|
287
|
+
ruby_internals = File.dirname(Config::CONFIG['rubylibdir'])
|
288
|
+
command.push '--exclude', /^#{Regexp.quote ruby_internals}/.to_s
|
289
|
+
|
290
|
+
# show results summary after execution
|
291
|
+
command.push '-T'
|
292
|
+
else
|
293
|
+
# enable Ruby warnings during execution
|
294
|
+
command << '-w'
|
295
|
+
end
|
296
|
+
|
297
|
+
command << script
|
298
|
+
|
299
|
+
require 'shellwords'
|
300
|
+
command.concat Shellwords.shellwords(ENV['opts'].to_s)
|
301
|
+
|
302
|
+
sh(*command)
|
303
|
+
end
|
304
|
+
|
305
|
+
desc 'Run tests.'
|
306
|
+
task :test do
|
307
|
+
test_runner.call :ruby
|
308
|
+
end
|
309
|
+
|
310
|
+
desc 'Run tests with code coverage analysis.'
|
311
|
+
task 'test:cov' do
|
312
|
+
test_runner.call :rcov
|
313
|
+
end
|
314
|
+
|
315
|
+
CLEAN.include 'cov'
|
316
|
+
|
317
|
+
desc 'Run tests with multiple Ruby versions.'
|
318
|
+
task 'test:ruby' do
|
319
|
+
test_runner.call :multiruby
|
320
|
+
end
|
321
|
+
|
322
|
+
desc 'Report code quality statistics.'
|
323
|
+
task 'lint' do
|
324
|
+
separator = '-' * 80
|
325
|
+
|
326
|
+
linter = lambda do |*command|
|
327
|
+
name = command.first
|
328
|
+
|
329
|
+
puts "\n\n", separator, name, separator
|
330
|
+
system(*command)
|
331
|
+
end
|
332
|
+
|
333
|
+
ruby_files = Dir['**/*.rb']
|
334
|
+
|
335
|
+
linter.call 'sloccount', '.'
|
336
|
+
linter.call 'flay' # operates on all .rb & .erb files by default
|
337
|
+
linter.call 'reek', *ruby_files
|
338
|
+
linter.call 'roodi', *ruby_files
|
232
339
|
end
|
233
340
|
|
234
341
|
# documentation
|
@@ -264,20 +371,32 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
264
371
|
doc_api_dst = 'doc/api'
|
265
372
|
|
266
373
|
desc 'Build API reference.'
|
267
|
-
task 'doc:api' =>
|
374
|
+
task 'doc:api' => 'doc:api:rdoc'
|
268
375
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
'
|
273
|
-
'--readme', options[:license_file]
|
376
|
+
namespace :doc do
|
377
|
+
namespace :api do
|
378
|
+
require 'sdoc'
|
379
|
+
require 'rake/rdoctask'
|
274
380
|
|
275
|
-
|
276
|
-
|
381
|
+
Rake::RDocTask.new do |t|
|
382
|
+
t.rdoc_dir = doc_api_dst
|
383
|
+
t.template = 'direct' # lighter template used on railsapi.com
|
384
|
+
t.options.push '--fmt', 'shtml' # explictly set shtml generator
|
385
|
+
t.rdoc_files.include '[A-Z]*', 'lib/**/*.rb', 'ext/**/*.{rb,c*}'
|
277
386
|
|
278
|
-
|
387
|
+
# regen when sources change
|
388
|
+
task t.name => t.rdoc_files
|
389
|
+
|
390
|
+
t.main = options[:license_file]
|
391
|
+
task t.name => t.main
|
392
|
+
end
|
393
|
+
|
394
|
+
%w[rdoc clobber_rdoc rerdoc].each do |inner|
|
395
|
+
hide_rake_task["doc:api:#{inner}"]
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
279
399
|
|
280
|
-
CLEAN.include '.yardoc'
|
281
400
|
CLOBBER.include doc_api_dst
|
282
401
|
|
283
402
|
# announcements
|
@@ -479,15 +598,15 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
479
598
|
|
480
599
|
# packaging
|
481
600
|
desc 'Build a release.'
|
482
|
-
task :
|
483
|
-
sh $0, 'package'
|
601
|
+
task :gem => [:clobber, :doc] do
|
602
|
+
sh $0, 'gem:package'
|
484
603
|
end
|
485
604
|
CLEAN.include 'pkg'
|
486
605
|
|
487
606
|
# ruby gem
|
488
607
|
require 'rake/gempackagetask'
|
489
608
|
|
490
|
-
|
609
|
+
gem_spec = Gem::Specification.new do |gem|
|
491
610
|
authors = project_module::AUTHORS
|
492
611
|
|
493
612
|
if author = authors.first
|
@@ -521,29 +640,49 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
521
640
|
gem.description = gem.summary
|
522
641
|
gem.homepage = project_module::WEBSITE
|
523
642
|
gem.files = FileList['**/*'].exclude('_darcs') - CLEAN
|
524
|
-
gem.executables = project_module::PROGRAM
|
525
643
|
gem.has_rdoc = true
|
526
644
|
|
527
|
-
|
528
|
-
|
645
|
+
executable = project_module::PROGRAM
|
646
|
+
executable_path = File.join(gem.bindir, executable)
|
647
|
+
gem.executables = executable if File.exist? executable_path
|
648
|
+
|
649
|
+
project_module::DEVELOP.each_pair do |gem_name, version_reqs|
|
650
|
+
version_reqs = Array(version_reqs).compact
|
651
|
+
gem.add_development_dependency gem_name, *version_reqs
|
529
652
|
end
|
530
653
|
|
531
654
|
project_module::REQUIRE.each_pair do |gem_name, version_reqs|
|
655
|
+
version_reqs = Array(version_reqs).compact
|
532
656
|
gem.add_dependency gem_name, *version_reqs
|
533
657
|
end
|
534
658
|
|
659
|
+
unless project_module == Inochi
|
660
|
+
if options[:inochi_producer]
|
661
|
+
gem.add_development_dependency Inochi::PROGRAM, Inochi::VERSION.requirement
|
662
|
+
end
|
663
|
+
|
664
|
+
if options[:inochi_consumer]
|
665
|
+
gem.add_dependency Inochi::PROGRAM, Inochi::VERSION.requirement
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
535
669
|
# additional configuration is done by user
|
536
670
|
yield gem if gem_config
|
537
671
|
end
|
538
672
|
|
539
|
-
|
673
|
+
namespace :gem do
|
674
|
+
Rake::GemPackageTask.new(gem_spec).define
|
540
675
|
|
541
|
-
|
542
|
-
|
676
|
+
%w[gem package repackage clobber_package].each do |t|
|
677
|
+
hide_rake_task.call "gem:#{t}"
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
task :clobber => "gem:clobber_package"
|
543
682
|
|
544
683
|
# releasing
|
545
684
|
desc 'Publish a release.'
|
546
|
-
task 'pub' => %w[ pub:
|
685
|
+
task 'pub' => %w[ pub:gem pub:doc pub:ann ]
|
547
686
|
|
548
687
|
# connect to RubyForge services
|
549
688
|
pub_forge = nil
|
@@ -683,10 +822,12 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
683
822
|
form['post[subject]'] = ann_subject
|
684
823
|
form['post[text]'] = ann_text
|
685
824
|
|
686
|
-
|
825
|
+
# enable email notification
|
826
|
+
form.field_with(:name => 'post[subscribed_by_author]').value = '1'
|
827
|
+
|
687
828
|
page = form.submit
|
829
|
+
errors = Array(page/'//div[@class="error"]/text()')
|
688
830
|
|
689
|
-
errors = [page/'//div[@class="error"]/text()'].flatten
|
690
831
|
if errors.empty?
|
691
832
|
puts 'Successfully announced to ruby-talk mailing list:', page.uri
|
692
833
|
else
|
@@ -737,7 +878,7 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
737
878
|
|
738
879
|
# release packages
|
739
880
|
desc 'Publish release packages to RubyForge.'
|
740
|
-
task 'pub:
|
881
|
+
task 'pub:gem' => :pub_forge do
|
741
882
|
# check if this release was already published
|
742
883
|
version = project_module::VERSION
|
743
884
|
packages = pub_forge.autoconfig['release_ids'][pub_forge_section]
|
@@ -755,7 +896,7 @@ def Inochi.rake project_symbol, options = {}, &gem_config
|
|
755
896
|
pub_forge.__send__ command, pub_forge_project, pub_forge_section, version, *files
|
756
897
|
end
|
757
898
|
|
758
|
-
Rake::Task[:
|
899
|
+
Rake::Task[:gem].invoke
|
759
900
|
packages = Dir['pkg/*.[a-z]*']
|
760
901
|
|
761
902
|
unless packages.empty?
|