source_position 0.0.3 → 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.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rbenv-version
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ script: 'bundle exec rspec spec'
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.3
6
+ - ree
7
+ - rbx-18mode
8
+ - rbx-19mode
data/README.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  Editor friendly source location
4
4
 
5
- ## Installation
5
+ [![Build Status](https://secure.travis-ci.org/linjunpop/source_position.png?branch=master)](http://travis-ci.org/linjunpop/source_position)
6
+ [![Dependency Status](https://gemnasium.com/linjunpop/source_position.png)](https://gemnasium.com/linjunpop/source_position)
7
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/linjunpop/source_position)
8
+
9
+ Tested on 1.8.7, 1.9.3, ree, rbx-18mode, rbx-19mode
6
10
 
7
- Ruby 1.8 user, please Install [ruby18_source_location] first.
11
+ ## Installation
8
12
 
9
13
  Add this line to your application's Gemfile:
10
14
 
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -1,4 +1,11 @@
1
+ if RUBY_VERSION < '1.9'
2
+ unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
3
+ require 'ruby18_source_location'
4
+ end
5
+ end
6
+
1
7
  require "source_position/version"
8
+ require "source_position/rbx_source_location"
2
9
 
3
10
  module SourcePosition
4
11
  def source_position
@@ -15,5 +22,6 @@ class UnboundMethod
15
22
  end
16
23
 
17
24
  class Proc
25
+ include SourcePosition::RbxSourceLocation
18
26
  include SourcePosition
19
27
  end
@@ -0,0 +1,7 @@
1
+ module SourcePosition
2
+ module RbxSourceLocation
3
+ def source_location
4
+ [block.file.to_s, block.line]
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SourcePosition
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -15,5 +15,11 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SourcePosition::VERSION
17
17
 
18
+ if RUBY_VERSION < '1.9'
19
+ unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
20
+ gem.add_dependency 'ruby18_source_location', '~> 0.2'
21
+ end
22
+ end
23
+
18
24
  gem.add_development_dependency 'rspec'
19
25
  end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'source_position'
3
2
 
4
3
  class Dummy
5
4
  def self.foobar
@@ -14,26 +13,30 @@ end
14
13
  describe SourcePosition do
15
14
  subject { Dummy.method(:foobar) }
16
15
 
17
- its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:5"}
16
+ its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:4"}
18
17
 
19
18
  context 'source_location returns nil value' do
20
19
  subject { Object.method(:to_s) }
20
+
21
+ before do
22
+ subject.should_receive(:source_location) { nil }
23
+ end
24
+
21
25
  its(:source_position) { should eq nil }
22
26
  end
23
27
 
24
28
  describe 'Method' do
25
29
  subject { Dummy.method(:foobar) }
26
- its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:5"}
30
+ its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:4"}
27
31
  end
28
32
 
29
33
  describe 'UnboundMethod' do
30
34
  subject { Dummy.instance_method(:test) }
31
- its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:9"}
35
+ its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:8"}
32
36
  end
33
37
 
34
38
  describe 'Proc' do
35
39
  subject { Proc.new{} }
36
- its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:35"}
40
+ its(:source_position) { should eq "#{Dir.pwd}/spec/source_position_spec.rb:39"}
37
41
  end
38
42
  end
39
-
@@ -1,3 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'source_position'
5
+
1
6
  # This file was generated by the `rspec --init` command. Conventionally, all
2
7
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
8
  # Require this file using `require "spec_helper"` to ensure that it is only
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: source_position
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -36,11 +36,13 @@ extra_rdoc_files: []
36
36
  files:
37
37
  - .gitignore
38
38
  - .rspec
39
+ - .travis.yml
39
40
  - Gemfile
40
41
  - LICENSE
41
42
  - README.md
42
43
  - Rakefile
43
44
  - lib/source_position.rb
45
+ - lib/source_position/rbx_source_location.rb
44
46
  - lib/source_position/version.rb
45
47
  - source_position.gemspec
46
48
  - spec/source_position_spec.rb