marked 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :test do
4
+ gem 'rake'
5
+ gem 'jeweler'
4
6
  gem 'test-unit'
5
7
  gem 'shoulda'
6
8
  gem 'mocha'
data/README.markdown CHANGED
@@ -1,7 +1,16 @@
1
1
  Marked
2
2
  =
3
3
 
4
- [http://github.com/JackDanger/marked](http://github.com/JackDanger/marked)
4
+ <pre>
5
+ "You stroll with this intelligence
6
+ in and out of fields of knowledge, getting always
7
+ more marks on your preserving tablets.
8
+ There is another kind of tablet, one
9
+ already completed and preserved inside you.
10
+ This second knowing is a fountainhead
11
+ from within you, moving out"
12
+ -- Rumi
13
+ </pre>
5
14
 
6
15
  DESCRIPTION
7
16
  ==
@@ -58,4 +67,4 @@ INSTALL
58
67
  * gem install marked
59
68
 
60
69
 
61
- Copyright 2011 Jack Danger Canty. Patches welcome, forks celebrated
70
+ Copyright 2011 [Jack Danger Canty](http://jackcanty.com). Patches welcome, forks celebrated
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/lib/marked.rb CHANGED
@@ -3,34 +3,33 @@ module Marked
3
3
 
4
4
  returnable = block_given? ? yield : objects.last
5
5
 
6
- Marked.log "<MARK>"
6
+ Marked.log "MARKED #{caller.first.split(':in ').first}"
7
7
 
8
8
  if block_given?
9
- Marked.print returnable
10
- Marked.log returnable
9
+ Marked.log Marked.pad returnable
11
10
  end
12
11
 
13
12
  objects.each do |object|
14
- Marked.print object
15
- Marked.log object
13
+ Marked.log Marked.pad object
16
14
  end
17
15
 
18
- Marked.log "</MARK>"
19
-
20
16
  returnable
21
17
  end
22
18
 
23
19
  def self.log object
24
- if defined?(Rails)
25
- Rails.logger.debug object.is_a?(String) ? object : object.inspect
26
- end
20
+ Rails.logger.debug object if defined?(Rails)
21
+ print object
27
22
  end
28
23
 
29
24
  def self.print object
30
- STDOUT.puts object.is_a?(String) ? object : object.inspect
25
+ STDOUT.puts object
26
+ end
27
+
28
+ def self.pad object
29
+ " " + (object.is_a?(String) ? object : object.inspect)
31
30
  end
32
31
  end
33
32
 
34
33
  class Object
35
34
  include Marked
36
- end
35
+ end
data/marked.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{marked}
8
+ s.version = "1.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jack Danger Canty"]
12
+ s.date = %q{2011-09-09}
13
+ s.description = %q{Quick Ruby debugger. Easily print any object or string to the console and to your logs while you're working.}
14
+ s.email = %q{rubygems@6brand.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "LICENSE",
22
+ "README.markdown",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/marked.rb",
26
+ "marked.gemspec",
27
+ "test/marked_test.rb",
28
+ "test/test_helper.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/JackDanger/marked}
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.6.2}
33
+ s.summary = %q{Fast debugging for Ruby. Output any objects or blocks to both Rails log and console output simultaneously}
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ else
40
+ end
41
+ else
42
+ end
43
+ end
44
+
data/test/marked_test.rb CHANGED
@@ -1,12 +1,31 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  class MarkedTest < Test::Unit::TestCase
4
+
5
+ def expect_log string
6
+ Marked.expects(:log).with Marked.pad string
7
+ end
8
+
9
+ def expect_unpadded_log string
10
+ Marked.expects(:log).with string
11
+ end
12
+
13
+
14
+ context "logging" do
15
+ setup {
16
+ Rails.logger.expects(:debug).with("MARKED ./test/marked_test.rb:22")
17
+ Marked.expects(:print).with( "MARKED ./test/marked_test.rb:22")
18
+ Rails.logger.expects(:debug).with(" this should be printed")
19
+ Marked.expects(:print).with( " this should be printed")
20
+ }
21
+ should "goes to two outputs" do
22
+ mark "this should be printed"
23
+ end
24
+ end
4
25
  context "printing and logging a single argument" do
5
26
  setup {
6
- Rails.logger.expects(:debug).with("<MARK>")
7
- Rails.logger.expects(:debug).with("this should be printed")
8
- Rails.logger.expects(:debug).with("</MARK>")
9
- Marked.expects(:print).with("this should be printed")
27
+ expect_unpadded_log "MARKED ./test/marked_test.rb:31"
28
+ expect_log "this should be printed"
10
29
  }
11
30
  should "return its argument" do
12
31
  assert_equal "this should be printed", mark("this should be printed")
@@ -14,12 +33,9 @@ class MarkedTest < Test::Unit::TestCase
14
33
  end
15
34
  context "printing and logging multiple arguments" do
16
35
  setup {
17
- Rails.logger.expects(:debug).with("<MARK>")
18
- Rails.logger.expects(:debug).with("this should be printed")
19
- Rails.logger.expects(:debug).with("this too")
20
- Rails.logger.expects(:debug).with("</MARK>")
21
- Marked.expects(:print).with("this should be printed")
22
- Marked.expects(:print).with("this too")
36
+ expect_unpadded_log "MARKED ./test/marked_test.rb:41"
37
+ expect_log "this should be printed"
38
+ expect_log "this too"
23
39
  }
24
40
  should "return its last argument" do
25
41
  assert_equal "this too", mark("this should be printed", "this too")
@@ -27,12 +43,9 @@ class MarkedTest < Test::Unit::TestCase
27
43
  end
28
44
  context "printing and logging non-strings" do
29
45
  setup {
30
- Marked.expects(:log).with("<MARK>")
31
- Marked.expects(:log).with({:a =>'a'})
32
- Marked.expects(:log).with([1, 2, 3])
33
- Marked.expects(:log).with("</MARK>")
34
- Marked.expects(:print).with({:a => 'a'})
35
- Marked.expects(:print).with([1, 2, 3])
46
+ expect_unpadded_log "MARKED ./test/marked_test.rb:51"
47
+ expect_log({:a =>'a'})
48
+ expect_log [1, 2, 3]
36
49
  }
37
50
  should "return its last argument as object" do
38
51
  assert_equal [1,2,3], mark({:a => 'a'}, [1,2,3])
@@ -42,15 +55,18 @@ class MarkedTest < Test::Unit::TestCase
42
55
  setup {
43
56
  @obj = {}
44
57
  @obj.expects(:called!).returns('returned!').once
45
- Rails.logger.expects(:debug).with("<MARK>")
46
- Rails.logger.expects(:debug).with("first arg")
47
- Rails.logger.expects(:debug).with("returned!")
48
- Rails.logger.expects(:debug).with("</MARK>")
49
- Marked.expects(:print).with("first arg")
50
- Marked.expects(:print).with("returned!")
58
+ expect_unpadded_log "MARKED ./test/marked_test.rb:63"
59
+ expect_log "first arg"
60
+ expect_log "returned!"
51
61
  }
52
62
  should "return its last argument as object" do
53
63
  assert_equal 'returned!', mark('first arg') { @obj.called! }
54
64
  end
55
65
  end
66
+ context "#pad" do
67
+ should "prepend 7 spaces" do
68
+ assert_equal (" "*7)+'padme',
69
+ Marked.pad('padme')
70
+ end
71
+ end
56
72
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marked
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease:
5
- version: 1.0.0
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Jack Danger Canty
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-06-07 00:00:00 -07:00
18
+ date: 2011-09-09 00:00:00 -07:00
14
19
  default_executable:
15
20
  dependencies: []
16
21
 
@@ -30,6 +35,7 @@ files:
30
35
  - Rakefile
31
36
  - VERSION
32
37
  - lib/marked.rb
38
+ - marked.gemspec
33
39
  - test/marked_test.rb
34
40
  - test/test_helper.rb
35
41
  has_rdoc: true
@@ -46,12 +52,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
52
  requirements:
47
53
  - - ">="
48
54
  - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
49
58
  version: "0"
50
59
  required_rubygems_version: !ruby/object:Gem::Requirement
51
60
  none: false
52
61
  requirements:
53
62
  - - ">="
54
63
  - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
55
67
  version: "0"
56
68
  requirements: []
57
69