rabbit-slide-znz-rubykaigi2017-frozen_string_literal 2017.09.19

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e3e4719954d760dffbef03c97c76ea9cc650265
4
+ data.tar.gz: a88cd5b6a2589c8745ec1bb51fce012f0120bcd4
5
+ SHA512:
6
+ metadata.gz: 664c7c43423fa1af914063bfe35046d09d70d4ab6492ae2ec1bccd77e5d8b0957eaa75aaa24cb44f2b582fa89c564b0259e3c89b46c0535024a61c5b3a1534c1
7
+ data.tar.gz: 4c7a04df3201d217df5ce13905bc6abd956fef9641915d3d3046f359022d99c5d6281f61dd62b7922b9e3bae8d5c37a42401a490e35a63ae85ab0fe3e69b4d4d
data/.rabbit ADDED
@@ -0,0 +1 @@
1
+ rubykaigi2017-frozen_string_literal.md
@@ -0,0 +1,23 @@
1
+ # How to specify `frozen_string_literal: true`
2
+
3
+ RubyKaigi 2017 の LT での発表資料です。
4
+
5
+ ## 作者向け
6
+
7
+ ### 表示
8
+
9
+ rake
10
+
11
+ ### 公開
12
+
13
+ rake publish
14
+
15
+ ## 閲覧者向け
16
+
17
+ ### インストール
18
+
19
+ gem install rabbit-slide-znz-rubykaigi2017-frozen_string_literal
20
+
21
+ ### 表示
22
+
23
+ rabbit rabbit-slide-znz-rubykaigi2017-frozen_string_literal.gem
@@ -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
+ # spec.files += Dir.glob("doc/**/*.*")
9
+ # spec.files -= Dir.glob("private/**/*.*")
10
+ # 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,20 @@
1
+ ---
2
+ id: rubykaigi2017-frozen_string_literal
3
+ base_name: rubykaigi2017-frozen_string_literal
4
+ tags:
5
+ - ruby
6
+ presentation_date: 2017/09/19
7
+ version: 2017.09.19
8
+ licenses: []
9
+ slideshare_id: how-to-specify-frozenstringliteral-true
10
+ speaker_deck_id: how-to-specify-frozen-string-literal-true
11
+ ustream_id:
12
+ vimeo_id:
13
+ youtube_id:
14
+ author:
15
+ markup_language: :markdown
16
+ name: Kazuhiro NISHIYAMA
17
+ email: zn@mbf.nifty.com
18
+ rubygems_user: znz
19
+ slideshare_user: znzjp
20
+ speaker_deck_user: znz
@@ -0,0 +1,91 @@
1
+ # How to specify `frozen_string_literal: true`
2
+
3
+ author
4
+ : Kazuhiro NISHIYAMA
5
+
6
+ content-source
7
+ : RubyKaigi 2017 LT
8
+
9
+ date
10
+ : 2017/09/19
11
+
12
+ allotted-time
13
+ : 5m
14
+
15
+ theme
16
+ : lightning-simple
17
+
18
+ # self.introduce
19
+
20
+ - One of Ruby committers
21
+ - Twitter, GitHub: `@znz`
22
+
23
+ # What's `frozen_string_literal` magic comment
24
+
25
+ - Specify string literals are frozen or not per file
26
+ - Frozen string literals are faster
27
+ - Generate less objects
28
+ - Reduce GC
29
+
30
+ # Example
31
+
32
+ - After coding if exist
33
+
34
+ example:
35
+
36
+ # -*- coding: utf-8 -*-
37
+ # frozen_string_literal: true
38
+ p ''.frozen? #=> true
39
+
40
+ # Past release
41
+
42
+ - Add *`frozen_string_literal: false`* for almost `*.rb` files when Ruby 2.3.0
43
+ - For compatibility with *`--enable=frozen-string-literal`* command line option of ruby
44
+
45
+ # Changes in this year
46
+
47
+ - Recent Ruby programs tend to specify `true`, but ruby standard libraries are `false`.
48
+ - So I changed to `frozen_string_literal: true` in some files which assigned to no maintainer in doc/maintainers.rdoc.
49
+
50
+ # Review points before change
51
+
52
+ Almost *`RuntimeError: can't modify frozen String`* points are:
53
+
54
+ - `String#<<`
55
+ - bang methods (e.g. `String#sub!`)
56
+
57
+ # Overlooked modification
58
+
59
+ - `IO#read(length, out_buffer)`
60
+ - this buffer is overlooked
61
+
62
+ # Find modified string literal
63
+
64
+ - *`--debug=frozen-string-literal`* command line option is very useful
65
+
66
+ examples:
67
+
68
+ ruby --debug=frozen-string-literal test.rb
69
+ make test-all TESTS='-v base64' RUBYOPT=--debug=frozen-string-literal
70
+
71
+ # Tests
72
+
73
+ - *`--debug=frozen-string-literal`* needs to run codes.
74
+ - So tests are very important.
75
+
76
+ # No change if can't
77
+
78
+ - If no tests, there is no need to forcibly change it.
79
+ - I think working codes are useful than broken faster codes.
80
+
81
+ # mkmf.rb
82
+
83
+ - mkmf.rb has many tests
84
+ - But mkmf.rb is too complex to me in a short time
85
+ - So I remain false
86
+
87
+ # Conclusion
88
+
89
+ - No tests may overlook modifications
90
+ - Use *`frozen_string_literal: true`* if you can
91
+ - You can use *`frozen_string_literal: false`* in some cases for compatibility for *`--enable=frozen-string-literal`*
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit-slide-znz-rubykaigi2017-frozen_string_literal
3
+ version: !ruby/object:Gem::Version
4
+ version: 2017.09.19
5
+ platform: ruby
6
+ authors:
7
+ - Kazuhiro NISHIYAMA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-19 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: RubyKaigi 2017 の LT での発表資料です。
28
+ email:
29
+ - zn@mbf.nifty.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rabbit"
35
+ - README.md
36
+ - Rakefile
37
+ - config.yaml
38
+ - pdf/rubykaigi2017-frozen_string_literal-rubykaigi2017-frozen_string_literal.pdf
39
+ - rubykaigi2017-frozen_string_literal.md
40
+ homepage: http://slide.rabbit-shocker.org/authors/znz/rubykaigi2017-frozen_string_literal/
41
+ licenses: []
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.6.13
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: 'How to specify `frozen_string_literal: true`'
63
+ test_files: []