daberu 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Daberu
1
+ # Daberu - Create a talkative object. [![Build Status](https://secure.travis-ci.org/myokoym/daberu.png?branch=master)](http://travis-ci.org/myokoym/daberu)
2
2
 
3
3
  おしゃべりなオブジェクトをつくることができます。
4
4
  [You can create a talkative object.]
@@ -27,7 +27,7 @@ Or install it yourself as:
27
27
 
28
28
  require 'daberu'
29
29
 
30
- a = Daberu.new([])
30
+ a = Daberu::Talker.new([])
31
31
  a << 1 #=> "Class: Array, Method: <<, Arguments: [1], Block: "
32
32
  a << 2 #=> "Class: Array, Method: <<, Arguments: [2], Block: "
33
33
  a << 3 #=> "Class: Array, Method: <<, Arguments: [3], Block: "
@@ -39,9 +39,10 @@ Or install it yourself as:
39
39
  2
40
40
  3
41
41
 
42
- p Daberu.format_get(a) #=> "Class: %s, Method: %s, Arguments: [%s], Block: %s"
43
- Daberu.format_set(a, "%s#%s(%s)")
44
- p Daberu.format_get(a) #=> "%s#%s(%s)"
42
+ include Daberu # With liking
43
+ p Talker.format_get(a) #=> "Class: %s, Method: %s, Arguments: [%s], Block: %s"
44
+ Talker.format_set(a, "%s#%s(%s)")
45
+ p Talker.format_get(a) #=> "%s#%s(%s)"
45
46
  a << 4 #=> "Array#<<(4)"
46
47
 
47
48
  ### Ruby version
data/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require "bundler"
3
+
4
+ task :default => [:spec]
5
+ begin
6
+ Bundler::GemHelper.install_tasks
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = 'spec/**/*_spec.rb'
10
+ spec.rspec_opts = ['-cfs']
11
+ end
12
+ rescue LoadError => e
13
+ end
data/daberu.gemspec CHANGED
@@ -14,4 +14,8 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "daberu"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Daberu::VERSION
17
+
18
+ gem.add_development_dependency 'rake', ['>= 0.9.2']
19
+ gem.add_development_dependency 'rspec', ['>= 2.10.0']
20
+ gem.add_development_dependency 'rdoc', ['>= 3.12']
17
21
  end
data/lib/daberu.rb CHANGED
@@ -1,34 +1 @@
1
- # encoding: utf-8
2
-
3
- class Daberu
4
- instance_methods.each do |m|
5
- undef_method m unless m.to_s =~ /^__|method_missing|respond_to?|object_id/
6
- end
7
-
8
- def initialize(obj = Object.new)
9
- @obj = obj
10
- @format = "Class: %s, Method: %s, Arguments: [%s], Block: %s"
11
- end
12
-
13
- def method_missing(name, *args, &block)
14
- p @format % [@obj.class, name, args.to_s.gsub(/^\[|\]$/, ""), block]
15
- @obj.send(name, *args, &block)
16
- end
17
-
18
- def self.format_get(obj)
19
- obj.__daberu_format_get__
20
- end
21
-
22
- def self.format_set(obj, str)
23
- obj.__daberu_format_set__(str)
24
- end
25
-
26
- def __daberu_format_get__
27
- @format
28
- end
29
-
30
- def __daberu_format_set__(str)
31
- @format = str
32
- end
33
- end
34
-
1
+ require 'daberu/talker'
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ module Daberu
4
+ class Talker
5
+ instance_methods.each do |m|
6
+ undef_method m unless m.to_s =~ /^__|method_missing|respond_to?|object_id/
7
+ end
8
+
9
+ def initialize(obj = Object.new)
10
+ @obj = obj
11
+ @format = "Class: %s, Method: %s, Arguments: [%s], Block: %s"
12
+ end
13
+
14
+ def method_missing(name, *args, &block)
15
+ p @format % [@obj.class, name, args.to_s.gsub(/^\[|\]$/, ""), block]
16
+ @obj.send(name, *args, &block)
17
+ end
18
+
19
+ def self.format_get(obj)
20
+ obj.__daberu_format_get__
21
+ end
22
+
23
+ def self.format_set(obj, str)
24
+ obj.__daberu_format_set__(str)
25
+ end
26
+
27
+ def __daberu_format_get__
28
+ @format
29
+ end
30
+
31
+ def __daberu_format_set__(str)
32
+ @format = str
33
+ end
34
+ end
35
+ end
36
+
@@ -1,3 +1,3 @@
1
1
  module Daberu
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/spec/daberu_spec.rb CHANGED
@@ -3,11 +3,11 @@
3
3
  require 'daberu'
