tm_helper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2010 Capital Thought, LLC
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use any part of this software or its source code except
5
+ in compliance with the License. You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ == tm_helper
2
+
3
+ Some useful utilities for Ruby development in TextMate.
4
+
5
+ == Features
6
+
7
+ * Formats +puts+ output when running RSpec specs in TextMate using the RSpec TextMate bundle.
8
+ * Namely, it escapes HTML and converts +\n+ characters to +<br/>+.
9
+ * This is useful when using +puts+ to debug code while running specs in TextMate.
10
+ * Supports forcing of logs to the Textmate window.
11
+ * Defining TM_SHOW_LOGS in your TextMate Preferences->Shell Variables will cause all logs issued using the Logger class be to redirected to the TextMate runner window.
12
+ * This is useful when you want to see your application's logs while running an RSpec spec in TextMate.
13
+
14
+ == Installation
15
+
16
+ Include tm_helper into your Gemfile.
17
+
18
+ gem 'tm_helper'
19
+
20
+ == Usage
21
+
22
+ Simply use +puts+ as you would normally. Output will be automatically formatted when running in an RSpec window.
23
+
24
+ Define TM_SHOW_LOGS in your TextMate Preferences->Shell Variables to cause Logger logs issued by your application be to redirected to the TextMate runner window.
25
+
26
+ === Advanced Usage
27
+
28
+ To test whether your code is running in TextMate, use the +running_in_textmate?+ function:
29
+
30
+ if TmHelper.running_in_textmate?
31
+ puts "I am running in TextMate."
32
+ end
33
+
34
+ To test whether your spec is being executed using the RSpec TextMate bundle, use the +running_rspec_bundle?+ function:
35
+
36
+ if TmHelper.running_rspec_bundle?
37
+ puts "I am running in TextMate with the RSpec TextMate bundle loaded."
38
+ end
39
+
40
+ == NOTES
41
+
42
+ == LICENSE
43
+
44
+ Copyright 2010 Capital Thought, LLC
45
+
46
+ Licensed under the Apache License, Version 2.0 (the "License");
47
+ you may not use any part of this software or its source code except
48
+ in compliance with the License. You may obtain a copy of the License at
49
+
50
+ http://www.apache.org/licenses/LICENSE-2.0
51
+
52
+ Unless required by applicable law or agreed to in writing, software
53
+ distributed under the License is distributed on an "AS IS" BASIS,
54
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
+ See the License for the specific language governing permissions and
56
+ limitations under the License.
57
+
58
+
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ begin
10
+ require 'jeweler'
11
+ Jeweler::Tasks.new do |gem|
12
+ gem.name = "tm_helper"
13
+ gem.summary = %Q{Helper for Ruby development in TextMate.}
14
+ gem.description = %Q{}
15
+ gem.email = "billdoughty@capitalthought.com"
16
+ gem.homepage = "http://github.com/capitalthought/tm_helper"
17
+ gem.authors = ["shock"]
18
+ gem.add_development_dependency "activesupport", ">= 2.3.8"
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake'
26
+ require 'rake/rdoctask'
27
+
28
+ require 'rspec/core/rake_task'
29
+
30
+ RSpec::Core::RakeTask.new( :spec ) do |t|
31
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
32
+ t.rspec_opts = '--format progress'
33
+ # t.rcov = true
34
+ end
35
+
36
+ task :default => :spec
37
+
38
+ Rake::RDocTask.new(:rdoc) do |rdoc|
39
+ rdoc.rdoc_dir = 'rdoc'
40
+ rdoc.title = 'RailsBridge'
41
+ rdoc.options << '--line-numbers' << '--inline-source'
42
+ rdoc.rdoc_files.include('README.rdoc')
43
+ rdoc.rdoc_files.include('lib/**/*.rb')
44
+ end
45
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,50 @@
1
+ require 'cgi'
2
+ require 'logger'
3
+
4
+ module TmHelper
5
+ def self.convert_to_html string
6
+ CGI.escapeHTML(string).gsub("\n", "<br/>")
7
+ end
8
+
9
+ def self.textmate_wrap string
10
+ if self.running_rspec_bundle?
11
+ self.convert_to_html string
12
+ else
13
+ string
14
+ end
15
+ end
16
+
17
+ def self.running_in_textmate?
18
+ ENV["TM_PROJECT_DIRECTORY"] || ENV["TM_FILEPATH"]
19
+ end
20
+
21
+ def self.running_rspec_bundle?
22
+ defined? ::RSpec::Mate || defined? ::SpecMate
23
+ end
24
+ end
25
+
26
+ if TmHelper.running_in_textmate? && TmHelper.running_rspec_bundle?
27
+ module Kernel
28
+ alias :orig_puts :puts
29
+ def puts string
30
+ orig_puts TmHelper.convert_to_html( string ) + "<br/>"
31
+ end
32
+ end
33
+ end
34
+
35
+ if TmHelper.running_in_textmate? && ENV["TM_SHOW_LOGS"]
36
+ require 'active_support/core_ext/logger'
37
+ class Logger
38
+ alias :orig_info :info
39
+ alias :orig_debug :debug
40
+ alias :orig_warn :warn
41
+ alias :orig_error :error
42
+
43
+ def info string; puts TmHelper.textmate_wrap( string ); end
44
+ def debug string; puts TmHelper.textmate_wrap( string ); end
45
+ def warn string; puts TmHelper.textmate_wrap( string ); end
46
+ def error string; puts TmHelper.textmate_wrap( string ); end
47
+
48
+ end
49
+ end
50
+
data/lib/tm_helper.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), 'tm_helper', 'tm_helper')
2
+
data/tm_helper.gemspec ADDED
@@ -0,0 +1,47 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tm_helper}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["shock"]
12
+ s.date = %q{2010-12-31}
13
+ s.description = %q{}
14
+ s.email = %q{billdoughty@capitalthought.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/tm_helper.rb",
25
+ "lib/tm_helper/tm_helper.rb",
26
+ "tm_helper.gemspec"
27
+ ]
28
+ s.homepage = %q{http://github.com/capitalthought/tm_helper}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.7}
32
+ s.summary = %q{Helper for Ruby development in TextMate.}
33
+
34
+ if s.respond_to? :specification_version then
35
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_development_dependency(%q<activesupport>, [">= 2.3.8"])
40
+ else
41
+ s.add_dependency(%q<activesupport>, [">= 2.3.8"])
42
+ end
43
+ else
44
+ s.add_dependency(%q<activesupport>, [">= 2.3.8"])
45
+ end
46
+ end
47
+
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tm_helper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - shock
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-31 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 2
32
+ - 3
33
+ - 8
34
+ version: 2.3.8
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: ""
38
+ email: billdoughty@capitalthought.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.rdoc
46
+ files:
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - lib/tm_helper.rb
52
+ - lib/tm_helper/tm_helper.rb
53
+ - tm_helper.gemspec
54
+ has_rdoc: true
55
+ homepage: http://github.com/capitalthought/tm_helper
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options:
60
+ - --charset=UTF-8
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Helper for Ruby development in TextMate.
88
+ test_files: []
89
+