kizapi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,13 @@
1
+ == 0.2.0 2008-04-10
2
+
3
+ * Keita Yamaguchi
4
+ * Moved to GitHub: http://github.com/keita/ruby-kizapi/tree/master
5
+ * Changed to use Bacon for spec
6
+ * Added KizAPI::VERSION
7
+ * Gemified!
8
+ * Reduced gem included files
9
+
1
10
  == 0.1.0 2007-12-31
2
11
 
3
- * Keita Yamaguchi:
12
+ * Keita Yamaguchi
4
13
  * Initial release
data/License.txt CHANGED
@@ -1,3 +1,3 @@
1
- Copyright (c) 2007 Keita Yamaguchi
1
+ Copyright (c) 2007-2008 Keita Yamaguchi
2
2
 
3
3
  ruby-kizapi is released under the Ruby license.
data/Manifest.txt CHANGED
@@ -3,24 +3,5 @@ License.txt
3
3
  Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
6
  lib/kizapi.rb
9
- lib/kizapi/version.rb
10
- log/debug.log
11
- script/destroy
12
- script/generate
13
- script/txt2html
14
- setup.rb
15
7
  spec/kizapi_spec.rb
16
- spec/spec.opts
17
- spec/spec_helper.rb
18
- tasks/deployment.rake
19
- tasks/environment.rake
20
- tasks/rspec.rake
21
- tasks/website.rake
22
- website/index.html
23
- website/index.txt
24
- website/javascripts/rounded_corners_lite.inc.js
25
- website/stylesheets/screen.css
26
- website/template.rhtml
data/README.txt CHANGED
@@ -1,17 +1,21 @@
1
- = README
1
+ = ruby-kizapi
2
2
 
3
- Authors:: Keita Yamaguchi(山口慶太)
4
- Copyright:: Copyright (C) Keita Yamaguchi, 2007. All rights reserved.
3
+ Author:: Keita Yamaguchi(山口 慶太) <keita.yamaguchi@gmail.com>
4
+ Copyright:: © Keita Yamaguchi, 2007ー2008. All rights reserved.
5
5
  License:: Ruby License
6
6
 
