ruremai 0.0.3 → 0.0.4

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e1d258ec1612988eb818caa44674bb6d4f21b9a
4
+ data.tar.gz: c2e11f00f01b18671a493d163d5d36a22b22a209
5
+ SHA512:
6
+ metadata.gz: 6c5011a422aeb7cf14294b9aa5a91e24aae5f76a4e0e8a1dca6ba06fc557775aa0b032d85f6629cd8f9d41725e77ed4b60737234984526dfb8aec1345cfb4278
7
+ data.tar.gz: bb3272c536450a43b2838af7264c6f304fc7d9d9c7e67bd7f662c325d06a28140365b706165f7665475dc876ae6c8fe9dede01ac558f58086674796491b1d827
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - '1.9.3'
3
+ - '2.0.0'
4
+ - '2.1'
5
+ - '2.2'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruremai
1
+ # Ruremai [![Build Status](https://travis-ci.org/hibariya/ruremai.png?branch=master)](https://travis-ci.org/hibariya/ruremai)
2
2
 
3
3
  Open ruby reference manual by browser as following.
4
4
 
@@ -1,6 +1,3 @@
1
- require 'uri'
2
- require 'cgi'
3
- require 'net/http'
4
1
  require 'launchy'
5
2
  require 'ruremai/version'
6
3
  require 'ruremai/ext/method'
@@ -13,6 +10,8 @@ module Ruremai
13
10
  class NoReferenceManualFound < StandardError; end
14
11
 
15
12
  class << self
13
+ attr_writer :locators
14
+
16
15
  def launch(method)
17
16
  if uri = locate(method)
18
17
  Launchy.open uri.to_s
@@ -32,11 +31,7 @@ module Ruremai
32
31
  end
33
32
 
34
33
  def locators
35
- @locators ||= [Locator::Rurema::Ja]
36
- end
37
-
38
- def locators=(list)
39
- @locators = list
34
+ @locators ||= [Locator::Rurema]
40
35
  end
41
36
  end
42
37
  end
@@ -1,3 +1,6 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
1
4
  module Ruremai
2
5
  module Locator
3
6
  autoload :Rurema, 'ruremai/locator/rurema'
@@ -1,27 +1,31 @@
1
+ require 'cgi'
2
+
1
3
  module Ruremai
2
4
  module Locator
3
5
  class Rurema < Base
4
- class Ja < Rurema
5
- def uri_base
6
- 'http://doc.ruby-lang.org/ja/'
7
- end
6
+ URI_BASE = 'http://doc.ruby-lang.org/ja/'
7
+ major, minor, teeny = *RUBY_VERSION.split(".").map(&:to_i)
8
+ PATH_VERSION_PART = [major, minor, major >= 2 ? 0 : teeny].join(".")
9
+
10
+ def candidates
11
+ uri_part = [PATH_VERSION_PART, 'method', escape(method_owner)].join('/')
12
+ method_name = escape(name.to_s)
8
13
 
9
- def candidates
10
- uri_part = [RUBY_VERSION, 'method', escape(method_owner)].join('/')
11
- method_name = escape(name.to_s)
12
- types =
13
- if receiver.is_a?(Module)
14
- %w(s m i)
15
- else
16
- %w(i m s)
17
- end
14
+ # s: singleton mehtod, m: module function, i: instance method
15
+ ordered_types =
16
+ if receiver.is_a?(Module)
17
+ %w(s m i)
18
+ else
19
+ %w(i m s)
20
+ end
18
21
 
19
- types.map {|type|
20
- URI.parse("#{uri_base}#{uri_part}/#{type}/#{method_name}.html")
21
- }
22
- end
22
+ ordered_types.map {|type|
23
+ URI.parse("#{URI_BASE}#{uri_part}/#{type}/#{method_name}.html")
24
+ }
23
25
  end
24
26
 
27
+ private
28
+
25
29
  def escape(str)