4
4
  require 'tempfile'
5
5
 
6
- describe Daberu do
6
+ describe Daberu::Talker do
7
7
  it "is no argument" do
8
8
  t = Tempfile.open("daberu")
9
9
  $stdout = File.open(t, "w")
10
- d = Daberu.new
10
+ d = Daberu::Talker.new
11
11
  d.class.should == Object
12
12
  $stdout.flush
13
13
  $stdout = STDOUT
@@ -16,7 +16,7 @@ describe Daberu do
16
16
  it "is Array object" do
17
17
  t = Tempfile.open("daberu")
18
18
  $stdout = File.open(t, "w")
19
- a = Daberu.new([])
19
+ a = Daberu::Talker.new([])
20
20
  a << "a"
21
21
  a << "b"
22
22
  a << "c"
@@ -32,7 +32,7 @@ describe Daberu do
32
32
  it "is stdout" do
33
33
  t = Tempfile.open("daberu")
34
34
  $stdout = File.open(t, "w")
35
- a = Daberu.new([])
35
+ a = Daberu::Talker.new([])
36
36
  a << "a"
37
37
  actual = []
38
38
  a.each do |i|
@@ -50,7 +50,7 @@ describe Daberu do
50
50
  it "is stdout of no argument" do
51
51
  t = Tempfile.open("daberu")
52
52
  $stdout = File.open(t, "w")
53
- d = Daberu.new
53
+ d = Daberu::Talker.new
54
54
  d.class
55
55
  $stdout.flush
56
56
  $stdout = STDOUT
@@ -63,8 +63,8 @@ describe Daberu do
63
63
  it "is point of stdout format" do
64
64
  t = Tempfile.open("daberu")
65
65
  $stdout = File.open(t, "w")
66
- d = Daberu.new
67
- Daberu.format_set(d, "%s#%s(%s): %s")
66
+ d = Daberu::Talker.new
67
+ Daberu::Talker.format_set(d, "%s#%s(%s): %s")
68
68
  d.class
69
69
  $stdout.flush
70
70
  $stdout = STDOUT
@@ -77,10 +77,10 @@ describe Daberu do
77
77
  it "is view of stdout format" do
78
78
  t = Tempfile.open("daberu")
79
79
  $stdout = File.open(t, "w")
80
- d = Daberu.new
80
+ d = Daberu::Talker.new
81
81
  $stdout.flush
82
82
  $stdout = STDOUT
83
- Daberu.format_get(d).should == "Class: %s, Method: %s, Arguments: [%s], Block: %s"
83
+ Daberu::Talker.format_get(d).should == "Class: %s, Method: %s, Arguments: [%s], Block: %s"
84
84
  end
85
85
  end
86
86
 
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + "/../lib/daberu"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daberu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-09-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.10.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.10.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '3.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
14
62
  description: Create a talkative object.
15
63
  email:
16
64
  - myokoym@gmail.com
@@ -19,14 +67,17 @@ extensions: []
19
67
  extra_rdoc_files: []
20
68
  files:
21
69
  - .gitignore
70
+ - .travis.yml
22
71
  - Gemfile
23
72
  - LICENSE
24
73
  - README.md
25
74
  - Rakefile
26
75
  - daberu.gemspec
27
76
  - lib/daberu.rb
77
+ - lib/daberu/talker.rb
28
78
  - lib/daberu/version.rb
29
79
  - spec/daberu_spec.rb
80
+ - spec/spec_helper.rb
30
81
  homepage: https://github.com/myokoym/daberu
31
82
  licenses: []
32
83
  post_install_message:
@@ -53,4 +104,5 @@ specification_version: 3
53
104
  summary: Create a talkative object
54
105
  test_files:
55
106
  - spec/daberu_spec.rb
107
+ - spec/spec_helper.rb
56
108
  has_rdoc: