packnga 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --output-dir doc/reference/en
2
+ --markup textile
3
+ --use-cache .yardoc
4
+ lib/**/*.rb
data/Gemfile CHANGED
@@ -15,6 +15,6 @@
15
15
  # License along with this library; if not, write to the Free Software
16
16
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
 
18
- source "http://rubygems.org/"
18
+ source "https://rubygems.org/"
19
19
 
20
20
  gemspec
data/README.textile CHANGED
@@ -12,7 +12,7 @@ Packnga is a library to translate to many languages by YARD.
12
12
 
13
13
  h2. Authors
14
14
 
15
- * Haruka Yoshihara <yoshihara@clear-code.com>
15
+ * Haruka Yoshihara <yshr04hrk@gmail.com>
16
16
  * Kouhei Sutou <kou@clear-code.com>
17
17
 
18
18
  h2. License
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8; mode: ruby -*-
2
2
  #
3
- # Copyright (C) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2011-2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
4
  # Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
@@ -16,16 +16,16 @@
16
16
  # License along with this library; if not, write to the Free Software
17
17
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 
19
- require 'English'
19
+ require "English"
20
20
 
21
- require 'pathname'
22
- require 'rubygems'
23
- require 'rubygems/package_task'
24
- require 'bundler/gem_helper'
21
+ require "pathname"
22
+ require "rubygems"
23
+ require "rubygems/package_task"
24
+ require "bundler/gem_helper"
25
25
 
26
26
  base_dir = File.join(File.dirname(__FILE__))
27
27
 
28
- packnga_lib_dir = File.join(base_dir, 'lib')
28
+ packnga_lib_dir = File.join(base_dir, "lib")
29
29
  $LOAD_PATH.unshift(packnga_lib_dir)
30
30
  ENV["RUBYLIB"] = "#{packnga_lib_dir}:#{ENV['RUBYLIB']}"
31
31
 
@@ -1,5 +1,37 @@
1
1
  h1. NEWS
2
2
 
3
+ h2. 0.9.8: 2013-06-07
4
+
5
+ h3. Improvements
6
+
7
+ * [ReferenceTask] Used YARD I18n feature for translating references.
8
+ For it, YARD 0.8.6.1 or later is required.
9
+ * [ReferenceTask] Supported replacing filenames which aren't
10
+ supported by GitHub Pages in "reference:publication:generate" task.
11
+ This task renames the fimename "_index.html" (methods list page) to
12
+ "alphabetical_index.html", because GitHub Pages doesn't support
13
+ files which their filenames start with "_".
14
+ * [ReferenceTask] Added the task ("release:references:upload") to
15
+ copy generated references to a HTML directory.
16
+ A HTML directory, for example, is a repository of GitHub Pages. In
17
+ this case, this task is used to commit references to GitHub Pages.
18
+ * [Referencetask] Dropped support to upload .htaccess.
19
+ * [ReleaseTask] Used the version in your gemspec as a new version
20
+ when no version is specified as an argument by "release:info:update"
21
+ task. A new version is used to replace HTML index files.
22
+
23
+ h3. Fixes
24
+
25
+ * [ReferenceTask] Generated "reference path" correctly in merged PO
26
+ files.
27
+ "reference path" is a path of a file including translated message
28
+ (msgid) and it's attached to its corresponded msgid.
29
+ * [ReleaseTask] Removed needless replaces in HTML files in the
30
+ task "release:info:update".
31
+ * [ReferenceTask] Added missing description for the task
32
+ "reference:publication:generate" to generate references for
33
+ publication.
34
+
3
35
  h2. 0.9.7: 2012-12-26
4
36
 
5
37
  h3. Improvements
@@ -9,14 +9,20 @@ h2. news.textileに変更点のまとめ
9
9
  $ git log -p --reverse (前回のリリースバージョン)..
10
10
  </pre>
11
11
 
12
- ログを"Author:"で検索しながら、ユーザにとって知る必要があるもの(ユーザに見える情報)のコミットログのみを抜き出す。
12
+ ログを"Author:"で検索しながら、ユーザにとって知る必要があるもののコミットログのみを抜き出す。
13
+
14
+ ユーザにとって必要な情報とは、仕様の変更や新しい機能の追加など、ユーザーがリリースするライブラリを使う上で影響ある情報である。
15
+ 逆に、リファクタリング、テストの変更、変数名の変更など、ユーザーが直接意識しない部分については書く必要はない。
16
+
13
17
  次に、抜き出したコミットログを1つずつ見て、その先頭にカテゴリ名がある場合は、":"を削除してカテゴリ名を"["と"]"で囲む。
14
18
  カテゴリ名を除いたログの先頭にある単語を過去形にし、頭文字を大文字にする。
15
19
  その後、ログを次のように分類する。
16
- 機能などに新しく追加されたものに関してはImprovement,
17
- 動作の変更などはChanges,
18
- バグの修正など前バージョンまでにあった問題を修正したものはFixesに記述する。
19
- また、コミットログの行末に[人名]がある場合はその人名をThanks以下に書く。
20
+
21
+ * Improvements: 機能などを新しく追加したコミットのログ
22
+ * Changes: 動作の変更など、今まであったものを変更したログ
23
+ * Fixes: バグの修正など前バージョンまでにあった問題を修正したログ
24
+
25
+ また、コミットログの行末に[人名]がある場合は、Thanksという分類を作って、その人名をThanks以下に書く。
20
26
  さらにREADMEにあるThanks以下にも名前を追加する。
