docstrings 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - jruby-19mode
5
+ - rbx-19mode
6
+ - 2.0.0
7
+ - ree
8
+ - 1.8.7
9
+ - jruby-18mode
10
+ - rbx-18mode
data/README.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  DocStrings allows you to define and access Python-like docstrings in Ruby.
4
4
 
5
+ [![Build Status](https://travis-ci.org/chendo/docstrings.png)](https://travis-ci.org/chendo/docstrings)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'docstrings'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install docstrings
20
+
5
21
  ## Usage
6
22
 
7
23
  ```ruby
@@ -35,7 +51,7 @@ So `"""Foo"""` simply evaluates to `"Foo"`, and all this gem does is define a me
35
51
 
36
52
  ## Wouldn't this cause a performance hit every time the method is called?
37
53
 
38
- Nope! At least, not in CRuby. Ruby is smart enough to recognise when string literals aren't actually used, and will skip generating bytecode for it.
54
+ Nope! At least, not in CRuby. Ruby is smart enough to recognise when string literals aren't actually used, and will skip generating bytecode for it. Thanks to @charliesome for pointing this out.
39
55
 
40
56
  ```ruby
41
57
  def no_docstring
@@ -67,20 +83,11 @@ puts RubyVM::InstructionSequence.of(method(:with_docstring)).disasm
67
83
 
68
84
  See https://eval.in/36676
69
85
 
70
- ## Installation
71
-
72
- Add this line to your application's Gemfile:
73
-
74
- gem 'docstrings'
75
-
76
- And then execute:
77
-
78
- $ bundle
79
-
80
- Or install it yourself as:
81
-
82
- $ gem install docstrings
86
+ ## Compatibility
83
87
 
88
+ * Ruby 1.9.x, 2.x
89
+ * JRuby 1.9 mode
90
+ * Rubinus 1.9 mode
84
91
 
85
92
  ## Contributing
86
93
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "method_source", "~> 0.8"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  require "docstrings/version"
4
+ require "method_source"
4
5
  require "docstrings/extensions/base"
5
6
 
6
7
  module DocStrings
@@ -3,13 +3,8 @@ module DocStrings
3
3
  module Base
4
4
  module MethodExtension
5
5
  def docstring
6
- path, line_number = source_location
7
-
8
- if path && File.exists?(path)
9
- file = File.read(path)
10
-
11
- # FIXME: This will work terribly for large files
12
- if file =~ Regexp.new(%Q{\\A(?:.*?\n){#{line_number}}\s*?"""([\\s\\S]+?)"""})
6
+ if respond_to?(:source)
7
+ if source =~ Regexp.new(%Q{"""([\\s\\S]+?)"""})
13
8
  $1.gsub(/\n\s+/, "\n").strip
14
9
  end
15
10
  end
@@ -1,3 +1,3 @@
1
1
  module DocStrings
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docstrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,6 +11,22 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: method_source
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: bundler
16
32
  requirement: !ruby/object:Gem::Requirement