rabbit-slide-yancya-a_investigative_report_of_refinements 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4921240da9ddfd9dc25d8fc0f848de159151109a
4
+ data.tar.gz: aaeed9bff682bd2774737e342c63548fda3550e4
5
+ SHA512:
6
+ metadata.gz: da4d78fd2f95bd5a73294447c2bd0144586b60fdfdfbb86a9b48e7101c60e17dbcd47e05b86c7e53d44f29451ace624a5d4edbda18a1d19d0c7a111a28a351b9
7
+ data.tar.gz: 5d8df77640a282bb94e2dc56cc4776489ef9a06808afaad4fd387dd2aff1c827cb4ab29bd56860df6ae97269faddb4b054a0c9d45ed89f980435d48fa3ef70f5
data/.rabbit ADDED
@@ -0,0 +1 @@
1
+ a_investigative_report_of_refinements.rab
data/README.rd ADDED
@@ -0,0 +1,24 @@
1
+ = A investigative report of refinements
2
+
3
+ RubyHiroba 2014 で発表した、Refinements についての LT 資料です
4
+
5
+ == 作者向け
6
+
7
+ === 表示
8
+
9
+ rake
10
+
11
+ === 公開
12
+
13
+ rake publish
14
+
15
+ == 閲覧者向け
16
+
17
+ === インストール
18
+
19
+ gem install rabbit-slide-yancya-a_investigative_report_of_refinements
20
+
21
+ === 表示
22
+
23
+ rabbit rabbit-slide-yancya-a_investigative_report_of_refinements.gem
24
+
data/README.rd~ ADDED
@@ -0,0 +1,24 @@
1
+ = TODO: スライドのタイトル
2
+
3
+ TODO: スライドの説明
4
+
5
+ == 作者向け
6
+
7
+ === 表示
8
+
9
+ rake
10
+
11
+ === 公開
12
+
13
+ rake publish
14
+
15
+ == 閲覧者向け
16
+
17
+ === インストール
18
+
19
+ gem install rabbit-slide-yancya-a_investigative_report_of_refinements
20
+
21
+ === 表示
22
+
23
+ rabbit rabbit-slide-yancya-a_investigative_report_of_refinements.gem
24
+
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "rabbit/task/slide"
2
+
3
+ # Edit ./config.yaml to customize meta data
4
+
5
+ spec = nil
6
+ Rabbit::Task::Slide.new do |task|
7
+ spec = task.spec
8
+ # task.spec.files += Dir.glob("doc/**/*.*")
9
+ # task.spec.files -= Dir.glob("private/**/*.*")
10
+ # task.spec.add_runtime_dependency("YOUR THEME")
11
+ end
12
+
13
+ desc "Tag #{spec.version}"
14
+ task :tag do
15
+ sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
16
+ sh("git", "push", "--tags")
17
+ end
@@ -0,0 +1,154 @@
1
+ = yancya には Refinements がわからぬ
2
+
3
+ : subtitle
4
+ A investigative report of refinements
5
+ : author
6
+ yancya
7
+ # : institution
8
+ # 所属
9
+ : content-source
10
+ RubyHiroba 2014
11
+ : date
12
+ 2014/09/21
13
+ : allotted-time
14
+ 5m
15
+ : theme
16
+ rabbit
17
+
18
+ = 自己紹介
19
+
20
+ # image
21
+ # src = yancya.jpg
22
+ # width = 150
23
+ # height = 150
24
+
25
+ * @yancya
26
+ * 何者でも無い1人の Rubyist
27
+ * 3児の父
28
+
29
+ = オープンクラス
30
+
31
+ * 特徴的な Ruby の機能
32
+
33
+ # coderay ruby
34
+ class Fixnum
35
+ # 既存のクラスにメソッドを足したり
36
+ def plusplus
37
+ self + 1
38
+ end
39
+ # メソッドを上書きしたり出来る
40
+ def succ
41
+ self + 2
42
+ end
43
+ end
44
+
45
+ = オープンクラス
46
+
47
+ # coderay ruby
48
+ (1..10).map{|n| n.succ}
49
+ #=> [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
50
+
51
+ (1..10).map(&:succ)
52
+ #=> [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
53
+
54
+ (1..10).map{|n| n.plusplus}
55
+ #=> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
56
+
57
+ (1..10).map(&:plusplus)
58
+ #=> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
59
+
60
+ = オープンクラス
61
+
62
+ * こんなモンキーパッチばかりしていると、プログラマがクラスを信じられなくなってしまうぞ
63
+
64
+ = オープンクラス
65
+
66
+ * こんなモンキーパッチばかりしていると、プログラマがクラスを信じられなくなってしまうぞ
67
+ * yancya は「気をつける」のが苦手だろ
68
+
69
+ = Refinements
70
+
71
+ * スコープを限定してモンキーパッチする仕組みがあるんだぞ
72
+
73
+ # coderay ruby
74
+ # module 内にモンキーパッチを書いておく
75
+ module PlusPlus
76
+ refine Fixnum do
77
+ def plusplus
78
+ self + 1
79
+ end
80
+
81
+ def succ
82
+ self + 2
83
+ end
84
+ end
85
+ end
86
+
87
+ = Refinements
88
+
89
+ * using 以降の、同一ファイル内のコードにのみ、影響するんだ
90
+
91
+ # coderay ruby
92
+ # さっきのモジュールを using の引数に渡してやる
93
+ using PlusPlus
94
+
95
+ (1..10).map{|n| n.succ}
96
+ #=> [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
97
+
98
+ (1..10).map{|n| n.plusplus}
99
+ #=> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
100
+
101
+ = 色々試してみよう
102
+
103
+ # coderay ruby
104
+ using PlusPlus
105
+
106
+ (1..10).map(&:succ)
107
+ #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
108
+ # 上書きされてない
109
+
110
+ (1..10).map(&:plusplus)
111
+ #=> in `each': super: no superclass method `plusplus'
112
+ #=> for 1:Fixnum (NoMethodError)
113
+ # そんなメソッドは無い
114
+
115
+ = そ、そんなはずは
116
+
117
+ # coderay ruby
118
+ using PlusPlus
119
+
120
+ # 動くかな
121
+ 1.plusplus #=> 2
122
+ # よし、動くぞ
123
+
124
+ # plusplus ってあるよねー
125
+ 1.respond_to? :plusplus
126
+ #=> false 「無いですけど?]「えっ」
127
+
128
+ = 何が悪いのか
129
+
130
+ * &:symbol って、:symbol.to_proc.call(arg) と同じだったような
131
+
132
+ = to_proc, send
133
+
134
+ * やはり...
135
+
136
+ # coderay ruby
137
+ using PlusPlus
138
+
139
+ 1.send(:succ) #=> 2
140
+ 1.send(:plusplus) #=> NoMethodError
141
+
142
+ :succ.to_proc[1] #=> 3
143
+ :plusplus.to_proc[1] #=> NoMethodError
144
+
145
+ = 気をつける
146
+
147
+ * メソッドが、どこのスコープで実行されるのか、きちんと気をつけないとダメ
148
+ * send などのメタプログラミングメソッドを使うと、スコープがファイル外へすっ飛んでいってしまうことがあるので
149
+
150
+ = 結論
151
+
152
+ * yancya に Refinements は、まだ早すぎる
153
+ * 気をつけなくてもキチンと書けるようになるか、そういう仕組みを作るしかない
154
+ * もうちょっと勉強してから出直してこよう
data/config.yaml ADDED
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: a_investigative_report_of_refinements
3
+ base_name: a_investigative_report_of_refinements
4
+ tags: []
5
+ presentation_date:
6
+ version: 1.0.0
7
+ licenses: []
8
+ slideshare_id: yancyajp
9
+ speaker_deck_id: yancya
10
+ ustream_id:
11
+ vimeo_id:
12
+ youtube_id:
13
+ author:
14
+ markup_language: :rd
15
+ name: yancya
16
+ email: yancya@upec.jp
17
+ rubygems_user: yancya
18
+ slideshare_user: yancyajp
19
+ speaker_deck_user: yancya
data/yancya.jpg ADDED
Binary file
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit-slide-yancya-a_investigative_report_of_refinements
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - yancya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rabbit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.2
27
+ description: RubyHiroba 2014 で発表した、Refinements についての LT 資料です
28
+ email:
29
+ - yancya@upec.jp
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rabbit"
35
+ - README.rd
36
+ - README.rd~
37
+ - Rakefile
38
+ - a_investigative_report_of_refinements.rab
39
+ - config.yaml
40
+ - pdf/a_investigative_report_of_refinements-a_investigative_report_of_refinements.pdf
41
+ - yancya.jpg
42
+ homepage: http://slide.rabbit-shocker.org/authors/yancya/a_investigative_report_of_refinements/
43
+ licenses: []
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: A investigative report of refinements
65
+ test_files: []