ruby-japanize 0.1.0

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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +1459 -0
  6. data/Rakefile +88 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/lib/japanize/base.rb +652 -0
  10. data/lib/japanize/container.rb +213 -0
  11. data/lib/japanize/core.rb +194 -0
  12. data/lib/japanize/enum.rb +127 -0
  13. data/lib/japanize/errors.rb +79 -0
  14. data/lib/japanize/globals.rb +109 -0
  15. data/lib/japanize/io.rb +388 -0
  16. data/lib/japanize/names.rb +213 -0
  17. data/lib/japanize/num.rb +319 -0
  18. data/lib/japanize/process.rb +318 -0
  19. data/lib/japanize/string.rb +257 -0
  20. data/lib/japanize/syntax.rb +805 -0
  21. data/lib/japanize/sys.rb +174 -0
  22. data/lib/japanize/test_unit.rb +99 -0
  23. data/lib/japanize/thread.rb +143 -0
  24. data/lib/japanize/time.rb +82 -0
  25. data/lib/japanize/version.rb +12 -0
  26. data/lib/japanize.rb +24 -0
  27. data/ruby-japanize.gemspec +41 -0
  28. data/sample/README.md +33 -0
  29. data/sample/dir.rb +15 -0
  30. data/sample/eval.rb +48 -0
  31. data/sample/export.rb +44 -0
  32. data/sample/fact.rb +17 -0
  33. data/sample/fib.rb +13 -0
  34. data/sample/freq.rb +17 -0
  35. data/sample/fullpath.rb +29 -0
  36. data/sample/less.rb +19 -0
  37. data/sample/list.rb +86 -0
  38. data/sample/list2.rb +22 -0
  39. data/sample/list3.rb +23 -0
  40. data/sample/mine.rb +204 -0
  41. data/sample/mkproto.rb +33 -0
  42. data/sample/mpart.rb +48 -0
  43. data/sample/occur.rb +17 -0
  44. data/sample/occur2.rb +17 -0
  45. data/sample/philos.rb +57 -0
  46. data/sample/pi.rb +20 -0
  47. data/sample/rcs.dat +17 -0
  48. data/sample/rcs.rb +45 -0
  49. data/sample/sieve.rb +17 -0
  50. data/sample/time.rb +14 -0
  51. data/sample/trojan.rb +18 -0
  52. data/sample/uumerge.rb +47 -0
  53. metadata +164 -0
data/Rakefile ADDED
@@ -0,0 +1,88 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+ require 'rdoc/task'
6
+
7
+ Rake::TestTask.new do |task|
8
+ if ((ENV.key? 'RUBY_DEBUG') && (! ENV['RUBY_DEBUG'].empty?)) then
9
+ task.ruby_opts << '-d'
10
+ end
11
+ end
12
+
13
+ rule '.html' => [ '.md' ] do |t|
14
+ sh "pandoc --from=markdown --to=html5 --standalone --self-contained --css=$HOME/.pandoc/github.css --output=#{t.name} #{t.source}"
15
+ end
16
+
17
+ desc 'Build README.html from markdown source'
18
+ task :readme => %w[ README.html ]
19
+ CLOBBER.include 'README.html'
20
+
21
+ namespace :sample do
22
+ desc 'Build sample/README.html from markdown source'
23
+ task :readme => %w[ sample/README.html ]
24
+ CLOBBER.include 'sample/README.html'
25
+ end
26
+
27
+ namespace :list do
28
+ word_count = lambda{|files, pattern|
29
+ count_table = Hash.new(0)
30
+ for f in files
31
+ IO.foreach(f) do |line|
32
+ code, _comment = line.split('#', 2)
33
+ code.scan(pattern) {|word|
34
+ count_table[word] += 1
35
+ if (ENV.key? 'DEBUG') then
36
+ puts "#{f}: #{word}: #{$`} <<< #{word} >>> #{$'}"
37
+ end
38
+ }
39
+ end
40
+ end
41
+
42
+ count_table
43
+ }
44
+
45
+ desc 'List kanji words'
46
+ task :kanji do
47
+ rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
48
+ word_count[rb_files, /\p{Han}+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
49
+ puts [ c, w ].join("\t")
50
+ end
51
+ end
52
+
53
+ desc 'List hiragana words'
54
+ task :hiragana do
55
+ rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
56
+ word_count[rb_files, /\p{Hiragana}+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
57
+ puts [ c, w ].join("\t")
58
+ end
59
+ end
60
+
61
+ desc 'List katakana words'
62
+ task :katakana do
63
+ rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
64
+ word_count[rb_files, /[\p{Katakana}ー]+/].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
65
+ puts [ c, w ].join("\t")
66
+ end
67
+ end
68
+
69
+ desc 'List japanese words'
70
+ task :japanese do
71
+ rb_files = `git ls-files`.lines.map(&:chomp).grep(/\.rb$/).grep_v(/^test/)
72
+ word_count[rb_files,
73
+ /
74
+ [_A-Za-z]*
75
+ [\p{Han}\p{Hiragana}\p{Katakana}ー]
76
+ [\p{Han}\p{Hiragana}\p{Katakana}ー_A-Za-z0-9]*
77
+ [!?]?
78
+ /x
79
+ ].sort_by{|w, c| [ c, w ] }.reverse_each do |w, c|
80
+ puts [ c, w ].join("\t")
81
+ end
82
+ end
83
+ end
84
+
85
+ # Local Variables:
86
+ # mode: Ruby
87
+ # indent-tabs-mode: nil
88
+ # End:
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruby/japanize"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here