動画リンク切れ
DONE 4, 6
Introduction
目的と最終課題
この講義では,Rubyを修得することを目的とします.その目的が達成されたかを評価するため,
- なんかのCLA(command line application)をRubyで作成してgithubで公開する,
- あるいはgemで公開する,
- あるいは,その紹介記事をqiitaに投稿する
を最終課題とし,成績評価します.それぞれのリンク先を年内をめどにmailで西谷に送ってください.
links
- Qiita記事
- Zoom URL
- 初回メモ by Saito
- Github
- 動画(各回のリンク先にリンクを提示)
Schedule
past
- d0_ruby_env 9/21
- d1_git 9/28 claとその操作感
- d2_ruby_tdd 10/5 Ruby文法,TDD
- d3_my_halo 10/12 Bundle, TDD, RSpec フレームワーク
- d4_rake_dsl 10/19 Rakefile, Thor, DSL
- d5_my_help_intro 10/26 open, github文化, markup言語
- d6_my_help_fsm 11/2
- d7_org2hiki_regexp 11/9
- d8_d10_refactoring_tsutaya 11/16, 11/30, 12/7
d11_qiita 12/14
d12_members_CLIs 12/21
(Rubyで)ソフト開発必読書
- pragmatic programmer
- "The Pragmatic Programmer, Your journey to mastery, 20th Anniversary Edition", 2nd ed.,David Thomas and Andrew Hunt, (Addison-Wesley Professional,2019) or (Pragmatic Bookshelf).
- "達人プログラマー -熟達に向けたあなたの旅-" 第2版, David Thomas and Andrew Hunt (著), 村上雅章 (訳) ,(オーム社,2020).
- TDD, RSpec3
- "Effective Testing with RSpec 3, Build Ruby Apps with Confidence", by Myron Marston and Erin Dees, (The Pragmatic Bookshelf, 2017).
- Refactoring
- "Refactoring : Ruby Edition: Ruby Edition", by Jay Fields, Martin Fowler, e-book, (https://martinfowler.com/books/refactoringRubyEd.html).
- "リファクタリング: Rubyエディション", ジェイフィールド,シェーンハービー,マーティンファウラー,Kent Beck【著】,長尾高弘【訳】, (アスキー・メディアワークス, 2010).
- Design Pattern
- "Rubyによるデザインパターン", ラス・オルセン (著), 小林 健一他 (翻訳), (ピアソン桐原, 2009).
Schedule_preparing
Error_translator
translator
DeepL API + GAS(google apps script)
- https://auto-worker.com/blog/?p=5043
- https://qiita.com/satto_sann/items/be4177360a0bc3691fdf
- https://github.com/shioyama/mobility
- https://github.com/soimort/translate-shell
shell
other language
日本語化が当たり前...
qiita_org
Design pattern(DSL, CoC)
contents_memo
rsync
- rsyncで同期
- rake rsync
- –dry-run
- exlcudeで.gitとか指定すればgitとの併用になんの問題もなし
- ただし,失敗するとrepositoryが乗っ取られるので,両方をgithubに載せて作業すべし.
- ruby bin/auto_sync.rb
- 一致の検査,
- array比較の好例
open on wsl
- wslでopen
- xdg-open?
rspec
-t, task-o, output_format-m, matcher-c, check_stderr-K, KeyError-s, shared_context-u, using_temp_dir , shared_context_II-a, aruba_setup , thor_aruba_loop , thor_aruba_-r, raise_error-i, interactive_aruba
for new class
- name the behavior (The Org2Hash: get org and trans it to hash by FSM)
- cp some spec for rspec
- start coding in main loop
- test
- TDD…
- after that the new class should go appropriate position(name).
> cat spec/unit/org2hash_spec.rb
module MyHelp
describe "Org2Hash" do
it "return input" do
input = "hoge"
expect(Org2Hash.new(input).contents).to be_include(input)
end
end
end
> cat lib/my_help.rb
# frozen_string_literal: true
...
module MyHelp
...
# Your code goes here...
class Org2Hash
attr_accessor :contents
def initialize(input)
@contents = input
end
end
end
> rspec spec/unit/org2hash_spec.rb
Org2Hash
return input
Finished in 0.00184 seconds (files took 0.23943 seconds to load)
1 example, 0 failures
fsm(finite state machine)
- make sample #=> org text
- name state
- guess final results #=> Hash
- make TRANSITIONS
- make case-when and action
- make def-method if large
Discussions
bashly
Compare to Rust ( => Ruby )
- The Rust Programming Language
- Getting started
Guessing number game
- install, compile, run
- cargo => packaging
- library, install, => bundle install, exec
- use rand::Rng; => install library
- Cargo.toml => **.gemspec
- . trains
- type => nil
Common Language Concepts
- variables and Mutability, Constants, Shadowing,
- Data Types
- Scalar, Integer(u32, unsigned), Floating-Point(f32), Numeric Op.,Boolean, Character,
- Compound Types
- Tuple, Array,
- Functions, Parameters(arguement), Functions with Return Values,
- Comments
- Control Flow
- if(if in let), loop, for, while,
Ownership
-
manage memory, without garbage collector
-
the Stack and the Heap
-
Variable scope, String
-
borrowing(clone), slice
-
Structs
-
Enum and Pattern Matching
-
Packages, Crates, and Modules
= Common Collections
- Error Handling,
- Generic Types, Traits, and Lifetimes
- Automated Tests
Building a command line program
- Reading the Argument Values
- main, dbg!, args
- Reading a File
- Refactoring
- methods, Grouping Conf. Vals.,
- Constructor for Config
- Error handling
- move to lib.rs
- Test Driven Dev.
- test, case_insensitive, ignore_case
- error output
Iterators and Closures
etc
- Cargo, Crates.io, Pointers, Concurrency, OOP,
OOP
- object, encapsulation, inheritance,
- To many people, polymorphism is synonymous with inheritance.
Inheritance has recently fallen out of favor as a programming design solution in many programming languages because it’s often at risk of sharing more code than necessary. Subclasses shouldn’t always share all characteristics of their parent class but will do so with inheritance. This can make a program’s design less flexible. It also introduces the possibility of calling methods on subclasses that don’t make sense or that cause errors because the methods don’t apply to the subclass. In addition, some languages will only allow single inheritance (meaning a subclass can only inherit from one class), further restricting the flexibility of a program’s design.
For these reasons, Rust takes the different approach of using trait objects instead of inheritance. Let’s look at how trait objects enable polymorphism in Rust.
Go, Elixir, Clojure
- source ~/git_hub/ruby_docs/multi_scale_22_text/README.org