21
27
 
22
28
  この作業をリリース予定日よりも前に行った場合は、目に見えるところにコミットIDをメモしておく。
@@ -40,6 +46,8 @@ h3. Fixes
40
46
  *
41
47
 
42
48
  h3. Thanks
49
+
50
+ *
43
51
  </pre>
44
52
 
45
53
  h2. 日本語訳の作成
@@ -67,20 +75,47 @@ doc/reference/ja/file.news.htmlなどのja.poを編集した箇所が正しく
67
75
 
68
76
  h2. バージョンとリリース日の更新
69
77
 
70
- 下記コマンドを入力して、プロジェクトページ(html/index.html、html/index.html.ja)の最新バージョンとリリース日をそれぞれ今回のリリースに合わせたものに更新する。
78
+ ranguba.orgのindexページ(index.html、ja/index.html)の最新バージョンとリリース日をそれぞれ今回のリリースに合わせたものに更新する。
79
+
80
+ まず、任意の位置で次のコマンドを実行して、ranguba.orgのリポジトリをcloneする。
81
+
82
+ <pre>
83
+ !!!command_line
84
+ $ git clone git@github.com:ranguba/ranguba.org.git
85
+ </pre>
86
+
87
+ そして、リリースするライブラリのRakefileに次を追加する。
88
+
89
+ <pre>
90
+ !!!ruby
91
+ Packnga::ReleaseTask.new(spec) do |task|
92
+ task.index_html_dir = "/path/to/ranguba.org"
93
+ end
94
+ </pre>
95
+
96
+ その後、次のコマンドを実行して最新バージョンとリリース日を更新する。
71
97
 
72
98
  <pre>
73
99
  !!!command_line
74
100
  $ rake release:info:update OLD_VERSION=(前回リリース時のバージョン) OLD_RELEASE_DATE=(前回リリース日) RELEASE_DATE=(今回のリリース日)
75
101
  </pre>
76
102
 
103
+ h2. .gemspecの確認
104
+
105
+ (パッケージ名).gemspecの中身が問題ないか確認する。特に初めてリリースするときは注意すること。
106
+
107
+ * .yardoptsをspec.filesに指定しているか(rubydoc.infoでドキュメントを閲覧するときに必要)
108
+ * spec.files+=のつもりでspec.files=になっていないか
109
+ * その他、spec.files=へ指定するファイルは過不足ないか・間違っていないか(diredなどでファイル一覧を見ながら作業する)
110
+ * 依存関係(add_{runtime/developement}_dependency)は間違っていないか
111
+
77
112
  h2. gemパッケージの作成
78
113
 
79
114
  下記コマンドを打ってアップロード用のgemパッケージをビルドする。
80
115
 
81
116
  <pre>
82
117
  !!!command_line
83
- $ make clean
118
+ $ make clean # rroongaのみ必要
84
119
  $ rake build
85
120
  </pre>
86
121
 
@@ -104,21 +139,27 @@ $ NO_MAKE=yes ruby1.9.1 test/run-test.rb
104
139
 
105
140
  h2. news.textileの最終的なまとめとリファレンス作成
106
141
 
107
- コミットIDをメモしていた場合、下記コマンドを実行してログを表示する。
142
+ 前回のリリース時から現在までの変更点をnews.textileにまとめるため、下記コマンドを実行してgitのコミットログを表示する。
108
143
 
109
144
  <pre>
110
145
  !!!command_line
111
- git log --reverse -p (前回のリリース時のバージョン)..(メモしていたコミットID)
146
+ $ git log -p --reverse (前回のリリースバージョン)..
112
147
  </pre>
113
148
 
114
- ログを"Author:"で検索しながら、ユーザにとって知る必要があるもの(ユーザに見える情報)のコミットログのみを抜き出す。
149
+ ログを"Author:"で検索しながら、ユーザにとって知る必要があるもののコミットログのみを抜き出す。
150
+
151
+ ユーザにとって必要な情報とは、仕様の変更や新しい機能の追加など、ユーザーがリリースするライブラリを使う上で影響ある情報である。
152
+ 逆に、リファクタリング、テストの変更、変数名の変更など、ユーザーが直接意識しない部分については書く必要はない。
153
+
115
154
  次に、抜き出したコミットログを1つずつ見て、その先頭にカテゴリ名がある場合は、":"を削除してカテゴリ名を"["と"]"で囲む。
116
155
  カテゴリ名を除いたログの先頭にある単語を過去形にし、頭文字を大文字にする。
117
156
  その後、ログを次のように分類する。
118
- 機能などに新しく追加されたものに関してはImprovement,
119
- 動作の変更などはChanges,
120
- バグの修正など前バージョンまでにあった問題を修正したものはFixesに記述する。
121
- また、コミットログの行末に[人名]がある場合はその人名をThanks以下に書く。
157
+
158
+ * Improvements: 機能などを新しく追加したコミットのログ
159
+ * Changes: 動作の変更など、今まであったものを変更したログ
160
+ * Fixes: バグの修正など前バージョンまでにあった問題を修正したログ
161
+
162
+ また、コミットログの行末に[人名]がある場合は、Thanksという分類を作って、その人名をThanks以下に書く。
122
163
  さらにREADMEにあるThanks以下にも名前を追加する。
123
164
 
124
165
  下記コマンドを実行してja.poを更新する。
@@ -142,7 +183,7 @@ doc/reference/ja/file.news.htmlなどのja.poを編集した箇所が正しく
142
183
 
143
184
  h2. これまでの変更をpush
144
185
 
145
- ここまでに行った変更をcommitしてgit pushする。
186
+ ここまでに行った変更をcommitしてpushする。
146
187
 
147
188
  h2. リリースバージョンのタグの作成とrubygems.orgへのパッケージのアップロード
148
189
 
@@ -153,29 +194,32 @@ h2. リリースバージョンのタグの作成とrubygems.orgへのパッケ
153
194
  $ rake release
154
195
  </pre>
155
196
 
156
- h2. rubyforgeにパッケージをアップロード
157
197
 
158
- 下記コマンドを実行してアップロードする。
198
+ h2. リファレンスをranguba.orgにアップロード
199
+
200
+ 次のコマンドを実行して、リファレンスをranguba.orgのリポジトリ内にコピーする。
159
201
 
160
202
  <pre>
161
203
  !!!command_line
162
- $ ruby1.8 -S rake release:rubyforge:upload
163
- $ ruby1.8 -S rake release:reference:publish
204
+ $ rake reference:publication:generate
205
+ $ rake release:references:upload
164
206
  </pre>
165
207
 
166
- rroonga以外の場合、index.html関連はrake release:html:publishでアップロードされないので、rroongaに移動してから下記コマンドを実行する。
208
+ その後、 次のコマンドを実行してranguba.orgのリポジトリをcloneしたディレクトリに移動する。
167
209
 
168
210
  <pre>
169
- !!!command_line
170
- $ ruby1.9.1 -S rake release:html:publish
211
+ $ cd /path/to/ranguba.org
171
212
  </pre>
172
213
 
214
+ そして、コピーにより生じた変更をranguba.orgのリポジトリにpushする。
215
+ ranguba.orgはGithub Pagesを使っているので、pushすると自動的にranguba.orgのサイトも更新される。
216
+
173
217
  h2. メーリングリストにリリースの周知
174
218
 
175
219
  メーリングリストにリリースした旨を書いたメールを流す。
176
220
  日本語の他、英語のメーリングリストにもリリースした旨を英語で書いたメールを流す。
177
221
 
178
- h3.日本語でのメールの具体例
222
+ h3. 日本語でのメールの具体例
179
223
 
180
224
  <pre>
181
225
  吉原です。
@@ -304,16 +348,6 @@ yoshihara
304
348
  (yoshihara at clear-code.com)
305
349
  </pre>
306
350
 
307
- h2. rubyforgeのニュースを更新
308
-
309
- rroonga以外の場合、もとのディレクトリに戻る。
310
- 下記コマンドを入力してrubyforgeの最新ニュースを更新する。
311
-
312
- <pre>
313
- !!!command_line
314
- $ rake releace:rubyforge:news:post
315
- </pre>
316
-
317
351
  h2. 次回リリース時のバージョン番号の設定
318
352
 
319
- rroongaはext/groonga/rb-grn.h、それ以外はlib/(パッケージ名)/version.rbにある、RB_GRN_MAJOR_VERSION,RB_GRN_MINOR_VERSION,RB_GRN_MICRO_VERSIONの値を次回リリース時のバージョンの値に変更する。
353
+ rroongaはext/groonga/rb-grn.h、それ以外はlib/(パッケージ名)/version.rbにある、RB_GRN_MAJOR_VERSION,RB_GRN_MINOR_VERSION,RB_GRN_MICRO_VERSIONの値を次回リリース時のバージョンの値に変更し、コミットする。
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011-2012 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2011-2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
4
  # Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
@@ -117,10 +117,6 @@ module Packnga
117
117
  yield(@reference_task)
118
118
  end
119
119
 
120
- def htaccess
121
- @reference_task.htaccess
122
- end
123
-
124
120
  private
125
121
  def define
126
122
  set_default_values
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011-2012 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2011-2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
4
  # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
@@ -91,11 +91,6 @@ module Packnga
91
91
  define_tasks
92
92
  end
93
93
 
94
- # path of .htaccess.
95
- def htaccess
96
- html_reference_dir + ".htaccess"
97
- end
98
-
99
94
  private
100
95
  def set_default_values
101
96
  @base_dir ||= Pathname.new("doc")
@@ -154,8 +149,8 @@ module Packnga
154
149
  po_file = "#{@po_dir}/#{language}.po"
155
150
 
156
151
  if File.exist?(po_file)
157
- file po_file => @files do |t|
158
- current_pot_file = "tmp.pot"
152
+ file po_file => @files do
153
+ current_pot_file = "#{@po_dir}/tmp.pot"
159
154
  create_pot_file(current_pot_file)
160
155
  GetText::Tools::MsgMerge.run(po_file, current_pot_file,
161
156
  "-o", po_file)
@@ -199,13 +194,22 @@ module Packnga
199
194
  po_file = "#{@po_dir}/#{language}.po"
200
195
  desc "Translates documents to #{language}."
201
196
  task language => [po_file, reference_base_dir, *@files] do