7
- == What
7
+ ruby-kizapi is a wrapper library for {kizAPI}[http://kizasi.jp/tool/kizapi.html] provided by {kizasi.jp}[http://kizasi.jp/].
8
8
 
9
- ruby-kizapi is a wrapper library for kizAPI provided by kizasi.jp.
9
+ == Usage
10
+
11
+ See {the documentation}[http://github.com/keita/ruby-kizapi/wikis].
10
12
 
11
13
  == Links
12
14
 
13
15
  * {kizasi.jp}[http://kizasi.jp/]
14
16
  * {kizAPI}[http://kizasi.jp/tool/kizapi.html]
15
17
  * ruby-kizapi
16
- * {Website}[http://kizapi.rubyforge.org/]
17
- * {Rubyforge Project}[http://rubyforge.org/projects/kizapi/]
18
+ * {Rubyforge}[http://rubyforge.org/projects/kizapi/]
19
+ * {GitHub}[http://github.com/keita/ruby-kizapi/tree/master]
20
+ * author's blog(written in Japanese)
21
+ * {¬¬日常日記}[http://d.hatena.ne.jp/keita_yamaguchi/]
data/Rakefile CHANGED
@@ -1,4 +1,83 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'yaml'
4
+ require 'fileutils'
3
5
 
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
6
+ require File.join(File.dirname(__FILE__), 'lib', 'kizapi')
7
+
8
+ #
9
+ # RubyForge
10
+ #
11
+
12
+ $config =
13
+ YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
14
+
15
+ #
16
+ # Clean
17
+ #
18
+
19
+ require 'rake/clean'
20
+
21
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
22
+
23
+ #
24
+ # RDoc
25
+ #
26
+
27
+ require 'rake/rdoctask'
28
+
29
+ Rake::RDocTask.new do |doc|
30
+ doc.title = "ruby-kizapi-#{KizAPI::VERSION} documentation"
31
+ doc.main = "README.txt"
32
+ doc.rdoc_files.include("{README,History,License}.txt", "lib/**/*.rb")
33
+ doc.options << "--line-numbers" << "--inline-source" << "-c UTF-8"
34
+ end
35
+
36
+ require 'rake/contrib/rubyforgepublisher'
37
+
38
+ desc "Upload API documentation"
39
+ task :publish => [:rdoc] do
40
+ pub = Rake::RubyForgePublisher.new("kizapi", $config["username"])
41
+ pub.upload
42
+ end
43
+
44
+ #
45
+ # Release
46
+ #
47
+
48
+ desc 'Release new gem version'
49
+ task :deploy => [:check_version, :release] do
50
+ puts "Tagging release #{CHANGES}"
51
+ end
52
+
53
+ task :check_version do
54
+ unless ENV['VERSION']
55
+ puts 'Must pass a VERSION=x.y.z release version'
56
+ exit
57
+ end
58
+ unless ENV['VERSION'] == KizAPI::VERSION
59
+ puts "Please update the release version, currently #{VERS}"
60
+ exit
61
+ end
62
+ end
63
+
64
+ #
65
+ # create gem
66
+ #
67
+
68
+ desc "Create the gem package"
69
+ task :gem do
70
+ sh "gemify -I"
71
+ end
72
+
73
+ #
74
+ # bacon
75
+ #
76
+
77
+ desc "Run the specs"
78
+ task :spec do
79
+ sh "bacon spec/*.rb"
80
+ end
81
+
82
+ desc "Default task is to run specs"
83
+ task :default => :spec
data/lib/kizapi.rb CHANGED
@@ -4,15 +4,28 @@ require "rss"
4
4
  require "time"
5
5
 
6
6
  # import Dublin Core into RSS 2.0
7
- module RSS
8
- class Rss
7
+ module RSS #:nodoc:
8
+ class Rss #:nodoc:
9
9
  install_ns(DC_PREFIX, DC_URI)
10
- class Channel; include DublincoreModel; end
11
- class Channel::Item; include DublincoreModel; end
10
+ class Channel #:nodoc:
11
+ include DublincoreModel
12
+ end
13
+ class Channel::Item #:nodoc:
14
+ include DublincoreModel
15
+ end
12
16
  end
13
17
  end
14
18
 
15
19
  module KizAPI
20
+ module Version #:nodoc:
21
+ MAJOR = 0
22
+ MINOR = 2
23
+ TINY = 0
24
+
25
+ STRING = [MAJOR, MINOR, TINY].join('.')
26
+ end
27
+
28
+ VERSION = Version::STRING
16
29
 
17
30
  # RelatedWords is a class for searching related words of a keyword.
18
31
  class RelatedWords < Array
data/spec/kizapi_spec.rb CHANGED
@@ -1,95 +1,92 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ $KCODE = "UTF-8"
2
+ $LOAD_PATH.unshift << File.join(File.dirname(__FILE__), "..", "lib")
3
+ require "kizapi"
4
+ require "rubygems"
5
+ require "bacon"
2
6
 
3
- describe KizAPI::RelatedWords do
4
- before(:all) do
5
- @words = KizAPI::RelatedWords.new("季節")
7
+ describe "KizAPI::RelatedWords" do
8
+ it "should read date" do
9
+ words = KizAPI::RelatedWords.new("季節")
10
+ words.date.should.be.kind_of(Time)
6
11
  end
7
12
 
8
- after(:all) do
9
- @words = nil
10
- end
11
-
12
- it "can read date" do
13
- @words.date.should be_a_kind_of(Time)
14
- end
15
-
16
- it "#day" do
13
+ it "day" do
17
14
  words = KizAPI::RelatedWords.day("季節")
18
- words.should be_a_kind_of(Array)
15
+ words.should.be.kind_of(Array)
19
16
  words.size.should > 0
20
17
  end
21
18
 
22
- it "#week" do
19
+ it "week" do
23
20
  words = KizAPI::RelatedWords.week("季節")
24
- words.should be_a_kind_of(Array)
21
+ words.should.be.kind_of(Array)
25
22
  words.size.should > 0
26
23
  end
27
24
 
28
- it "#month" do
25
+ it "month" do
29
26
  words = KizAPI::RelatedWords.month("季節")
30
- words.should be_a_kind_of(Array)
27
+ words.should.be.kind_of(Array)
31
28
  words.size.should > 0
32
29
  end
33
30
  end
34
31
 
35
- describe KizAPI::KeywordInContexts do
36
- it "fetch sentences" do
32
+ describe "KizAPI::KeywordInContexts" do
33
+ it "should fetch sentences" do
37
34
  contexts = KizAPI::KeywordInContexts.new("季節")
38
- contexts.should be_a_kind_of(Array)
35
+ contexts.should.be.kind_of(Array)
39
36
  contexts.size.should > 0
40
37
  contexts.each do |context|
41
- context.should be_a_kind_of(KizAPI::KeywordInContexts::Context)
38
+ context.should.be.kind_of(KizAPI::KeywordInContexts::Context)
42
39
  context.size.should > 0
43
40
  context.each do |sentence|
44
- sentence.should be_a_kind_of(String)
41
+ sentence.should.be.kind_of(String)
45
42
  end
46
43
  end
47
44
  end
48
45
 
49
46
  it "KWIC is an alias" do
50
- KizAPI::KeywordInContexts.equal?(KizAPI::KWIC)
47
+ KizAPI::KeywordInContexts.should == KizAPI::KWIC
51
48
  end
52
49
  end
53
50
 
54
- describe KizAPI::Ranking do
55
- it "can fetch keywords" do
51
+ describe "KizAPI::Ranking" do
52
+ it "should fetch keywords" do
56
53
  ranking = KizAPI::Ranking.new
57
- ranking.should be_a_kind_of(Array)
54
+ ranking.should.be.kind_of(Array)
58
55
  ranking.size.should == 30
59
56
  ranking.each do |keyword|
60
- keyword.should be_a_kind_of(KizAPI::Ranking::Keyword)
61
- keyword.link.should be_a_kind_of(URI)
57
+ keyword.should.be.kind_of(KizAPI::Ranking::Keyword)
58
+ keyword.link.should.be.kind_of(URI)
62
59
  end
63
60
  end
64
61
  end
65
62
 
66
- describe KizAPI::ChannelWords do
67
- it "can fetch channel words" do
63
+ describe "KizAPI::ChannelWords" do
64
+ it "should fetch channel words" do
68
65
  words = KizAPI::ChannelWords.new("季節")
69
- words.date.should be_a_kind_of(Time)
70
- words.should be_a_kind_of(Array)
66
+ words.date.should.be.kind_of(Time)
67
+ words.should.be.kind_of(Array)
71
68
  words.size.should > 0
72
69
  words.each do |word|
73
- word.should be_a_kind_of(KizAPI::ChannelWords::Word)
74
- word.should respond_to(:subject)
70
+ word.should.be.kind_of(KizAPI::ChannelWords::Word)
71
+ word.should.respond_to(:subject)
75
72
  end
76
73
  end
77
74
 
78
- it "#day" do
75
+ it "day" do
79
76
  words = KizAPI::ChannelWords.day("季節")
80
- words.should be_a_kind_of(Array)
77
+ words.should.be.kind_of(Array)
81
78
  words.size.should > 0
82
79
  end
83
80
 
84
- it "#week" do
81
+ it "week" do
85
82
  words = KizAPI::ChannelWords.week("季節")
86
- words.should be_a_kind_of(Array)
83
+ words.should.be.kind_of(Array)
87
84
  words.size.should > 0
88
85
  end
89
86
 
90
- it "#month" do
87
+ it "month" do
91
88
  words = KizAPI::ChannelWords.month("季節")
92
- words.should be_a_kind_of(Array)
89
+ words.should.be.kind_of(Array)
93
90
  words.size.should > 0
94
91
  end
95
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kizapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Yamaguchi
@@ -9,55 +9,31 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-31 00:00:00 +09:00
12
+ date: 2008-04-10 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: description of gem
16
+ description:
17
17
  email: keita.yamaguchi@gmail.com
18
18
  executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files:
23
- - History.txt
24
- - License.txt
25
- - Manifest.txt
26
- - README.txt
27
- - website/index.txt
22
+ extra_rdoc_files: []
23
+
28
24
  files:
29
25
  - History.txt
30
26
  - License.txt
31
27
  - Manifest.txt
32
28
  - README.txt
33
29
  - Rakefile
34
- - config/hoe.rb
35
- - config/requirements.rb
36
30
  - lib/kizapi.rb
37
- - lib/kizapi/version.rb
38
- - log/debug.log
39
- - script/destroy
40
- - script/generate
41
- - script/txt2html
42
- - setup.rb
43
31
  - spec/kizapi_spec.rb
44
- - spec/spec.opts
45
- - spec/spec_helper.rb
46
- - tasks/deployment.rake
47
- - tasks/environment.rake
48
- - tasks/rspec.rake
49
- - tasks/website.rake
50
- - website/index.html
51
- - website/index.txt
52
- - website/javascripts/rounded_corners_lite.inc.js
53
- - website/stylesheets/screen.css
54
- - website/template.rhtml
55
32
  has_rdoc: true
56
- homepage: http://kizapi.rubyforge.org
33
+ homepage: http://rubyforge.org/projects/kizapi/
57
34
  post_install_message:
58
- rdoc_options:
59
- - --main
60
- - README.txt
35
+ rdoc_options: []
36
+
61
37
  require_paths:
62
38
  - lib
63
39
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -75,9 +51,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
51
  requirements: []
76
52
 
77
53
  rubyforge_project: kizapi
78
- rubygems_version: 1.0.1
54
+ rubygems_version: 1.1.0
79
55
  signing_key:
80
56
  specification_version: 2
81
- summary: description of gem
57
+ summary: ruby-kizapi is a wrapper library for kizAPI provided by kizasi.jp.
82
58
  test_files: []
83
59
 
data/config/hoe.rb DELETED
@@ -1,78 +0,0 @@
1
- require 'kizapi/version'
2
-
3
- AUTHOR = 'Keita Yamaguchi' # can also be an array of Authors
4
- EMAIL = "keita.yamaguchi@gmail.com"
5
- DESCRIPTION = "description of gem"
6
- GEM_NAME = 'kizapi' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'kizapi' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- RUBYFORGE_USERNAME = "unknown"
14
- def rubyforge_username
15
- unless @config
16
- begin
17
- @config = YAML.load(File.read(File.expand_path(@config_file)))
18
- rescue
19
- puts <<-EOS
20
- ERROR: No rubyforge config file found: #{@config_file}
21
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
- - See http://newgem.rubyforge.org/rubyforge.html for more details
23
- EOS
24
- exit
25
- end
26
- end
27
- RUBYFORGE_USERNAME.replace @config["username"]
28
- end
29
-
30
-
31
- REV = nil
32
- # UNCOMMENT IF REQUIRED:
33
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
- VERS = KizAPI::VERSION::STRING + (REV ? ".#{REV}" : "")
35
-
36
- class Hoe
37
- def extra_deps
38
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
39
- @extra_deps
40
- end
41
- end
42
-
43
- # Generate all the Rake tasks
44
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
45
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
46
- p.author = AUTHOR
47
- p.description = DESCRIPTION
48
- p.email = EMAIL
49
- p.summary = DESCRIPTION
50
- p.url = HOMEPATH
51
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
52
- p.test_globs = ["test/**/test_*.rb"]
53
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
54
-
55
- # == Optional
56
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
57
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
58
-
59
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
60
-
61
- end
62
-
63
- Rake::RDocTask.new(:docs) do |rd|
64
- rd.main = "README.txt"
65
- rd.rdoc_dir = "doc"
66
- Dir.glob("lib/**/*.rb") do |path| rd.rdoc_files << path end
67
- rd.rdoc_files += ["README.txt", "History.txt", "License.txt"]
68
- rd.title = GEM_NAME + " " + VERS + " documentation"
69
- rd.options += ["--opname", "index.html",
70
- "--line-numbers",
71
- "--inline-source",
72
- "--charset", "UTF-8"]
73
- end
74
-
75
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
76
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
77
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
78
- hoe.rsync_args = '-av --delete --ignore-errors'
@@ -1,17 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
6
- begin
7
- require req_gem
8
- rescue LoadError
9
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
- puts "Installation: gem install #{req_gem} -y"
11
- exit
12
- end
13
- end
14
-
15
- $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
-
17
- require 'kizapi'
@@ -1,9 +0,0 @@
1
- module KizAPI #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 0
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
data/log/debug.log DELETED
File without changes
data/script/destroy DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html DELETED
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- begin
5
- require 'newgem'
6
- rescue LoadError
7
- puts "\n\nGenerating the website requires the newgem RubyGem"
8
- puts "Install: gem install newgem\n\n"
9
- exit(1)
10
- end
11
- require 'redcloth'
12
- require 'syntax/convertors/html'
13
- require 'erb'
14
- require File.dirname(__FILE__) + '/../lib/kizapi/version.rb'
15
-
16
- version = KizAPI::VERSION::STRING
17
- download = 'http://rubyforge.org/projects/kizapi'
18
-
19
- class Fixnum
20
- def ordinal
21
- # teens
22
- return 'th' if (10..19).include?(self % 100)
23
- # others
24
- case self % 10
25
- when 1: return 'st'
26
- when 2: return 'nd'
27
- when 3: return 'rd'
28
- else return 'th'
29
- end
30
- end
31
- end
32
-
33
- class Time
34
- def pretty
35
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
- end
37
- end
38
-
39
- def convert_syntax(syntax, source)
40
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
- end
42
-
43
- if ARGV.length >= 1
44
- src, template = ARGV
45
- template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
-
47
- else
48
- puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
- exit!
50
- end
51
-
52
- template = ERB.new(File.open(template).read)
53
-
54
- title = nil
55
- body = nil
56
- File.open(src) do |fsrc|
57
- title_text = fsrc.readline
58
- body_text = fsrc.read
59
- syntax_items = []
60
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
- ident = syntax_items.length
62
- element, syntax, source = $1, $2, $3
63
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
- "syntax-temp-#{ident}"
65
- }
66
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
- body = RedCloth.new(body_text).to_html
68
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
- end
70
- stat = File.stat(src)
71
- created = stat.ctime
72
- modified = stat.mtime
73
-
74
- $stdout << template.result(binding)