26
30
  CGI.escape(str).gsub(/(%[\dA-Z]{2})/) {|s|
27
31
  %(=#{s[1..-1].downcase})
@@ -1,3 +1,3 @@
1
1
  module Ruremai
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -15,8 +15,9 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Ruremai::VERSION
17
17
 
18
- gem.add_runtime_dependency 'launchy', '~> 2.1.0'
18
+ gem.add_runtime_dependency 'launchy', '~> 2.4.3'
19
19
 
20
- gem.add_development_dependency 'tapp', '~> 1.3.1'
21
- gem.add_development_dependency 'rspec', '>= 2.10.0'
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'tapp', '~> 1.5.0'
22
+ gem.add_development_dependency 'rspec', '~> 3.2.0'
22
23
  end
@@ -1,33 +1,52 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Ruremai::Locator::Rurema::Ja do
3
+ describe Ruremai::Locator::Rurema do
4
4
  describe '#candidates' do
5
- let(:locator) { Ruremai::Locator::Rurema::Ja.new(target) }
5
+ PATH_VERSION_PART = (/\A1\./ =~ RUBY_VERSION ? RUBY_VERSION : RUBY_VERSION[/\A\d+\.\d+/] + ".0").freeze
6
+ let(:locator) { Ruremai::Locator::Rurema.new(target) }
6
7
 
7
8
  subject { locator.candidates.map(&:to_s) }
8
9
 
9
- context 'CamelCase method' do
10
+ describe 'CamelCase method' do
10
11
  let(:target) { method(:Integer) }
11
12
 
12
- it { should include %(http://doc.ruby-lang.org/ja/1.9.3/method/Kernel/m/Integer.html) }
13
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Kernel/m/Integer.html) }
13
14
  end
14
15
 
15
- context 'query method' do
16
+ describe 'query method' do
16
17
  let(:target) { nil.method(:nil?) }
17
18
 
18
- it { should include %(http://doc.ruby-lang.org/ja/#{RUBY_VERSION}/method/NilClass/i/nil=3f.html) }
19
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/NilClass/i/nil=3f.html) }
19
20
  end
20
21
 
21
- context 'space ship operator' do
22
+ describe 'space ship operator' do
22
23
  let(:target) { 0.method(:<=>) }
23
24
 
24
- it { should include %(http://doc.ruby-lang.org/ja/#{RUBY_VERSION}/method/Fixnum/i/=3c=3d=3e.html) }
25
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Fixnum/i/=3c=3d=3e.html) }
25
26
  end
26
27
 
27
- context 'nested class' do
28
+ describe 'nested class' do
28
29
  let(:target) { Net::HTTP.method(:new) }
29
30
 
30
- it { should include 'http://doc.ruby-lang.org/ja/1.9.3/method/Net=3a=3aHTTP/s/new.html' }
31
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Net=3a=3aHTTP/s/new.html) }
32
+ end
33
+
34
+ describe '`' do
35
+ let(:target) { Kernel.method(:`) }
36
+
37
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Kernel/m/=60.html) }
38
+ end
39
+
40
+ describe 'infix operator method' do
41
+ let(:target) { 1.method(:+) }
42
+
43
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Fixnum/i/=2b.html) }
44
+ end
45
+
46
+ describe 'prefix operator method' do
47
+ let(:target) { 1.method(:+@) }
48
+
49
+ it { should include %(http://doc.ruby-lang.org/ja/#{PATH_VERSION_PART}/method/Numeric/i/=2b=40.html) }
31
50
  end
32
51
  end
33
52
  end
metadata CHANGED
@@ -1,64 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruremai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - hibariya
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: launchy
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 2.1.0
19
+ version: 2.4.3
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 2.1.0
26
+ version: 2.4.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: tapp
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ~>
45
+ - - "~>"
36
46
  - !ruby/object:Gem::Version
37
- version: 1.3.1
47
+ version: 1.5.0
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ~>
52
+ - - "~>"
44
53
  - !ruby/object:Gem::Version
45
- version: 1.3.1
54
+ version: 1.5.0
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rspec
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - "~>"
52
60
  - !ruby/object:Gem::Version
53
- version: 2.10.0
61
+ version: 3.2.0
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: 2.10.0
68
+ version: 3.2.0
62
69
  description: Object.method(:name).rurema!
63
70
  email:
64
71
  - celluloid.key@gmail.com
@@ -66,7 +73,8 @@ executables: []
66
73
  extensions: []
67
74
  extra_rdoc_files: []
68
75
  files:
69
- - .gitignore
76
+ - ".gitignore"
77
+ - ".travis.yml"
70
78
  - Gemfile
71
79
  - LICENSE
72
80
  - README.md
@@ -83,27 +91,26 @@ files:
83
91
  - spec/spec_helper.rb
84
92
  homepage: https://github.com/hibariya/ruremai
85
93
  licenses: []
94
+ metadata: {}
86
95
  post_install_message:
87
96
  rdoc_options: []
88
97
  require_paths:
89
98
  - lib
90
99
  required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
100
  requirements:
93
- - - ! '>='
101
+ - - ">="
94
102
  - !ruby/object:Gem::Version
95
103
  version: '0'
96
104
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
105
  requirements:
99
- - - ! '>='
106
+ - - ">="
100
107
  - !ruby/object:Gem::Version
101
108
  version: '0'
102
109
  requirements: []
103
110
  rubyforge_project:
104
- rubygems_version: 1.8.23
111
+ rubygems_version: 2.4.5
105
112
  signing_key:
106
- specification_version: 3
113
+ specification_version: 4
107
114
  summary: Open ruby reference manual by browser.
108
115
  test_files:
109
116
  - spec/locator/rurema_spec.rb