202
- locale = YARD::I18n::Locale.new(language)
203
- locale.load(@po_dir)
204
- Dir.mktmpdir do |temp_dir|
205
- create_translated_sources(temp_dir, locale)
206
- copy_extra_files(temp_dir)
207
- create_translated_documents(temp_dir, locale)
208
- end
197
+ translate_doc_dir = "#{reference_base_dir}/#{language}"
198
+ rm_rf(translate_doc_dir)
199
+ yardoc = YARD::CLI::Yardoc.new
200
+ options = [
201
+ "--title", @spec.name,
202
+ "--po-dir", @po_dir,
203
+ "--locale", language,
204
+ "--charset", "utf-8",
205
+ "--no-private",
206
+ "--output-dir", translate_doc_dir
207
+ ]
208
+ options += ["--readme", @readme] if @readme
209
+ options += @source_files
210
+ options += ["-"]
211
+ options += @text_files
212
+ yardoc.run(*options)
209
213
  end
210
214
  end
211
215
  end
@@ -229,12 +233,10 @@ module Packnga
229
233
  raw_reference_dir = reference_base_dir + language.to_s
230
234
  prepared_reference_dir = html_reference_dir + language.to_s
231
235
  rm_rf(prepared_reference_dir.to_s)
232
- head = erb_template("head.#{language}")
233
- header = erb_template("header.#{language}")
234
- footer = erb_template("footer.#{language}")
235
236
  raw_reference_dir.find do |path|
236
237
  relative_path = path.relative_path_from(raw_reference_dir)
237
- prepared_path = prepared_reference_dir + relative_path
238
+ prepared_path = generate_prepared_path(prepared_reference_dir,
239
+ relative_path)
238
240
  if path.directory?
239
241
  mkdir_p(prepared_path.to_s)
240
242
  else
@@ -242,60 +244,78 @@ module Packnga
242
244
  when /(?:file|method|class)_list\.html\z/
243
245
  cp(path.to_s, prepared_path.to_s)
244
246
  when /\.html\z/
245
- relative_dir_path = relative_path.dirname
246
- current_path = relative_dir_path + path.basename
247
- if current_path.basename.to_s == "index.html"
248
- current_path = current_path.dirname
249
- end
250
- top_path = html_base_dir.relative_path_from(prepared_path.dirname)
251
- package_path = top_path + @spec.name
252
- paths = {
253
- :top => top_path,
254
- :current => current_path,
255
- :package => package_path,
256
- }
257
- templates = {
258
- :head => head,
259
- :header => header,
260
- :footer => footer
261
- }
262
- content = apply_template(File.read(path.to_s),
263
- paths,
264
- templates,
265
- language)
266
- File.open(prepared_path.to_s, "w") do |file|
267
- file.print(content)
268
- end
247
+ create_published_file(path, relative_path, prepared_path,
248
+ language)
269
249
  else
270
250
  cp(path.to_s, prepared_path.to_s)
271
251
  end
272
252
  end
273
253
  end
274
254
  end
275
- File.open(htaccess, "w") do |file|
276
- file.puts("RedirectMatch permanent ^/#{@spec.name}/$ " +
277
- "#{@spec.homepage}#{@spec.name}/en/")
278
- end
279
255
  end
280
256
 
281
- task :generate => ["reference:generate", "reference:publication:prepare"]
257
+ desc "Generates reference for publication."
258
+ task :generate => ["reference:generate",
259
+ "reference:publication:prepare"]
260
+ end
261
+ end
262
+
263
+ def create_published_file(path, relative_path, prepared_path, language)
264
+ relative_dir_path = relative_path.dirname
265
+ if path.basename.to_s == "_index.html"
266
+ current_path = relative_dir_path + "alphabetical_index.html"
267
+ else
268
+ current_path = relative_dir_path + path.basename
269
+ if current_path.basename.to_s == "index.html"
270
+ current_path = current_path.dirname
271
+ end
272
+ end
273
+ top_path = html_base_dir.relative_path_from(prepared_path.dirname)
274
+ package_path = top_path + @spec.name
275
+ paths = {
276
+ :top => top_path,
277
+ :current => current_path,
278
+ :package => package_path,
279
+ }
280
+ templates = {
281
+ :head => erb_template("head.#{language}"),
282
+ :header => erb_template("header.#{language}"),
283
+ :footer => erb_template("footer.#{language}")
284
+ }
285
+ content = apply_templates(File.read(path.to_s),
286
+ paths,
287
+ templates,
288
+ language)
289
+ content = content.gsub(/"(.*?)_index\.html"/,
290
+ "\"\\1alphabetical_index.html\"")
291
+ File.open(prepared_path.to_s, "w") do |file|
292
+ file.print(content)
293
+ end
294
+ end
295
+
296
+ def generate_prepared_path(prepared_reference_dir, relative_path)
297
+ prepared_path = prepared_reference_dir + relative_path
298
+ if prepared_path.basename.to_s == "_index.html"
299
+ prepared_path.dirname + "alphabetical_index.html"
300
+ else
301
+ prepared_path
282
302
  end
283
303
  end
284
304
 
285
- def apply_template(content, paths, templates, language)
286
- content = content.sub(/lang="en"/, "lang=\"#{language}\"")
305
+ def apply_templates(content, paths, templates, language)
306
+ content = content.gsub(/lang="en"/, "lang=\"#{language}\"")
287
307
 
288
308
  title = nil
289
- content = content.sub(/<title>(.+?)<\/title>/m) do
309
+ content = content.gsub(/<title>(.+?)<\/title>/m) do
290
310
  title = $1
291
311
  templates[:head].result(binding)
292
312
  end
293
313
 
294
- content = content.sub(/<body(?:.*?)>/) do |body_start|
314
+ content = content.gsub(/<body(?:.*?)>/) do |body_start|
295
315
  "#{body_start}\n#{templates[:header].result(binding)}\n"
296
316
  end
297
317
 
298
- content = content.sub(/<\/body/) do |body_end|
318
+ content = content.gsub(/<\/body/) do |body_end|
299
319
  "\n#{templates[:footer].result(binding)}\n#{body_end}"
300
320
  end
301
321
 
@@ -309,91 +329,5 @@ module Packnga
309
329
  erb.filename = file
310
330
  erb
311
331
  end
312
-
313
- def create_translated_documents(output_dir, locale)
314
- language = locale.name.to_s
315
- translate_doc_dir = "#{reference_base_dir}/#{language}"
316
- po_dir = File.expand_path(@po_dir)
317
- mkdir_p(translate_doc_dir)
318
-
319
- Dir.chdir(output_dir) do
320
- YARD::Registry.clear
321
- YARD.parse(@source_files)
322
-
323
- options = [
324
- "--title", @spec.name,
325
- "-o", translate_doc_dir,
326
- "--po-dir", po_dir,
327
- "--locale", language,
328
- "--charset", "utf-8",
329
- "--no-private"
330
- ]
331
- options += ["--readme", @readme] if @readme
332
- options += @source_files
333
- options += ["-"]
334
- options += @text_files
335
-
336
- YARD::CLI::Yardoc.run(*options)
337
- end
338
- translated_files = File.join(output_dir, translate_doc_dir, "**")
339
- FileUtils.cp_r(Dir.glob(translated_files), translate_doc_dir)
340
- end
341
-
342
- def create_translated_sources(output_dir, locale)
343
- YARD.parse(@source_files)
344
- create_translated_files(@source_files, output_dir) do |content|
345
- code_objects = YARD::Registry.all
346
- code_objects.each do |code_object|
347
- original_docstring = code_object.docstring
348
- content = translate_content_part(content,
349
- original_docstring,
350
- locale)
351
-
352
- original_docstring.tags.each do |tag|
353
- original_tag_text = tag.text
354
- next if original_tag_text.nil?
355
- content = translate_content_part(content,
356
- original_tag_text,
357
- locale)
358
- end
359
- end
360
- content
361
- end
362
- end
363
-
364
- def copy_extra_files(output_dir)
365
- @extra_files.each do |file|
366
- target_extra_file = File.join(output_dir, file)
367
- FileUtils.mkdir_p(File.dirname(target_extra_file))
368
- FileUtils.cp_r(file, target_extra_file)
369
- end
370
- end
371
-
372
- def create_translated_files(original_files, output_dir)
373
- original_files.each do |file|
374
- translated_file = File.join(output_dir, file)
375
- FileUtils.mkdir_p(File.dirname(translated_file))
376
- content = File.read(file)
377
-
378
- translated_text = yield(content)
379
-
380
- File.open(translated_file, "w") do |file|
381
- file.puts(translated_text)
382
- end
383
- end
384
- end
385
-
386
- def translate_content_part(content, original_text, locale)
387
- translated_content = ""
388
- text = YARD::I18n::Text.new(original_text)
389
- translate_text = text.translate(locale)
390
- original_text = original_text.each_line.collect do |line|
391
- "(.+)#{Regexp.escape(line)}"
392
- end
393
- translate_text = translate_text.each_line.collect do |line|
394
- "\\1#{line}"
395
- end
396
- content.sub(/#{original_text.join}/, translate_text.join)
397
- end
398
332
  end
399
333
  end
@@ -50,11 +50,11 @@ module Packnga
50
50
 
51
51
  private
52
52
  def html_base_dir
53
- @base_dir + "html"
53
+ File.join(@base_dir, "html")
54
54
  end
55
55
 
56
56
  def html_reference_dir
57
- html_base_dir + @spec.name
57
+ File.join(html_base_dir, @spec.name)
58
58
  end
59
59
 
60
60
  def set_default_values
@@ -68,6 +68,7 @@ module Packnga
68
68
  def define_tasks
69
69
  namespace :release do
70
70
  define_info_task
71
+ define_reference_upload_task
71
72
  define_tag_task
72
73
  end
73
74
  end
@@ -76,35 +77,19 @@ module Packnga
76
77
  namespace :info do
77
78
  desc "Update version in index HTML."
78
79
  task :update do
79
- old_version = ENV["OLD_VERSION"]
80
- old_release_date = ENV["OLD_RELEASE_DATE"]
81
- new_release_date = ENV["RELEASE_DATE"] || Time.now.strftime("%Y-%m-%d")
82
- new_version = ENV["VERSION"]
83
-
84
- empty_options = []
85
- empty_options << "OLD_VERSION" if old_version.nil?
86
- empty_options << "OLD_RELEASE_DATE" if old_release_date.nil?
87
-
88
- unless empty_options.empty?
89
- raise ArgumentError, "Specify option(s) of #{empty_options.join(", ")}."
90
- end
91
80
  @index_html_dir = Pathname(@index_html_dir)
92
- indexes = [@index_html_dir + "index.html", @index_html_dir + "ja/index.html"]
81
+ indexes = [
82
+ @index_html_dir + "index.html",
83
+ @index_html_dir + "ja/index.html"
84
+ ]
93
85
  indexes.each do |index|
94
86
  content = replaced_content = File.read(index)
95
- [[old_version, new_version],
96
- [old_release_date, new_release_date]].each do |old, new|
97
- replaced_content = replaced_content.gsub(/#{Regexp.escape(old)}/, new)
98
- if /\./ =~ old
99
- old_underscore = old.gsub(/\./, '-')
100
- new_underscore = new.gsub(/\./, '-')
101
- replaced_content =
102
- replaced_content.gsub(/#{Regexp.escape(old_underscore)}/,
103
- new_underscore)
104
- end
87
+ package_infos.each do |key, (old, new)|
88
+ next if old == new
89
+ old_regexp = /#{Regexp.escape(old)}/
90
+ replaced_content = replaced_content.gsub(old_regexp, new)
105
91
  end
106
92
 
107
- next if replaced_content == content
108
93
  File.open(index, "w") do |output|
109
94
  output.print(replaced_content)
110
95
  end
@@ -113,6 +98,36 @@ module Packnga
113
98
  end
114
99
  end
115
100
 
101
+ def package_infos
102
+ old_version = ENV["OLD_VERSION"]
103
+ old_release_date = ENV["OLD_RELEASE_DATE"]
104
+ new_release_date = ENV["RELEASE_DATE"] || Time.now.strftime("%Y-%m-%d")
105
+ new_version = ENV["VERSION"] || @spec.version.to_s
106
+
107
+ empty_options = []
108
+ empty_options << "OLD_VERSION" if old_version.nil?
109
+ empty_options << "OLD_RELEASE_DATE" if old_release_date.nil?
110
+ empty_options << "VERSION" if new_version.empty?
111
+
112
+ unless empty_options.empty?
113
+ raise ArgumentError, "Specify option(s) of #{empty_options.join(", ")}."
114
+ end
115
+
116
+ {
117
+ :version => [old_version, new_version],
118
+ :release_date => [old_release_date, new_release_date]
119
+ }
120
+ end
121
+
122
+ def define_reference_upload_task
123
+ namespace :references do
124
+ desc "Copy references to reference html directory."
125
+ task :upload do
126
+ cp_r(html_reference_dir, @index_html_dir)
127
+ end
128
+ end
129
+ end
130
+
116
131
  def define_tag_task
117
132
  desc "Tag the current revision."
118
133
  task :tag do
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Packnga
20
20
  # Packnga version.
21
- VERSION = "0.9.7"
21
+ VERSION = "0.9.8"
22
22
  end
data/packnga.gemspec ADDED
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8; mode: ruby -*-
2
+ #
3
+ # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ base_dir = File.dirname(__FILE__)
19
+ $LOAD_PATH.unshift(File.expand_path("lib", base_dir))
20
+ require "packnga/version"
21
+
22
+ version = Packnga::VERSION.dup
23
+
24
+ readme_path = File.join(base_dir, "README.textile")
25
+ entries = File.read(readme_path).split(/^h2\.\s(.*)$/)
26
+ entry = lambda do |entry_title|
27
+ entries[entries.index(entry_title) + 1]
28
+ end
29
+
30
+ authors = []
31
+ emails = []
32
+ entry.call("Authors").each_line do |line|
33
+ if /\*\s*(.+)\s<([^<>]*)>$/ =~ line
34
+ authors << $1
35
+ emails << $2
36
+ end
37
+ end
38
+
39
+ clean_white_space = lambda do |entry|
40
+ entry.gsub(/(\A\n+|\n+\z)/, '') + "\n"
41
+ end
42
+ description = clean_white_space.call(entry.call("Description"))
43
+ summary, description = description.split(/\n\n+/, 2)
44
+
45
+ Gem::Specification.new do |spec|
46
+ spec.name = "packnga"
47
+ spec.version = version
48
+ spec.authors = authors
49
+ spec.email = emails
50
+ spec.summary = summary
51
+ spec.description = description
52
+
53
+ spec.extra_rdoc_files = ["README.textile"]
54
+ spec.files = ["README.textile", "Rakefile", "Gemfile", ".yardopts"]
55
+ spec.files += ["packnga.gemspec"]
56
+ Dir.chdir(base_dir) do
57
+ spec.files += Dir.glob("lib/**/*.rb")
58
+ spec.files += Dir.glob("doc/text/*.*")
59
+ spec.test_files = Dir.glob("test/**/*.rb")
60
+ end
61
+
62
+ spec.homepage = "http://ranguba.org/packnga/en/"
63
+ spec.licenses = ["LGPLv2"]
64
+ spec.require_paths = ["lib"]
65
+
66
+ spec.add_runtime_dependency("rake")
67
+ spec.add_runtime_dependency("yard", ">= 0.8.6.1")
68
+ spec.add_runtime_dependency("gettext", ">= 2.3.6")
69
+ spec.add_development_dependency("test-unit")
70
+ spec.add_development_dependency("test-unit-notify")
71
+ spec.add_development_dependency("test-unit-rr")
72
+ spec.add_development_dependency("bundler")
73
+ spec.add_development_dependency("RedCloth")
74
+ end
75
+
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -48,4 +48,41 @@ class ReferenceTaskTest < Test::Unit::TestCase
48
48
  Rake::Task["reference:po:update:ja"].invoke
49
49
  end
50
50
  end
51
+
52
+ def test_reference_publication_prepare
53
+ Dir.mktmpdir do |base_dir|
54
+ package_name = "packnga"
55
+ language = "en"
56
+
57
+ spec = Gem::Specification.new do |_spec|
58
+ _spec.name = package_name
59
+ end
60
+
61
+ Packnga::DocumentTask.new(spec) do |task|
62
+ task.translate_language = language
63
+ task.base_dir = base_dir
64
+ end
65
+
66
+ reference_dir = File.join(base_dir, "reference/#{language}")
67
+ fixtures_dir = File.join(File.dirname(__FILE__), "fixtures")
68
+ fixtures = Dir.glob(File.join(fixtures_dir, "{file.news,_index}.html"))
69
+
70
+ FileUtils.mkdir_p(reference_dir)
71
+ FileUtils.cp_r(fixtures, reference_dir)
72
+
73
+ Rake::Task["reference:publication:prepare"].invoke
74
+
75
+ html_dir = File.join(base_dir, "html/#{package_name}/#{language}")
76
+ Dir.chdir(html_dir) do
77
+ assert_true(File.exist?("file.news.html"))
78
+ assert_true(File.exist?("alphabetical_index.html"))
79
+ assert_false(File.exist?("_index.html"))
80
+
81
+ expected_file = File.join(fixtures_dir, "expected", "file.news.html")
82
+ expected_content = File.read(expected_file)
83
+ actual_content = File.read("file.news.html")
84
+ assert_equal(expected_content, actual_content)
85
+ end
86
+ end
87
+ end
51
88
  end
@@ -0,0 +1,191 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "test/unit/rr"
19
+ require "tmpdir"
20
+
21
+ class ReleaseTaskTest < Test::Unit::TestCase
22
+ def teardown
23
+ Rake::Task.clear
24
+ end
25
+
26
+ class InfoUpdateTest < self
27
+ def test_none_version
28
+ Dir.mktmpdir do |base_dir|
29
+ index_dir = File.join(base_dir, "index_dir")
30
+
31
+ spec = Gem::Specification.new
32
+
33
+ Packnga::ReleaseTask.new(spec) do |task|
34
+ task.index_html_dir = index_dir
35
+ task.base_dir = base_dir
36
+ end
37
+
38
+ index = "1.0.0 2013-03-28"
39
+ index_file = File.join(index_dir, "index.html")
40
+ create_index_file(index_file, index)
41
+ ja_index_file = File.join(index_dir, "ja", "index.html")
42
+ create_index_file(ja_index_file, index)
43
+
44
+ package_infos = {
45
+ :old_version => "1.0.0",
46
+ :old_release_date => "2013-03-28",
47
+ :new_release_date => "2013-04-01"
48
+ }
49
+ set_environments(package_infos)
50
+ assert_raise(ArgumentError) do
51
+ Rake::Task["release:info:update"].invoke
52
+ end
53
+ end
54
+ end
55
+
56
+ def test_version_in_spec
57
+ Dir.mktmpdir do |base_dir|
58
+ index_dir = File.join(base_dir, "index_dir")
59
+
60
+ spec = nil
61
+ Gem::Specification.new do |_spec|
62
+ spec = _spec
63
+ spec.version = "1.0.1"
64
+ end
65
+ Packnga::ReleaseTask.new(spec) do |task|
66
+ task.index_html_dir = index_dir
67
+ task.base_dir = base_dir
68
+ end
69
+
70
+ index = "1.0.0 2013-03-28"
71
+ index_file = File.join(index_dir, "index.html")
72
+ create_index_file(index_file, index)
73
+ ja_index_file = File.join(index_dir, "ja", "index.html")
74
+ create_index_file(ja_index_file, index)
75
+
76
+ package_infos = {
77
+ :old_version => "1.0.0",
78
+ :old_release_date => "2013-03-28",
79
+ :new_release_date => "2013-04-01"
80
+ }
81
+ set_environments(package_infos)
82
+ Rake::Task["release:info:update"].invoke
83
+
84
+ expected_index = "1.0.1 2013-04-01"
85
+ assert_equal(expected_index, File.read(index_file))
86
+ assert_equal(expected_index, File.read(ja_index_file))
87
+ end
88
+ end
89
+
90
+ def test_version_in_env
91
+ Dir.mktmpdir do |base_dir|
92
+ index_dir = File.join(base_dir, "index_dir")
93
+
94
+ spec = Gem::Specification.new
95
+ Packnga::ReleaseTask.new(spec) do |task|
96
+ task.index_html_dir = index_dir
97
+ task.base_dir = base_dir
98
+ end
99
+
100
+ index = "1.0.0 2013-03-28"
101
+ index_file = File.join(index_dir, "index.html")
102
+ create_index_file(index_file, index)
103
+ ja_index_file = File.join(index_dir, "ja", "index.html")
104
+ create_index_file(ja_index_file, index)
105
+
106
+ package_infos = {
107
+ :old_version => "1.0.0",
108
+ :new_version => "1.0.1",
109
+ :old_release_date => "2013-03-28",
110
+ :new_release_date => "2013-04-01"
111
+ }
112
+ set_environments(package_infos)
113
+ Rake::Task["release:info:update"].invoke
114
+
115
+ expected_index = "1.0.1 2013-04-01"
116
+ assert_equal(expected_index, File.read(index_file))
117
+ assert_equal(expected_index, File.read(ja_index_file))
118
+ end
119
+ end
120
+
121
+ def test_same_versions
122
+ Dir.mktmpdir do |base_dir|
123
+ index_dir = File.join(base_dir, "index_dir")
124
+
125
+ Packnga::ReleaseTask.new(Gem::Specification.new) do |task|
126
+ task.index_html_dir = index_dir
127
+ task.base_dir = base_dir
128
+ end
129
+
130
+ index = "1.0.0 2013-03-28"
131
+ index_file = File.join(index_dir, "index.html")
132
+ create_index_file(index_file, index)
133
+ ja_index_file = File.join(index_dir, "ja", "index.html")
134
+ create_index_file(ja_index_file, index)
135
+
136
+ package_infos = {
137
+ :old_version => "1.0.0",
138
+ :new_version => "1.0.0",
139
+ :old_release_date => "2013-03-28",
140
+ :new_release_date => "2013-04-01"
141
+ }
142
+ set_environments(package_infos)
143
+
144
+ Rake::Task["release:info:update"].invoke
145
+ expected_index = "1.0.0 2013-04-01"
146
+ assert_equal(expected_index, File.read(index_file))
147
+ assert_equal(expected_index, File.read(ja_index_file))
148
+ end
149
+ end
150
+
151
+ private
152
+ def create_index_file(index_file, index)
153
+ FileUtils.mkdir_p(File.dirname(index_file))
154
+ File.open(index_file, "w") do |file|
155
+ file.print(index)
156
+ end
157
+ end
158
+
159
+ def set_environments(package_infos={})
160
+ ENV["OLD_VERSION"] = package_infos[:old_version]
161
+ ENV["VERSION"] = package_infos[:new_version]
162
+ ENV["OLD_RELEASE_DATE"] = package_infos[:old_release_date]
163
+ ENV["RELEASE_DATE"] = package_infos[:new_release_date]
164
+ end
165
+ end
166
+
167
+ def test_upload_references
168
+ Dir.mktmpdir do |base_dir|
169
+ package_name = "packnga"
170
+ index_dir = File.join(base_dir, "index_dir")
171
+ reference_dir = File.join(base_dir, "html", package_name)
172
+ reference_filename = "file.html"
173
+
174
+ spec = Gem::Specification.new do |_spec|
175
+ _spec.name = package_name
176
+ end
177
+
178
+ Packnga::ReleaseTask.new(spec) do |task|
179
+ task.index_html_dir = index_dir
180
+ task.base_dir = base_dir
181
+ end
182
+
183
+ FileUtils.mkdir_p(reference_dir)
184
+ FileUtils.touch(File.join(reference_dir, reference_filename))
185
+
186
+ Rake::Task["release:references:upload"].invoke
187
+ uploaded_path = File.join(index_dir, reference_filename)
188
+ assert_true(File.exist?(uploaded_path))
189
+ end
190
+ end
191
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packnga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-26 00:00:00.000000000 Z
13
+ date: 2013-06-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ! '>='
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
38
+ version: 0.8.6.1
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: 0.8.6.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: gettext
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -144,7 +144,7 @@ description: ! 'Packnga is a library to translate to many languages by YARD.
144
144
 
145
145
  '
146
146
  email:
147
- - yoshihara@clear-code.com
147
+ - yshr04hrk@gmail.com
148
148
  - kou@clear-code.com
149
149
  executables: []
150
150
  extensions: []
@@ -154,20 +154,23 @@ files:
154
154
  - README.textile
155
155
  - Rakefile
156
156
  - Gemfile
157
- - lib/packnga/reference-task.rb
157
+ - .yardopts
158
+ - packnga.gemspec
158
159
  - lib/packnga/document-task.rb
159
- - lib/packnga/yard-task.rb
160
- - lib/packnga/version.rb
160
+ - lib/packnga/reference-task.rb
161
161
  - lib/packnga/release-task.rb
162
+ - lib/packnga/version.rb
163
+ - lib/packnga/yard-task.rb
162
164
  - lib/packnga.rb
163
- - doc/text/tutorial.textile
164
- - doc/text/release.textile
165
165
  - doc/text/lgpl.txt
166
166
  - doc/text/news.textile
167
+ - doc/text/release.textile
168
+ - doc/text/tutorial.textile
167
169
  - test/run-test.rb
168
170
  - test/test-document-task.rb
169
171
  - test/test-reference-task.rb
170
- homepage: http://groonga.rubyforge.org/
172
+ - test/test-release-task.rb
173
+ homepage: http://ranguba.org/packnga/en/
171
174
  licenses:
172
175
  - LGPLv2
173
176
  post_install_message:
@@ -182,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
185
  version: '0'
183
186
  segments:
184
187
  - 0
185
- hash: -416471251229729484
188
+ hash: -2492821662086626858
186
189
  required_rubygems_version: !ruby/object:Gem::Requirement
187
190
  none: false
188
191
  requirements:
@@ -191,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
194
  version: '0'
192
195
  segments:
193
196
  - 0
194
- hash: -416471251229729484
197
+ hash: -2492821662086626858
195
198
  requirements: []
196
199
  rubyforge_project:
197
200
  rubygems_version: 1.8.23
@@ -202,4 +205,5 @@ test_files:
202
205
  - test/run-test.rb
203
206
  - test/test-document-task.rb
204
207
  - test/test-reference-task.rb
208
+ - test/test-release-task.rb
205
209
  has_rdoc: