packnga 0.9.5 → 0.9.6

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/README.textile CHANGED
@@ -35,8 +35,8 @@ h2. Install
35
35
 
36
36
  h2. Documents
37
37
 
38
- * "Reference manual in English":http://groonga.rubyforge.org/packnga/en/
39
- * "Reference manual in Japanese":http://groonga.rubyforge.org/packnga/ja/
38
+ * "Reference manual in English":http://ranguba.org/packnga/en/
39
+ * "Reference manual in Japanese":http://ranguba.org/packnga/ja/
40
40
 
41
41
  h2. Mailing list
42
42
 
data/Rakefile CHANGED
@@ -33,6 +33,10 @@ require "packnga"
33
33
 
34
34
  helper = Bundler::GemHelper.new(base_dir)
35
35
  helper.install
36
+ def helper.version_tag
37
+ version
38
+ end
39
+
36
40
  spec = helper.gemspec
37
41
  Rake::Task["release"].prerequisites.clear
38
42
 
@@ -40,11 +44,13 @@ Gem::PackageTask.new(spec) do |pkg|
40
44
  pkg.need_tar_gz = true
41
45
  end
42
46
 
43
- Packnga::DocumentTask.new(spec)
47
+ Packnga::DocumentTask.new(spec) do |task|
48
+ task.original_language = "en"
49
+ task.translate_languages = "ja"
50
+ end
44
51
 
45
52
  Packnga::ReleaseTask.new(spec) do |task|
46
- task.index_html_dir = "../rroonga/doc/html"
47
- task.changes = File.read("doc/text/news.textile").split(/^h2\.\s(.*)$/)[2]
53
+ task.index_html_dir = "../ranguba.org"
48
54
  end
49
55
 
50
56
  desc "Run tests."
@@ -1,5 +1,31 @@
1
1
  h1. NEWS
2
2
 
3
+ h2. 0.9.6: 2012-12-19
4
+
5
+ h3. Improvements
6
+
7
+ * [ReferenceTask] Used GetText::Tools::MsgMerge.run instead of
8
+ GNU msgmerge.
9
+ * [DocumentTask] Added #original_language for translation
10
+ target. Its default value is user's current locale.
11
+ * [DocumentTask] Added #translate_languages to translate document.
12
+ Its default value is English if user's current locale isn't it,
13
+ otherwise default value is not specified.
14
+
15
+ h3. Changes
16
+
17
+ * Use user's current locale as the default translation targets
18
+ instead of Japanese.
19
+ * For Ranguba project:
20
+ * [template] Removed needless Piwik tag.
21
+ * Followed the move from rubyforge.org to ranguba.org.
22
+ * [ReleaseTask] Removed rubyforge support.
23
+
24
+ h3. Fixes
25
+
26
+ * [ReferenceTask] Removed needless patch for YARD. This patch is
27
+ needless from YARD 0.8.3.
28
+
3
29
  h2. 0.9.5: 2012-08-30
4
30
 
5
31
  h3. Improvements
@@ -62,14 +62,12 @@ Gem::Specification.new do |s|
62
62
  s.files += Dir.glob("doc/text/*.*")
63
63
  end
64
64
 
65
- s.homepage = "http://groonga.rubyforge.org/"
65
+ s.homepage = "http://ranguba.org/"
66
66
  s.licenses = ["LGPLv2"]
67
67
  s.require_paths = ["lib"]
68
- s.rubyforge_project = "groonga"
69
68
 
70
69
  s.add_runtime_dependency("rake")
71
70
  s.add_runtime_dependency("yard")
72
- s.add_runtime_dependency("rubyforge")
73
71
  s.add_runtime_dependency("gettext")
74
72
  s.add_development_dependency("test-unit")
75
73
  s.add_development_dependency("test-unit-notify")
@@ -78,9 +76,6 @@ Gem::Specification.new do |s|
78
76
  end
79
77
  </pre>
80
78
 
81
- If you set the attribute @rubyforge_project@ of @spec@ value,
82
- "Packnga::ReleaseTask" class creates tasks for rubyforge.
83
-
84
79
  Next, we should get @spec@ value in Rakefile from gemspec,
85
80
  so we write below source code in Rakefile.
86
81
 
@@ -104,8 +99,7 @@ Jeweler::Tasks.new do |_spec|
104
99
  spec = _spec
105
100
  spec.name = "packnga"
106
101
  spec.version = version
107
- spec.rubyforge_project = "groonga"
108
- spec.homepage = "http://groonga.rubyforge.org/"
102
+ spec.homepage = "http://ranguba.org/"
109
103
  spec.authors = ["Haruka Yoshihara", "Kouhei Sutou"]
110
104
  spec.email = ["yoshihara@clear-code.com", "kou@clear-code.com"]
111
105
  entries = File.read("README.textile").split(/^h2\.\s(.*)$/)
@@ -135,7 +129,6 @@ This table describes Packnga's classes.
135
129
  - Packnga::ReleaseTask :=
136
130
  This class create tasks for uploading references and package and preparing to upload them.
137
131
  It defines a task to tag the current version in git and a task to user-install gem for test.
138
- It also create tasks for uploading rubyforge if you set @rubyforge_project@ in @spec@ .
139
132
  =:
140
133
 
141
134
  Please see below for creating tasks.
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2011-2012 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
@@ -47,6 +47,20 @@ module Packnga
47
47
  @reference_task.base_dir = dir
48
48
  end
49
49
 
50
+ # Sets original language which you wrote document.
51
+ # Default value is your current locale (Locale.current.to_s).
52
+ # @param [String] language language you wrote document
53
+ def original_language=(language)
54
+ @reference_task.original_language = language
55
+ end
56
+
57
+ # Sets translate languages for document.
58
+ # @param [String] languages languages to translate
59
+ def translate_languages=(languages)
60
+ languages = [languages] if languages.instance_of?(String)
61
+ @reference_task.translate_languages = languages
62
+ end
63
+
50
64
  # Runs block to task for YARD documentation.
51
65
  def yard
52
66
  yield(@yard_task)
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
3
+ # Copyright (C) 2011-2012 Haruka Yoshihara <yoshihara@clear-code.com>
4
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
5
  #
5
6
  # This library is free software; you can redistribute it and/or
6
7
  # modify it under the terms of the GNU Lesser General Public
@@ -46,10 +47,22 @@ module Packnga
46
47
  # @return [Array<String>] target text files
47
48
  attr_accessor :text_files
48
49
 
50
+ # This attribute is used to set the language you wrote original
51
+ # document. Its default value is your current locale.
52
+ # @return [String] language you used to write document
53
+ attr_accessor :original_language
54
+
55
+ # This attribute is used to set languages for tnanslated document.
56
+ # If original_language isn't one, its default value is English.
57
+ # Otherwise, it is not specified.
58
+ # @return [Array<String>] target languages
59
+ attr_accessor :translate_languages
60
+
49
61
  # @private
50
62
  def initialize(spec)
51
63
  @spec = spec
52
64
  @base_dir = nil
65
+ @original_language = nil
53
66
  @translate_languages = nil
54
67
  @supported_languages = nil
55
68
  @source_files = nil
@@ -57,7 +70,6 @@ module Packnga
57
70
  @readme = nil
58
71
  @extra_files = nil
59
72
  @files = nil
60
- @html_files = nil
61
73
  @po_dir = nil
62
74
  @pot_file = nil
63
75
  end
@@ -76,9 +88,13 @@ module Packnga
76
88
  private
77
89
  def set_default_values
78
90
  @base_dir ||= Pathname.new("doc")
79
- @translate_languages ||= [:ja]
80
- @supported_languages = [:en, *@translate_languages]
81
- @html_files = FileList[(doc_en_dir + "**/*.html").to_s].to_a
91
+ @original_language ||= current_language
92
+ if @original_language == "en"
93
+ @translate_languages ||= []
94
+ else
95
+ @translate_languages ||= ["en"]
96
+ end
97
+ @supported_languages = [@original_language, *@translate_languages]
82
98
  @po_dir = "#{@base_dir}/po"
83
99
  @pot_file = "#{@po_dir}/#{@spec.name}.pot"
84
100
  @extra_files = @text_files
@@ -86,12 +102,20 @@ module Packnga
86
102
  @files = @source_files + @extra_files
87
103
  end
88
104
 
89
- def reference_base_dir
90
- @base_dir + "reference"
105
+ def current_language
106
+ locale = Locale.current
107
+ language = locale.language
108
+ region = locale.region
109
+
110
+ if region.nil?
111
+ language
112
+ else
113
+ "#{language}_#{region}"
114
+ end
91
115
  end
92
116
 
93
- def doc_en_dir
94
- @base_dir + "reference/en"
117
+ def reference_base_dir
118
+ @base_dir + "reference"
95
119
  end
96
120
 
97
121
  def html_base_dir
@@ -134,8 +158,8 @@ module Packnga
134
158
  file po_file => @files do |t|
135
159
  current_pot_file = "tmp.pot"
136
160
  create_pot_file(current_pot_file)
137
- GetText.msgmerge(po_file, current_pot_file,
138
- "#{@spec.name} #{Packnga::VERSION}")
161
+ GetText::Tools::MsgMerge.run(po_file, current_pot_file,
162
+ "-o", po_file)
139
163
  FileUtils.rm_f(current_pot_file)
140
164
  end
141
165
  else
@@ -374,399 +398,3 @@ module Packnga
374
398
  end
375
399
  end
376
400
  end
377
-
378
- # XXX: This module is the patch to translate documents.
379
- # This module should be deleted after
380
- # https://github.com/lsegal/yard/pull/594 is merged and released.
381
- # @private
382
- module YARD
383
- # @private
384
- module I18n
385
- # @private
386
- class Locale
387
- def translate(message)
388
- return message if @messages[message].nil?
389
- return message if @messages[message].empty?
390
- @messages[message]
391
- end
392
- end
393
- end
394
- end
395
-
396
- # XXX: This module is the re-definition of YARD module.
397
- # this module should be deleted in the next release of YARD.
398
- # @private
399
- module YARD
400
- module CLI
401
- # @private
402
- class Yardoc
403
- def parse_arguments(*args)
404
- parse_yardopts_options(*args)
405
-
406
- # Parse files and then command line arguments
407
- optparse(*support_rdoc_document_file!) if use_document_file
408
- optparse(*yardopts) if use_yardopts_file
409
- optparse(*args)
410
-
411
- # Last minute modifications
412
- self.files = ['{lib,app}/**/*.rb', 'ext/**/*.c'] if self.files.empty?
413
- self.files.delete_if {|x| x =~ /\A\s*\Z/ } # remove empty ones
414
- readme = Dir.glob('README*').first
415
- readme ||= Dir.glob(files.first).first if options.onefile
416
- options.readme ||= CodeObjects::ExtraFileObject.new(readme) if readme
417
- options.files.unshift(options.readme).uniq! if options.readme
418
-
419
- Tags::Library.visible_tags -= hidden_tags
420
- add_visibility_verifier
421
- add_api_verifier
422
-
423
- apply_locale
424
-
425
- # US-ASCII is invalid encoding for onefile
426
- if defined?(::Encoding) && options.onefile
427
- if ::Encoding.default_internal == ::Encoding::US_ASCII
428
- log.warn "--one-file is not compatible with US-ASCII encoding, using ASCII-8BIT"
429
- ::Encoding.default_external, ::Encoding.default_internal = ['ascii-8bit'] * 2
430
- end
431
- end
432
-
433
- if generate && !verify_markup_options
434
- false
435
- else
436
- true
437
- end
438
- end
439
-
440
- def apply_locale
441
- options.files.each do |file|
442
- file.locale = options.locale
443
- end
444
- end
445
-
446
- def output_options(opts)
447
- opts.separator ""
448
- opts.separator "Output options:"
449
-
450
- opts.on('--one-file', 'Generates output as a single file') do
451
- options.onefile = true
452
- end
453
-
454
- opts.on('--list', 'List objects to standard out (implies -n)') do |format|
455
- self.generate = false
456
- self.list = true
457
- end
458
-
459
- opts.on('--no-public', "Don't show public methods. (default shows public)") do
460
- visibilities.delete(:public)
461
- end
462
-
463
- opts.on('--protected', "Show protected methods. (default hides protected)") do
464
- visibilities.push(:protected)
465
- end
466
-
467
- opts.on('--private', "Show private methods. (default hides private)") do
468
- visibilities.push(:private)
469
- end
470
-
471
- opts.on('--no-private', "Hide objects with @private tag") do
472
- options.verifier.add_expressions '!object.tag(:private) &&
473
- (object.namespace.is_a?(CodeObjects::Proxy) || !object.namespace.tag(:private))'
474
- end
475
-
476
- opts.on('--[no-]api API', 'Generates documentation for a given API',
477
- '(objects which define the correct @api tag).',
478
- 'If --no-api is given, displays objects with',
479
- 'no @api tag.') do |api|
480
- api = '' if api == false
481
- apis.push(api)
482
- end
483
-
484
- opts.on('--embed-mixins', "Embeds mixin methods into class documentation") do
485
- options.embed_mixins << '*'
486
- end
487
-
488
- opts.on('--embed-mixin [MODULE]', "Embeds mixin methods from a particular",
489
- " module into class documentation") do |mod|
490
- options.embed_mixins << mod
491
- end
492
-
493
- opts.on('--no-highlight', "Don't highlight code blocks in output.") do
494
- options.highlight = false
495
- end
496
-
497
- opts.on('--default-return TYPE', "Shown if method has no return type. ",
498
- " (defaults to 'Object')") do |type|
499
- options.default_return = type
500
- end
501
-
502
- opts.on('--hide-void-return', "Hides return types specified as 'void'. ",
503
- " (default is shown)") do
504
- options.hide_void_return = true
505
- end
506
-
507
- opts.on('--query QUERY', "Only show objects that match a specific query") do |query|
508
- next if YARD::Config.options[:safe_mode]
509
- options.verifier.add_expressions(query.taint)
510
- end
511
-
512
- opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title|
513
- options.title = title
514
- end
515
-
516
- opts.on('-r', '--readme FILE', '--main FILE', 'The readme file used as the title page',
517
- ' of documentation.') do |readme|
518
- if File.file?(readme)
519
- options.readme = CodeObjects::ExtraFileObject.new(readme)
520
- else
521
- log.warn "Could not find readme file: #{readme}"
522
- end
523
- end
524
-
525
- opts.on('--files FILE1,FILE2,...', 'Any extra comma separated static files to be ',
526
- ' included (eg. FAQ)') do |files|
527
- add_extra_files(*files.split(","))
528
- end
529
-
530
- opts.on('--asset FROM[:TO]', 'A file or directory to copy over to output ',
531
- ' directory after generating') do |asset|
532
- re = /^(?:\.\.\/|\/)/
533
- from, to = *asset.split(':').map {|f| File.cleanpath(f) }
534
- to ||= from
535
- if from =~ re || to =~ re
536
- log.warn "Invalid file '#{asset}'"
537
- else
538
- assets[from] = to
539
- end
540
- end
541
-
542
- opts.on('-o', '--output-dir PATH',
543
- 'The output directory. (defaults to ./doc)') do |dir|
544
- options.serializer.basepath = dir
545
- end
546
-
547
- opts.on('-m', '--markup MARKUP',
548
- 'Markup style used in documentation, like textile, ',
549
- ' markdown or rdoc. (defaults to rdoc)') do |markup|
550
- self.has_markup = true
551
- options.markup = markup.to_sym
552
- end
553
-
554
- opts.on('-M', '--markup-provider MARKUP_PROVIDER',
555
- 'Overrides the library used to process markup ',
556
- ' formatting (specify the gem name)') do |markup_provider|
557
- options.markup_provider = markup_provider.to_sym
558
- end
559
-
560
- opts.on('--charset ENC', 'Character set to use when parsing files ',
561
- ' (default is system locale)') do |encoding|
562
- begin
563
- if defined?(Encoding) && Encoding.respond_to?(:default_external=)
564
- Encoding.default_external, Encoding.default_internal = encoding, encoding
565
- end
566
- rescue ArgumentError => e
567
- raise OptionParser::InvalidOption, e
568
- end
569
- end
570
-
571
- opts.on('-t', '--template TEMPLATE',
572
- 'The template to use. (defaults to "default")') do |template|
573
- options.template = template.to_sym
574
- end
575
-
576
- opts.on('-p', '--template-path PATH',
577
- 'The template path to look for templates in.',
578
- ' (used with -t).') do |path|
579
- next if YARD::Config.options[:safe_mode]
580
- YARD::Templates::Engine.register_template_path(File.expand_path(path))
581
- end
582
-
583
- opts.on('-f', '--format FORMAT',
584
- 'The output format for the template.',
585
- ' (defaults to html)') do |format|
586
- options.format = format.to_sym
587
- end
588
-
589
- opts.on('--no-stats', 'Don\'t print statistics') do
590
- self.statistics = false
591
- end
592
-
593
- opts.on('--locale LOCALE',
594
- 'The locale for generated documentation.',
595
- ' (defaults to en)') do |locale|
596
- options.locale = locale
597
- end
598
-
599
- opts.on('--po-dir DIR',
600
- 'The directory that has .po files.',
601
- ' (defaults to #{YARD::Registry.po_dir})') do |dir|
602
- YARD::Registry.po_dir = dir
603
- end
604
- end
605
- end
606
- end
607
-
608
- module CodeObjects
609
- # @private
610
- class ExtraFileObject
611
- attr_writer :attributes
612
- attr_reader :locale
613
-
614
- def initialize(filename, contents = nil)
615
- self.filename = filename
616
- self.name = File.basename(filename).gsub(/\.[^.]+$/, '')
617
- self.attributes = SymbolHash.new(false)
618
- @original_contents = contents
619
- @parsed = false
620
- @locale = nil
621
- ensure_parsed
622
- end
623
-
624
- def attributes
625
- ensure_parsed
626
- @attributes
627
- end
628
-
629
- def contents
630
- ensure_parsed
631
- @contents
632
- end
633
-
634
- def contents=(contents)
635
- @original_contents = contents
636
- @parsed = false
637
- end
638
-
639
- def locale=(locale)
640
- @locale = locale
641
- @parsed = false
642
- end
643
-
644
- private
645
- def ensure_parsed
646
- return if @parsed
647
- @parsed = true
648
- @contents = parse_contents(@original_contents || File.read(@filename))
649
- end
650
-
651
- def parse_contents(data)
652
- retried = false
653
- cut_index = 0
654
- data = translate(data)
655
- data = data.split("\n")
656
- data.each_with_index do |line, index|
657
- case line
658
- when /^#!(\S+)\s*$/
659
- if index == 0
660
- attributes[:markup] = $1
661
- else
662
- cut_index = index
663
- break
664
- end
665
- when /^\s*#\s*@(\S+)\s*(.+?)\s*$/
666
- attributes[$1] = $2
667
- else
668
- cut_index = index
669
- break
670
- end
671
- end
672
- data = data[cut_index..-1] if cut_index > 0
673
- contents = data.join("\n")
674
-
675
- if contents.respond_to?(:force_encoding) && attributes[:encoding]
676
- begin
677
- contents.force_encoding(attributes[:encoding])
678
- rescue ArgumentError
679
- log.warn "Invalid encoding `#{attributes[:encoding]}' in #{filename}"
680
- end
681
- end
682
- contents
683
- rescue ArgumentError => e
684
- if retried && e.message =~ /invalid byte sequence/
685
- # This should never happen.
686
- log.warn "Could not read #{filename}, #{e.message}. You probably want to set `--charset`."
687
- return ''
688
- end
689
- data.force_encoding('binary') if data.respond_to?(:force_encoding)
690
- retried = true
691
- retry
692
- end
693
-
694
- def translate(data)
695
- text = YARD::I18n::Text.new(data, :have_header => true)
696
- text.translate(YARD::Registry.locale(locale))
697
- end
698
- end
699
- end
700
-
701
- module I18n
702
- # @private
703
- class Locale
704
- def load(locale_directory)
705
- return false if @name.nil?
706
-
707
- po_file = File.join(locale_directory, "#{@name}.po")
708
- return false unless File.exist?(po_file)
709
-
710
- begin
711
- require "gettext/tools/poparser"
712
- require "gettext/runtime/mofile"
713
- rescue LoadError
714
- log.warn "Need gettext gem for i18n feature:"
715
- log.warn " gem install gettext"
716
- return false
717
- end
718
-
719
- parser = GetText::PoParser.new
720
- parser.report_warning = false
721
- data = GetText::MoFile.new
722
- parser.parse_file(po_file, data)
723
- @messages.merge!(data)
724
- true
725
- end
726
- end
727
- end
728
-
729
- # @private
730
- module Registry
731
- DEFAULT_PO_DIR = "po"
732
- class << self
733
- def locale(name)
734
- thread_local_store.locale(name)
735
- end
736
-
737
- attr_accessor :po_dir
738
- undef po_dir, po_dir=
739
- def po_dir=(dir) Thread.current[:__yard_po_dir__] = dir end
740
- def po_dir
741
- Thread.current[:__yard_po_dir__] ||= DEFAULT_PO_DIR
742
- end
743
- end
744
- end
745
-
746
- # @private
747
- class RegistryStore
748
- def initialize
749
- @file = nil
750
- @checksums = {}
751
- @store = {}
752
- @proxy_types = {}
753
- @object_types = {:root => [:root]}
754
- @notfound = {}
755
- @loaded_objects = 0
756
- @available_objects = 0
757
- @locales = {}
758
- @store[:root] = CodeObjects::RootObject.allocate
759
- @store[:root].send(:initialize, nil, :root)
760
- end
761
-
762
- def locale(name)
763
- @locales[name] ||= load_locale(name)
764
- end
765
-
766
- def load_locale(name)
767
- locale = I18n::Locale.new(name)
768
- locale.load(Registry.po_dir)
769
- locale
770
- end
771
- end
772
- end
@@ -15,14 +15,10 @@
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
- require "rubyforge"
19
- require "digest"
20
-
21
18
  module Packnga
22
19
  # This class creates release tasks.
23
20
  #
24
21
  # Release tasks tag current version and install gem for test.
25
- # It also define tasks to upload RubyForge whether option.
26
22
  #
27
23
  # @since 0.9.0
28
24
  class ReleaseTask
@@ -37,27 +33,16 @@ module Packnga
37
33
  # This attribute is message when tagging in release.
38
34
  # @param [String] value message
39
35
  attr_writer :tag_message
40
- # This attribute is options for uploading RubyForge by rsync.
41
- # @param [Hash] value options for uploading.
42
- attr_writer :publish_options
43
- # This attribute is text for changes in new release
44
- # to post news to RubyForge.
45
- # @param [String] value text for changes.
46
- attr_writer :changes
47
36
  # Defines task for preparing to release.
48
37
  # Defined tasks update version and release-date in index files
49
38
  # and tag in git.
50
- # If you set rubyforge_project of Jeweler::Task.new with its given block,
51
- # it also define tasks to update RubyForge.
52
39
  # @param [Gem::Specification] spec specification for your package
53
40
  def initialize(spec)
54
41
  @spec = spec
55
42
  @index_html_dir = nil
56
- @rubyforge = nil
57
43
  @tag_messsage = nil
58
44
  @publish_options = nil
59
45
  @changes = nil
60
- @rubyforge_password = nil
61
46
  yield(self) if block_given?
62
47
  set_default_values
63
48
  define_tasks
@@ -84,7 +69,6 @@ module Packnga
84
69
  namespace :release do
85
70
  define_info_task
86
71
  define_tag_task
87
- define_rubyforge_tasks
88
72
  end
89
73
  end
90
74
 
@@ -105,7 +89,7 @@ module Packnga
105
89
  raise ArgumentError, "Specify option(s) of #{empty_options.join(", ")}."
106
90
  end
107
91
  @index_html_dir = Pathname(@index_html_dir)
108
- indexes = [@index_html_dir + "index.html", @index_html_dir + "index.html.ja"]
92
+ indexes = [@index_html_dir + "index.html", @index_html_dir + "ja/index.html"]
109
93
  indexes.each do |index|
110
94
  content = replaced_content = File.read(index)
111
95
  [[old_version, new_version],
@@ -136,103 +120,5 @@ module Packnga
136
120
  sh("git tag -a #{version} -m '#{@tag_message}'")
137
121
  end
138
122
  end
139
-
140
- def define_rubyforge_tasks
141
- return if @spec.rubyforge_project.nil?
142
- @rubyforge = RubyForge.new
143
- @uninitialized_password = Digest::SHA2.hexdigest(Time.now.to_f.to_s)
144
- @rubyforge.configure("password" => @uninitialized_password)
145
- define_reference_task
146
- define_html_task
147
- define_publish_task
148
- define_upload_tasks
149
- define_post_task
150
- end
151
-
152
- def define_reference_task
153
- namespace :reference do
154
- desc "Upload document to RubyForge."
155
- task :publish => "reference:publication:generate" do
156
- rsync_to_rubyforge(@spec, "#{html_reference_dir}/", @spec.name, @publish_options)
157
- end
158
- end
159
- end
160
-
161
- def define_html_task
162
- namespace :html do
163
- desc "Publish HTML to Web site."
164
- task :publish do
165
- rsync_to_rubyforge(@spec, "#{html_base_dir}/", "", @publish_options)
166
- end
167
- end
168
- end
169
-
170
- def define_publish_task
171
- desc "Upload document and HTML to RubyForge."
172
- task :publish => ["html:publish", "reference:publish"]
173
- end
174
-
175
- def define_upload_tasks
176
- namespace :rubyforge do
177
- desc "Upload tar.gz to RubyForge."
178
- task :upload => "package" do
179
- ensure_rubyforge_password
180
- if @rubyforge.autoconfig["group_ids"][@spec.rubyforge_project].nil?
181
- @rubyforge.scrape_config
182
- @rubyforge.save_autoconfig
183
- end
184
- if @rubyforge.autoconfig["package_ids"][@spec.name].nil?
185
- @rubyforge.create_package(@rubyforge.autoconfig["group_ids"][@spec.rubyforge_project], @spec.name)
186
- end
187
- @rubyforge.add_release(@spec.rubyforge_project,
188
- @spec.name,
189
- @spec.version.to_s,
190
- "pkg/#{@spec.name}-#{@spec.version}.tar.gz")
191
- end
192
- end
193
- desc "Release to RubyForge."
194
- task :rubyforge => "release:rubyforge:upload"
195
- end
196
-
197
- def define_post_task
198
- namespace :rubyforge do
199
- namespace :news do
200
- desc "Post news to RubyForge."
201
- task :post do
202
- ensure_rubyforge_password
203
- group_id =
204
- @rubyforge.autoconfig["group_ids"][@spec.rubyforge_project]
205
- subject =
206
- "#{@spec.name} version #{@spec.version} has been released!"
207
- body = @spec.description + "\nChanges:" + @changes
208
-
209
- if @rubyforge.post_news(group_id, subject, body).nil?
210
- raise "News couldn't be posted to RubyForge."
211
- end
212
- end
213
- end
214
- end
215
- end
216
-
217
- def rsync_to_rubyforge(spec, source, destination, options={})
218
- host = "#{@rubyforge.userconfig["username"]}@rubyforge.org"
219
-
220
- rsync_args = "-av --exclude '*.erb' --chmod=ug+w"
221
- rsync_args << " --group=#{spec.rubyforge_project}"
222
- rsync_args << " --delete" if options[:delete]
223
- rsync_args << " --dry-run" if options[:dryrun]
224
- remote_dir = "/var/www/gforge-projects/#{spec.rubyforge_project}/"
225
- sh("rsync #{rsync_args} #{source} #{host}:#{remote_dir}#{destination}")
226
- end
227
-
228
- def ensure_rubyforge_password
229
- if @rubyforge.userconfig["password"] == @uninitialized_password
230
- print "password:"
231
- system("stty -echo")
232
- @rubyforge.userconfig["password"] = STDIN.gets.chomp
233
- system("stty echo")
234
- puts
235
- end
236
- end
237
123
  end
238
124
  end
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Packnga
20
20
  # Packnga version.
21
- VERSION = "0.9.5"
21
+ VERSION = "0.9.6"
22
22
  end
data/test/run-test.rb ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env 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
+ $KCODE = "u" if RUBY_VERSION < "1.9"
19
+
20
+ require "test-unit"
21
+ require "test/unit/notify"
22
+
23
+ base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
24
+ lib_dir = File.join(base_dir, "lib")
25
+ test_dir = File.join(base_dir, "test")
26
+
27
+ $LOAD_PATH.unshift(lib_dir)
28
+ $LOAD_PATH.unshift(test_dir)
29
+
30
+ require "packnga"
31
+
32
+ Dir.glob("#{test_dir}/**/test{_,-}*.rb") do |file|
33
+ require file.sub(/\.rb$/, '')
34
+ end
35
+
36
+ ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] ||= "5000"
37
+
38
+ exit Test::Unit::AutoRunner.run
@@ -0,0 +1,216 @@
1
+ # -*- coding: utf-8 -*-
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
+ class DocumentTaskTest < Test::Unit::TestCase
19
+ def teardown
20
+ Rake::Task.clear
21
+ end
22
+
23
+ def test_base_directory_set
24
+ spec = Gem::Specification.new
25
+ base_dir = Pathname("base_directory")
26
+ document_task = Packnga::DocumentTask.new(spec) do |task|
27
+ task.base_dir = base_dir.to_s
28
+ end
29
+
30
+ document_task.yard do |yard_task|
31
+ assert_equal(base_dir, yard_task.base_dir)
32
+ end
33
+
34
+ document_task.reference do |reference_task|
35
+ assert_equal(base_dir, reference_task.base_dir)
36
+ end
37
+ end
38
+
39
+ class TranslateLanguagesTest < self
40
+ def test_single
41
+ translate_language = "ja"
42
+ options = {:translate_languages => translate_language}
43
+ document_task = create_document_task(options)
44
+
45
+ document_task.reference do |reference_task|
46
+ assert_equal([translate_language], reference_task.translate_languages)
47
+ end
48
+ end
49
+
50
+ def test_multi
51
+ translate_languages = ["ja", "uk"]
52
+ options = {:translate_languages => translate_languages}
53
+ document_task = create_document_task(options)
54
+
55
+ document_task.reference do |reference_task|
56
+ assert_equal(translate_languages, reference_task.translate_languages)
57
+ end
58
+ end
59
+
60
+ private
61
+ def create_document_task(options)
62
+ translate_languages = options[:translate_languages]
63
+ spec = Gem::Specification.new
64
+ Packnga::DocumentTask.new(spec) do |task|
65
+ task.translate_languages = translate_languages
66
+ end
67
+ end
68
+ end
69
+
70
+ def test_original_language
71
+ original_language = "original_language"
72
+ spec = Gem::Specification.new
73
+ document_task = Packnga::DocumentTask.new(spec) do |task|
74
+ task.original_language = original_language
75
+ end
76
+
77
+ document_task.reference do |reference_task|
78
+ assert_equal(original_language, reference_task.original_language)
79
+ end
80
+ end
81
+
82
+ class ReadmeTest < self
83
+ def setup
84
+ @readme = "README.textile"
85
+ spec = Gem::Specification.new do |_spec|
86
+ _spec.files = [@readme]
87
+ end
88
+ document_task = Packnga::DocumentTask.new(spec)
89
+ @yard_task = extract_yard_task(document_task)
90
+ @reference_task = extract_reference_task(document_task)
91
+ end
92
+
93
+ def test_readme
94
+ assert_equal(@readme, @yard_task.readme)
95
+ assert_equal(@readme, @reference_task.readme)
96
+ end
97
+
98
+ def test_source_files
99
+ assert_equal([], @yard_task.source_files)
100
+ assert_equal([], @reference_task.source_files)
101
+ end
102
+
103
+ def test_text_files
104
+ assert_equal([], @yard_task.text_files)
105
+ assert_equal([], @reference_task.text_files)
106
+ end
107
+ end
108
+
109
+ class SourceFilesTest < self
110
+ def setup
111
+ source_ruby_files = ["lib/packnga.rb", "lib/packnga/version.rb"]
112
+ other_ruby_files = ["other1.rb", "ext/other2.rb"]
113
+
114
+ source_c_files = ["ext/packnga.c", "ext/packnga/version.c"]
115
+ other_c_files = ["other1.c", "lib/other2.c"]
116
+
117
+ spec = Gem::Specification.new do |_spec|
118
+ _spec.files = [
119
+ source_ruby_files,
120
+ other_ruby_files,
121
+ source_c_files,
122
+ other_c_files,
123
+ ]
124
+ end
125
+ document_task = Packnga::DocumentTask.new(spec)
126
+ @yard_task = extract_yard_task(document_task)
127
+ @reference_task = extract_reference_task(document_task)
128
+
129
+ @source_files = source_ruby_files + source_c_files
130
+ end
131
+
132
+ def test_readme
133
+ assert_nil(@yard_task.readme)
134
+ assert_nil(@reference_task.readme)
135
+ end
136
+
137
+ def test_source_files
138
+ assert_equal(@source_files, @yard_task.source_files)
139
+ assert_equal(@source_files, @reference_task.source_files)
140
+ end
141
+
142
+ def test_text_files
143
+ assert_equal([], @yard_task.text_files)
144
+ assert_equal([], @reference_task.text_files)
145
+ end
146
+ end
147
+
148
+ class TextFilesTest < self
149
+ def setup
150
+ @source_text_files = ["doc/text/tutorial.textile", "doc/text/new.md"]
151
+ other_text_files = ["other1.textile", "doc/other2.md", "Rakefile"]
152
+
153
+ spec = Gem::Specification.new do |_spec|
154
+ _spec.files = [
155
+ @source_text_files,
156
+ other_text_files,
157
+ ]
158
+ end
159
+ document_task = Packnga::DocumentTask.new(spec)
160
+ @yard_task = extract_yard_task(document_task)
161
+ @reference_task = extract_reference_task(document_task)
162
+ end
163
+
164
+ def test_readme
165
+ assert_nil(@yard_task.readme)
166
+ assert_nil(@reference_task.readme)
167
+ end
168
+
169
+ def test_source_files
170
+ assert_equal([], @yard_task.source_files)
171
+ assert_equal([], @reference_task.source_files)
172
+ end
173
+
174
+ def test_text_files
175
+ assert_equal(@source_text_files, @yard_task.text_files)
176
+ assert_equal(@source_text_files, @reference_task.text_files)
177
+ end
178
+ end
179
+
180
+ class NoFilesTest < self
181
+ def setup
182
+ spec = Gem::Specification.new
183
+ document_task = Packnga::DocumentTask.new(spec)
184
+ @yard_task = extract_yard_task(document_task)
185
+ @reference_task = extract_reference_task(document_task)
186
+ end
187
+
188
+ def test_readme
189
+ assert_nil(@yard_task.readme)
190
+ assert_nil(@reference_task.readme)
191
+ end
192
+
193
+ def test_source_files
194
+ assert_equal([], @yard_task.source_files)
195
+ assert_equal([], @reference_task.source_files)
196
+ end
197
+
198
+ def test_text_files
199
+ assert_equal([], @yard_task.text_files)
200
+ assert_equal([], @reference_task.text_files)
201
+ end
202
+ end
203
+
204
+ private
205
+ def extract_yard_task(document_task)
206
+ document_task.yard do |yard_task|
207
+ yard_task
208
+ end
209
+ end
210
+
211
+ def extract_reference_task(document_task)
212
+ document_task.reference do |reference_task|
213
+ reference_task
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
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
+ require "test/unit/rr"
19
+ require "tmpdir"
20
+
21
+ class ReferenceTaskTest < Test::Unit::TestCase
22
+ def teardown
23
+ Rake::Task.clear
24
+ end
25
+
26
+ def test_po_update_no_po_file_exists
27
+ Dir.mktmpdir do |base_dir|
28
+ package_name = "packnga"
29
+ language = "ja"
30
+
31
+ spec = Gem::Specification.new do |_spec|
32
+ _spec.name = package_name
33
+ end
34
+
35
+ Packnga::DocumentTask.new(spec) do |task|
36
+ task.translate_languages = language
37
+ task.base_dir = base_dir
38
+ end
39
+
40
+ po_dir = "#{base_dir}/po"
41
+ pot_file = "#{po_dir}/#{package_name}.pot"
42
+ po_file = "#{po_dir}/#{language}.po"
43
+
44
+ mock(GetText::Tools::MsgInit).run("--input", pot_file,
45
+ "--output", po_file,
46
+ "--locale", language)
47
+
48
+ Rake::Task["reference:po:update:ja"].invoke
49
+ end
50
+ end
51
+ 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.5
4
+ version: 0.9.6
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-08-30 00:00:00.000000000 Z
13
+ date: 2012-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -44,22 +44,6 @@ dependencies:
44
44
  - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: rubyforge
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
47
  - !ruby/object:Gem::Dependency
64
48
  name: gettext
65
49
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +51,7 @@ dependencies:
67
51
  requirements:
68
52
  - - ! '>='
69
53
  - !ruby/object:Gem::Version
70
- version: '0'
54
+ version: 2.3.6
71
55
  type: :runtime
72
56
  prerelease: false
73
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,7 +59,7 @@ dependencies:
75
59
  requirements:
76
60
  - - ! '>='
77
61
  - !ruby/object:Gem::Version
78
- version: '0'
62
+ version: 2.3.6
79
63
  - !ruby/object:Gem::Dependency
80
64
  name: test-unit
81
65
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +164,9 @@ files:
180
164
  - doc/text/release.textile
181
165
  - doc/text/lgpl.txt
182
166
  - doc/text/news.textile
167
+ - test/run-test.rb
168
+ - test/test-document-task.rb
169
+ - test/test-reference-task.rb
183
170
  homepage: http://groonga.rubyforge.org/
184
171
  licenses:
185
172
  - LGPLv2
@@ -195,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
182
  version: '0'
196
183
  segments:
197
184
  - 0
198
- hash: -2327966079894861645
185
+ hash: 4177022307643837781
199
186
  required_rubygems_version: !ruby/object:Gem::Requirement
200
187
  none: false
201
188
  requirements:
@@ -204,12 +191,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
191
  version: '0'
205
192
  segments:
206
193
  - 0
207
- hash: -2327966079894861645
194
+ hash: 4177022307643837781
208
195
  requirements: []
209
- rubyforge_project: groonga
196
+ rubyforge_project:
210
197
  rubygems_version: 1.8.23
211
198
  signing_key:
212
199
  specification_version: 3
213
200
  summary: An utility library to package i18n-ed library.
214
- test_files: []
201
+ test_files:
202
+ - test/run-test.rb
203
+ - test/test-document-task.rb
204
+ - test/test-reference-task.rb
215
205
  has_rdoc: