drive 0.26.0 → 0.28.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bd7bffb05fd92820dff9636b8e45a6d534ba93d4f3e494f27d510110d27c484
4
- data.tar.gz: 6b5e577baef1bb0ccb36b5b870d0ad89cacd229dcbec1fe9265bfa9ed84a514a
3
+ metadata.gz: 8f9907d0cf9072683d008fc22974145df3d9a91032f9aec640d622c5527aefab
4
+ data.tar.gz: b93d1e1388db3c5be48a3a539f0c4e75c55bb99a567b61b2c835e35a471030a3
5
5
  SHA512:
6
- metadata.gz: 5964e392a7e3ea8d8c3eb20a17675101133e83ad0f57f667411cecd9c8984a23a0bf1089d7640e7a804a9a4c60f75592a2826c3eb575c34d8c5496c7ae2ba055
7
- data.tar.gz: 4815745a2c6193d595268c4f412fd6046e588c353558c55468056b496767db37126592fa237be636c6d20e9f7c44a62d2612f233150a113e65bdc774b2cd2617
6
+ metadata.gz: d9829b4b0541d937dcf3be5e5b7a5004a059c922bac237e97874e9f283bb3676c5641ba5a4f8b206bc26c575eca4616c68d50b56a96fb83967dfb8275dfcc6d1
7
+ data.tar.gz: 8e2bd2fba533a4212efa2a878950b3063c6e1f7a5059e4e63c93fd44acb8826bbe18fd8c224934b75d8eb00c05b90e074de9cce712d50a9656f6c2cf115a89c0
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@ For more information about changelogs, check [Keep a Changelog](http://keepachan
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 0.28.0 - 2026-11-20
10
+
11
+ * [FEATURE] `Refined::Aircraft`, `Refined::Model`, `Refined::Engine`: the refinery's tables, read
12
+ by every app: `Refined::Aircraft.registered("n-22196")` and its `model_name`, `engine_name` and
13
+ `owner_place`; `twin?`, `propeller?` (all but jets and turboshafts), `piston?` (a carburetor or
14
+ fuel injection and magnetos) and `expected_engine(position)`
15
+ * [FEATURE] `Refined::Engine.designated("o320b")`, the engine a typed make and model names;
16
+ `#cylinders`, as its maker and model say; `#dual_magneto?`; `#family_ids`
17
+ * [FEATURE] `Refined::Choices.new(aircraft, engine:, position:).for(slot)`: what to offer for an
18
+ engine, a propeller, a carburetor or fuel injection and each magneto: what the data sheets list
19
+ for that side, then the others (the same sheets', or the engine family's), then each part an STC
20
+ allows the model by its own designation; a propeller an STC installs with the engine said comes
21
+ first. Moved from hangar's `Equipment::Choices`
22
+ * [FEATURE] The refinery's `AircraftEngine`, `ModelEngine`, `ModelAppliance`, `EngineAppliance`,
23
+ `Appliance`, `Modification`, `ModificationEngine` and `ModificationAppliance`, read-only
24
+ * [FEATURE] `Inspection::PREP`, `GROUPS` and `ITEMS`: 14 CFR Part 43 Appendix D as a mechanic
25
+ checks it (config/inspection.yml). An app with its own `Inspection` keeps it
26
+
27
+ ## 0.27.0 - 2026-11-17
28
+
29
+ * [FEATURE] `rate_limited agent: 60`: pages one user agent may ask for a minute, from every address
30
+ together, for a scraper spread over thousands of addresses. A crawler is not counted, nor a
31
+ controller that says `def agent_limited? = false`; one refused is told nothing of what was counted.
32
+
9
33
  ## 0.26.0 - 2026-11-10
10
34
 
11
35
  * [BREAKING] The easy design system and the error pages are `wordmark`'s
@@ -120,7 +144,8 @@ For more information about changelogs, check [Keep a Changelog](http://keepachan
120
144
  flown by `easy/flyer.js` (ES5, included once by the page) and drawn by `sky` and `flyer` in `easy/components`.
121
145
  On a holiday, by the visitor's own calendar, the plane flies in the day's colors with one line of smoke per color:
122
146
  New Year's Day and Eve, Valentine's Day, St. Patrick's Day, Easter, Memorial Day, Independence Day, National
123
- Aviation Day, Halloween, Veterans Day, Thanksgiving, Wright Brothers Day and Christmas. `date:` flies it on another day, to see one.
147
+ Aviation Day, Halloween, Veterans Day, Thanksgiving, Wright Brothers Day and Christmas. `date:` flies it on another
148
+ day, to see one.
124
149
 
125
150
  * [FEATURE] `i-small-plane`, easyAnnual's single engine, in the sprite beside easyFAA's `i-plane`.
126
151
 
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Drive
2
2
 
3
3
  A Rails engine for the easyFAA apps, each behind Cloudflare. What their pages look like, the error
4
- pages included, is [`wordmark`](https://github.com/easyfaa/design)'s.
4
+ pages included, is [`easyfaa`](https://github.com/easyfaa/easyfaa/tree/main/design)'s.
5
5
  A copy of the tables a source publishes is the [`mirroring`](https://github.com/easyfaa/mirroring)
6
6
  gem's.
7
7
 
8
8
  - **`RateLimited`**: `rate_limited` holds an address to 20 pages a minute and 200 a day, or the
9
- app's own limits, and tells it so in words. A search engine's own crawler has no limit.
9
+ app's own limits, and tells it so in words; with `agent:`, a user agent too, from every address
10
+ together. A search engine's own crawler has no limit.
10
11
  - **`Crawler`**: whether a request comes from a search engine's crawler: Cloudflare vouches for
11
12
  it (where `EDGE_KEY` is set), or its address is in the ranges Google, Bing, Apple, Claude,
12
13
  ChatGPT or Perplexity publish, fetched once a day.
@@ -2,8 +2,12 @@
2
2
  # crawler (Crawler) is never held to, so it can list every page. Refused, a client is told why in
3
3
  # words, with status 429, rather than with an error the app would report.
4
4
  #
5
+ # A limit by user agent, from every address together, refuses a scraper spread over thousands of
6
+ # addresses, which still sends a few browsers' names. It is told nothing of what was counted. A
7
+ # controller whose callers all share one user agent turns it off with `def agent_limited? = false`.
8
+ #
5
9
  # rate_limited # 20 a minute and 200 a day
6
- # rate_limited minute: 120, day: nil, scope: 'public'
10
+ # rate_limited minute: 120, day: nil, agent: 60, scope: 'public'
7
11
  module RateLimited
8
12
  extend ActiveSupport::Concern
9
13
 
@@ -14,27 +18,47 @@ module RateLimited
14
18
  class_methods do
15
19
  # @param minute [Integer, nil] pages an address may ask for a minute.
16
20
  # @param day [Integer, nil] pages an address may ask for a day.
21
+ # @param agent [Integer, nil] pages one user agent may ask for a minute, from every address.
17
22
  # @param scope [String, nil] the controllers counted together; each its own if nil.
18
- def rate_limited(minute: 20, day: 200, scope: nil)
23
+ def rate_limited(minute: 20, day: 200, agent: nil, scope: nil)
19
24
  { minute: [minute, 1.minute], day: [day, 1.day] }.each do |name, (to, within)|
20
25
  next unless to
21
26
 
22
27
  rate_limit(to:, within:, name: name.to_s, scope:, unless: -> { crawler? },
23
28
  with: -> { refuse_flood minute:, day: })
24
29
  end
30
+ limit_agents(agent, scope:) if agent
31
+ end
32
+
33
+ private
34
+
35
+ def limit_agents(to, scope:)
36
+ rate_limit(to:, within: 1.minute, by: -> { request.user_agent.to_s }, name: 'agent', scope:,
37
+ if: -> { agent_limited? }, with: -> { refuse_agent_flood })
25
38
  end
26
39
  end
27
40
 
28
41
  private
29
42
 
30
- # Whether a search engine vouches for this client, asked once a request.
31
- def crawler? = defined?(@crawler) ? @crawler : @crawler = Crawler.verified?(request)
43
+ def crawler?
44
+ # A search engine is asked once a request whether it vouches for this client.
45
+ defined?(@crawler) ? @crawler : @crawler = Crawler.verified?(request)
46
+ end
32
47
 
33
- # What a client asking too often is told. A host may say it its own way.
34
48
  def refuse_flood(minute:, day:)
49
+ # A host may say it its own way.
35
50
  limits = { minute:, day: }.compact.map { |per, count| "#{count} a #{per}" }
36
51
  render plain: 'Too many requests. Each address may ask for so many pages: ' \
37
52
  "#{limits.join ' and '}.\n",
38
53
  status: :too_many_requests
39
54
  end
55
+
56
+ def agent_limited? = !crawler?
57
+
58
+ def refuse_agent_flood
59
+ logger.warn "Agent limit: #{request.user_agent} on #{request.path}"
60
+ response.cache_control.merge! private: true, no_store: true
61
+ render plain: "Too many requests right now. Wait a minute, then reload this page.\n",
62
+ status: :too_many_requests
63
+ end
40
64
  end
@@ -0,0 +1,17 @@
1
+ # The annual or 100-hour inspection, as 14 CFR Part 43 Appendix D lists it (config/inspection.yml): (a) the prep,
2
+ # (b) to (j) its items, then the close-up checks; and the ELT's.
3
+ module Inspection
4
+ # The whole list, as the file says it.
5
+ DATA = YAML.load_file(File.expand_path('../../config/inspection.yml', __dir__)).freeze
6
+
7
+ # (a) Before the inspection: what's done first, each a name by its key.
8
+ PREP = DATA['prep'].freeze
9
+
10
+ # (b) to (j): each group's title and its items, each a name and what it's inspected for, by key (b1, b2…).
11
+ GROUPS = DATA['groups'].freeze
12
+
13
+ # Every item, by key (b1 … j1): [group letter, name, what it's inspected for].
14
+ ITEMS = GROUPS.flat_map do |letter, group|
15
+ group['items'].map { |key, (name, about)| [key, [letter, name, about]] }
16
+ end.to_h.freeze
17
+ end
@@ -0,0 +1,58 @@
1
+ module Refined
2
+ # An aircraft as the FAA registers it (refined.aircraft): its N-number, serial, year, model,
3
+ # engine and owner.
4
+ class Aircraft < Record
5
+ self.table_name = 'refined.aircraft'
6
+
7
+ belongs_to :model, optional: true
8
+ belongs_to :engine, optional: true
9
+ has_many :aircraft_engines, dependent: nil
10
+
11
+ # The registered aircraft with the N-number, however it was typed.
12
+ def self.registered(typed)
13
+ tail = NNumber.parse typed
14
+ includes(:model, :engine).find_by n_number: tail if tail
15
+ end
16
+
17
+ # Its model's name: "Cessna 150H".
18
+ def model_name = model&.name
19
+
20
+ # Its engine's name: "Cont Motor O-200 Series".
21
+ def engine_name = engine&.name
22
+
23
+ # The engines that turn no propeller: jets, and a helicopter's turboshafts (a rotor).
24
+ UNPROPELLED = %w[turbo_fan turbo_jet ramjet turbo_shaft].freeze
25
+
26
+ # The engines no carburetor feeds and no magneto fires: turbines and electric motors.
27
+ UNSPARKED = %w[turbo_fan turbo_jet ramjet turbo_prop turbo_shaft electric].freeze
28
+
29
+ # Whether it has two engines.
30
+ def twin? = model&.number_of_engines == 2
31
+
32
+ # Whether its engines turn a propeller: all but jets and turboshafts.
33
+ def propeller? = UNPROPELLED.exclude?(model&.engine_type)
34
+
35
+ # Whether its engines are pistons, with a carburetor or fuel injection and magnetos: all but turbines and electric
36
+ # motors.
37
+ def piston? = UNSPARKED.exclude?(model&.engine_type)
38
+
39
+ # The engine the refinery matched this side's engine ADs by: the data sheet's, else the registry's, unless the
40
+ # sheet puts that on the other side.
41
+ def expected_engine(position = nil)
42
+ elsewhere = aircraft_engines.any? { it.from_registry? && !it.on?(position) }
43
+ sheet_engine(position) || (engine unless elsewhere)
44
+ end
45
+
46
+ # Where its registered owner is: "Scottsdale, AZ".
47
+ def owner_place = [owner_city&.titleize, owner_state].compact_blank.join(', ')
48
+
49
+ private
50
+
51
+ # The one engine the refinery took from the model's data sheet for this side, where the registry records none or
52
+ # a family only.
53
+ def sheet_engine(position)
54
+ rows = aircraft_engines.select { it.from_sheet? && it.on?(position) }
55
+ rows.first.engine if rows.one?
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,18 @@
1
+ module Refined
2
+ # An engine an aircraft's engine ADs are matched by, as the refinery wrote it (refined.aircraft_engines): the
3
+ # registry's, or one its model's data sheet lists, on one side of a twin or, with no position, on both.
4
+ class AircraftEngine < Record
5
+ self.table_name = 'refined.aircraft_engines'
6
+
7
+ belongs_to :engine
8
+
9
+ # Whether it comes from the data sheet.
10
+ def from_sheet? = source == 'data_sheet'
11
+
12
+ # Whether it comes from the registry.
13
+ def from_registry? = source == 'registry'
14
+
15
+ # Whether it is on this side of a twin: any is when no side is asked, and one with no position is on both.
16
+ def on?(side) = side.nil? || position.nil? || position == side
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module Refined
2
+ # A part number ADs name and a mechanic may say is installed (a magneto's "4251", a propeller's "1C160/DTM7553"), as
3
+ # the refinery gathered it (refined.appliances).
4
+ class Appliance < Record
5
+ self.table_name = 'refined.appliances'
6
+
7
+ # Those the refinery still lists.
8
+ scope :current, -> { where retired_at: nil }
9
+ end
10
+ end
@@ -0,0 +1,69 @@
1
+ module Refined
2
+ class Choices
3
+ # What the STCs an aircraft's model (or, for an accessory, its engine) is approved for allow (the refinery's
4
+ # modification_engines and modification_appliances): each engine or part by its own designation, as an AD names
5
+ # it, though the STC may name a family ("O-360"), however the refinery writes it (O360-A1A and O-360-A1A are
6
+ # one), its note the STCs that allow it.
7
+ module Modified
8
+ private
9
+
10
+ def modified(slot)
11
+ slot == 'engine' ? modified_engines : modified_appliances(KINDS.fetch(slot, %w[propeller]))
12
+ end
13
+
14
+ def modified_engines
15
+ by_design(engine_rows) { it.engine.model }.map do |rows|
16
+ engine = rows.first.engine
17
+ Choice.new(designation: engine.model, maker: engine.manufacturer.presence, note: "STC #{numbers rows}")
18
+ end
19
+ end
20
+
21
+ def modified_appliances(kinds)
22
+ by_design(appliance_rows(kinds)) { it.appliance.name }.map { appliance_from_stcs it }
23
+ end
24
+
25
+ def appliance_from_stcs(rows)
26
+ appliance = rows.first.appliance
27
+ Choice.new(designation: appliance.name, maker: appliance.maker, note: "STC #{numbers rows}")
28
+ end
29
+
30
+ # The propellers the STCs that allow the engine said to be installed on this model install with it, before the
31
+ # data sheets' (which go with the engine the sheet lists), or the sheets' alone.
32
+ def paired_first(sheets)
33
+ paired = paired_propellers
34
+ paired.empty? ? sheets : [paired, sheets.flatten]
35
+ end
36
+
37
+ def paired_propellers
38
+ return [] unless @engine
39
+
40
+ stcs = ModificationEngine.where(model_id: @aircraft.model_id, engine_id: @engine.id).select(:modification_id)
41
+ rows = ModificationAppliance.where(model_id: @aircraft.model_id, modification_id: stcs)
42
+ propellers = rows.includes(:modification, :appliance).select { it.appliance.kind == 'propeller' }
43
+ by_design(propellers) { it.appliance.name }.map { paired_choice it }
44
+ end
45
+
46
+ def paired_choice(rows) = appliance_from_stcs(rows).with(note: "with STC #{numbers rows}", paired: true)
47
+
48
+ # The rows of each design, by its designation's key.
49
+ def by_design(rows, &designation)
50
+ rows.group_by { Designation.key designation.call(it) }.sort.map(&:last)
51
+ end
52
+
53
+ # A family the refinery keeps as an engine ("O-320 Series") is no engine a plate names.
54
+ def engine_rows
55
+ rows = ModificationEngine.where(model_id: @aircraft.model_id).includes(:modification, :engine)
56
+ rows.reject { it.engine.series }
57
+ end
58
+
59
+ def appliance_rows(kinds)
60
+ engine = @engine || @aircraft.expected_engine(@position)
61
+ rows = ModificationAppliance.where(model_id: @aircraft.model_id)
62
+ rows = rows.or(ModificationAppliance.where(engine_id: engine.id)) if engine
63
+ rows.includes(:modification, :appliance).select { kinds.include? it.appliance.kind }
64
+ end
65
+
66
+ def numbers(rows) = rows.map { it.modification.number }.uniq.sort.join(', ')
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,110 @@
1
+ module Refined
2
+ # What a page offers a mechanic to pick from for each part the registry does not record: first what the data sheets
3
+ # list for this aircraft, then the others it may well have, since an STC or a field approval allows parts no sheet
4
+ # lists: what the same sheets list for other models, or an accessory what its engine's family's list. They may also
5
+ # type one in. On one side of a twin, what the sheets list for that side comes first.
6
+ class Choices
7
+ include Modified
8
+
9
+ # One part to pick; paired, one an STC installs with the engine said to be installed, not a data sheet's.
10
+ Choice = Data.define(:designation, :maker, :note, :paired) do
11
+ def initialize(designation:, maker:, note:, paired: false) = super
12
+
13
+ # Its maker and designation.
14
+ def to_s = [maker, designation].compact_blank.join(' ')
15
+ end
16
+
17
+ # The kinds of appliance each accessory's slot holds.
18
+ KINDS = { 'fuel_metering' => %w[carburetor fuel_injection], 'magneto' => %w[magneto],
19
+ 'left_magneto' => %w[magneto], 'right_magneto' => %w[magneto], }.freeze
20
+
21
+ # @param aircraft [Refined::Aircraft]
22
+ # @param engine [Refined::Engine, nil] the engine said to be installed, which picks its accessories better than
23
+ # the registry.
24
+ # @param position [String, nil] the side of a twin the choices are for.
25
+ def initialize(aircraft, engine: nil, position: nil)
26
+ @aircraft = aircraft
27
+ @engine = engine
28
+ @position = position
29
+ end
30
+
31
+ # The ones the data sheets list for this aircraft, the others, and those an STC allows (one for each way an STC
32
+ # words it, its note the STCs): the engine's, the propeller's or an accessory's (KINDS). A propeller's first are
33
+ # those the STCs that allow the engine said to be installed install with it, then the sheets'.
34
+ def for(slot)
35
+ listed, others = case slot
36
+ when 'engine' then engines
37
+ when 'propeller' then paired_first(propellers)
38
+ else accessories(KINDS.fetch(slot))
39
+ end
40
+ listed = unique(listed)
41
+ others = apart(unique(others), listed)
42
+ [listed, others, apart(modified(slot), listed + others)]
43
+ end
44
+
45
+ private
46
+
47
+ def engines
48
+ expected = sheet_engine_ids
49
+ mine = ModelEngine.where(model_id: @aircraft.model_id).includes(:engine)
50
+ .sort_by.with_index do |row, index|
51
+ [side(row), expected.include?(row.engine_id) ? 0 : 1,
52
+ index,]
53
+ end
54
+ [mine.map { engine_choice it }, same_sheets(ModelEngine, mine, :engine).map { engine_choice it }]
55
+ end
56
+
57
+ def propellers
58
+ mine = ModelAppliance.where(model_id: @aircraft.model_id).includes(:appliance)
59
+ .sort_by.with_index { |row, index| [side(row), index] }
60
+ [mine.map { appliance_choice it }, same_sheets(ModelAppliance, mine, :appliance).map { appliance_choice it }]
61
+ end
62
+
63
+ # What the engine said to be installed (else the one expected) has on its data sheet, then what its family's do.
64
+ def accessories(kinds)
65
+ engine = @engine || @aircraft.expected_engine(@position)
66
+ return [[], []] unless engine
67
+
68
+ [sheets_list(kinds, [engine.id]), sheets_list(kinds, engine.family_ids).sort_by(&:designation)]
69
+ end
70
+
71
+ # The engines that the refinery took from the data sheet for this side.
72
+ def sheet_engine_ids = @aircraft.aircraft_engines.select { it.from_sheet? && it.on?(@position) }.map(&:engine_id)
73
+
74
+ # The accessories of these kinds the data sheets of these engines list.
75
+ def sheets_list(kinds, engine_ids)
76
+ rows = EngineAppliance.where(engine_id: engine_ids).includes(:appliance)
77
+ rows.select { kinds.include? it.appliance.kind }.map { appliance_choice it }
78
+ end
79
+
80
+ # What the same sheets list for other models.
81
+ def same_sheets(table, mine, part)
82
+ return [] if mine.empty?
83
+
84
+ table.where(sheet: mine.map(&:sheet).uniq).where.not(model_id: @aircraft.model_id).includes(part).to_a
85
+ end
86
+
87
+ # This side's rows first, then the ones for both sides, then the other side's.
88
+ def side(row)
89
+ return 0 if @position.nil? || row.side == @position
90
+
91
+ row.side.nil? ? 1 : 2
92
+ end
93
+
94
+ def engine_choice(row)
95
+ Choice.new(designation: row.engine.model, maker: row.engine.manufacturer.presence, note: row.condition.presence)
96
+ end
97
+
98
+ def appliance_choice(row)
99
+ Choice.new(designation: row.appliance.name, maker: row.appliance.maker, note: row.condition.presence)
100
+ end
101
+
102
+ def unique(choices) = choices.reject { it.designation.empty? }.uniq { Designation.key it.designation }
103
+
104
+ # The choices none of those offered already names.
105
+ def apart(choices, offered)
106
+ keys = offered.map { Designation.key it.designation }
107
+ choices.reject { keys.include? Designation.key(it.designation) }
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,67 @@
1
+ module Refined
2
+ # An engine model as the refinery names it (refined.engines).
3
+ class Engine < Record
4
+ self.table_name = 'refined.engines'
5
+
6
+ # A dual magneto's designation, one unit firing both sets of plugs: a D where a single one has an S (D4LN-2021,
7
+ # S4LN-200), or Bendix's D-2000 and D-3000.
8
+ DUAL_MAGNETO = /\AD(\d*[LR]N|-\d)/
9
+
10
+ # Lycoming's cylinders by displacement, 4 where it isn't here.
11
+ LYCOMING_CYLINDERS = { 435 => 6, 480 => 6, 540 => 6, 580 => 6, 720 => 8 }.freeze
12
+
13
+ # Continental's four-cylinder displacements (the A and C 65 to 90 too): 6 otherwise.
14
+ CONTINENTAL_FOURS = [170, 190, 200, 240, 346].freeze
15
+
16
+ has_many :engine_appliances, dependent: nil
17
+
18
+ # Those the refinery still lists.
19
+ scope :current, -> { where retired_at: nil }
20
+
21
+ # The one a typed make and model names, however it was written ("O-320-B", "o320b"): of those still listed with
22
+ # its designation, the one on the most aircraft.
23
+ def self.designated(typed)
24
+ current.where(designation_key: Designation.key(typed)).order(aircraft_count: :desc).first
25
+ end
26
+
27
+ # The engines still listed of its family, those its designation's letters and number start (every O-320 for an
28
+ # O-320-H2AD), itself among them.
29
+ def family_ids
30
+ root = family_key
31
+ return [] unless root
32
+
33
+ like = Engine.current.where('designation_key LIKE ?', "#{self.class.sanitize_sql_like root}%")
34
+ like.select { it.family_key == root }.map(&:id)
35
+ end
36
+
37
+ # How many cylinders it has, as its maker and model say: Lycoming's by displacement, Continental's fours by
38
+ # theirs, Franklin's 4A; 6 where nothing says.
39
+ def cylinders
40
+ words = "#{manufacturer} #{name} #{model}".upcase
41
+ size = words[/(\d{3})/, 1].to_i
42
+ if words.include?('LYCOMING') then LYCOMING_CYLINDERS.fetch(size, 4)
43
+ elsif words.match?(/\bCONT/) then continental_cylinders(words, size)
44
+ elsif words.include?('FRANKLIN') then words.include?('4A') ? 4 : 6
45
+ else
46
+ 6
47
+ end
48
+ end
49
+
50
+ # Whether its data sheet lists magnetos, every one of them dual.
51
+ def dual_magneto?
52
+ magnetos = engine_appliances.includes(:appliance).map(&:appliance).select { it.kind == 'magneto' }
53
+ magnetos.any? && magnetos.all? { DUAL_MAGNETO.match? it.name }
54
+ end
55
+
56
+ protected
57
+
58
+ # Its family's letters and number, as its designation key starts: "O320" for the O-320-H2AD.
59
+ def family_key = designation_key.to_s[/\A[A-Z]+\d+/]
60
+
61
+ private
62
+
63
+ def continental_cylinders(words, size)
64
+ CONTINENTAL_FOURS.include?(size) || words.match?(/\b[AC]-?(65|75|85|90)\b/) ? 4 : 6
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,10 @@
1
+ module Refined
2
+ # A magneto, carburetor or other accessory an engine may have, as its data sheet lists it
3
+ # (refined.engine_appliances).
4
+ class EngineAppliance < Record
5
+ self.table_name = 'refined.engine_appliances'
6
+
7
+ belongs_to :engine
8
+ belongs_to :appliance
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module Refined
2
+ # An aircraft model as the refinery names it (refined.models).
3
+ class Model < Record
4
+ self.table_name = 'refined.models'
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Refined
2
+ # A propeller an aircraft of a model may fly with, as its data sheet lists it (refined.model_appliances).
3
+ class ModelAppliance < Record
4
+ self.table_name = 'refined.model_appliances'
5
+
6
+ belongs_to :appliance
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Refined
2
+ # An engine an aircraft of a model may be flown with, as its data sheet lists it (refined.model_engines).
3
+ class ModelEngine < Record
4
+ self.table_name = 'refined.model_engines'
5
+
6
+ belongs_to :engine
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Refined
2
+ # A Supplemental Type Certificate as the refinery keeps it (refined.modifications): its number and what it changes.
3
+ class Modification < Record
4
+ self.table_name = 'refined.modifications'
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module Refined
2
+ # A propeller or an accessory an STC allows (refined.modification_appliances), on an aircraft model or an engine, as
3
+ # the STC words it.
4
+ class ModificationAppliance < Record
5
+ self.table_name = 'refined.modification_appliances'
6
+
7
+ belongs_to :modification
8
+ belongs_to :appliance
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Refined
2
+ # An engine an STC allows on an aircraft model (refined.modification_engines), as the STC words it ("O-320" for
3
+ # every O-320 it reaches).
4
+ class ModificationEngine < Record
5
+ self.table_name = 'refined.modification_engines'
6
+
7
+ belongs_to :modification
8
+ belongs_to :engine
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Refined
2
+ # Base class for the refinery's tables (the refined schema), which every app reads and only the
3
+ # refinery writes.
4
+ class Record < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,92 @@
1
+ # 14 CFR Part 43 Appendix D as a mechanic checks it: (a) is the prep, (b) to (j) the 42 items, each a name and what
2
+ # it is inspected for. Then the close-up checks and the ELT's (14 CFR 91.207(d)).
3
+ prep:
4
+ clean: Aircraft cleaned
5
+ cowling: Cowling removed
6
+ engine: Engine cleaned
7
+ access: Inspection plates and access doors opened or removed
8
+ fairing: Fairings removed
9
+ groups:
10
+ b:
11
+ title: "Fuselage and hull"
12
+ items:
13
+ b1: [ "Fabric and skin", "for deterioration, distortion, other evidence of failure, and defective or insecure attachment of fittings" ]
14
+ b2: [ "Systems and components", "for improper installation, apparent defects, and unsatisfactory operation" ]
15
+ b3: [ "Envelope, gas bags, ballast tanks and related parts", "for poor condition" ]
16
+ c:
17
+ title: "Cabin and cockpit"
18
+ items:
19
+ c1: [ "Generally", "for uncleanliness and loose equipment that might foul the controls" ]
20
+ c2: [ "Seats and safety belts", "for poor condition and apparent defects" ]
21
+ c3: [ "Windows and windshields", "for deterioration and breakage" ]
22
+ c4: [ "Instruments", "for poor condition, mounting, marking, and (where practicable) improper operation" ]
23
+ c5: [ "Flight and engine controls", "for improper installation and improper operation" ]
24
+ c6: [ "Batteries", "for improper installation and improper charge" ]
25
+ c7: [ "All systems", "for improper installation, poor general condition, apparent and obvious defects, and insecurity of attachment" ]
26
+ d:
27
+ title: "Engine and nacelle"
28
+ items:
29
+ d1: [ "Engine section", "for visual evidence of excessive oil, fuel, or hydraulic leaks, and sources of such leaks" ]
30
+ d2: [ "Studs and nuts", "for improper torquing and obvious defects" ]
31
+ d3: [ "Internal engine", "for cylinder compression and for metal particles or foreign matter on screens and sump drain plugs; with weak compression, for improper internal condition and tolerances" ]
32
+ d4: [ "Engine mount", "for cracks, looseness of mounting, and looseness of engine to mount" ]
33
+ d5: [ "Flexible vibration dampeners", "for poor condition and deterioration" ]
34
+ d6: [ "Engine controls", "for defects, improper travel, and improper safetying" ]
35
+ d7: [ "Lines, hoses, and clamps", "for leaks, improper condition and looseness" ]
36
+ d8: [ "Exhaust stacks", "for cracks, defects, and improper attachment" ]
37
+ d9: [ "Accessories", "for apparent defects in security of mounting" ]
38
+ d10: [ "All systems", "for improper installation, poor general condition, defects, and insecure attachment" ]
39
+ d11: [ "Cowling", "for cracks and defects" ]
40
+ e:
41
+ title: "Landing gear"
42
+ items:
43
+ e1: [ "All units", "for poor condition and insecurity of attachment" ]
44
+ e2: [ "Shock absorbing devices", "for improper oleo fluid level" ]
45
+ e3: [ "Linkages, trusses, and members", "for undue or excessive wear, fatigue, and distortion" ]
46
+ e4: [ "Retracting and locking mechanism", "for improper operation" ]
47
+ e5: [ "Hydraulic lines", "for leakage" ]
48
+ e6: [ "Electrical system", "for chafing and improper operation of switches" ]
49
+ e7: [ "Wheels", "for cracks, defects, and condition of bearings" ]
50
+ e8: [ "Tires", "for wear and cuts" ]
51
+ e9: [ "Brakes", "for improper adjustment" ]
52
+ e10: [ "Floats and skis", "for insecure attachment and obvious or apparent defects" ]
53
+ f:
54
+ title: "Wing and center section"
55
+ items:
56
+ f1: [ "Wing and center section assembly", "for poor general condition, fabric or skin deterioration, distortion, evidence of failure, and insecurity of attachment" ]
57
+ g:
58
+ title: "Empennage"
59
+ items:
60
+ g1: [ "Complete empennage assembly", "for poor general condition, fabric or skin deterioration, distortion, evidence of failure, insecure attachment, improper component installation, and improper component operation" ]
61
+ h:
62
+ title: "Propeller"
63
+ items:
64
+ h1: [ "Propeller assembly", "for cracks, nicks, binds, and oil leakage" ]
65
+ h2: [ "Bolts", "for improper torquing and lack of safetying" ]
66
+ h3: [ "Anti-icing devices", "for improper operations and obvious defects" ]
67
+ h4: [ "Control mechanisms", "for improper operation, insecure mounting, and restricted travel" ]
68
+ i:
69
+ title: "Radio"
70
+ items:
71
+ i1: [ "Radio and electronic equipment", "for improper installation and insecure mounting" ]
72
+ i2: [ "Wiring and conduits", "for improper routing, insecure mounting, and obvious defects" ]
73
+ i3: [ "Bonding and shielding", "for improper installation and poor condition" ]
74
+ i4: [ "Antenna, including trailing antenna", "for poor condition, insecure mounting, and improper operation" ]
75
+ j:
76
+ title: "Miscellaneous"
77
+ items:
78
+ j1: [ "Each installed item not covered above", "for improper installation and improper operation" ]
79
+ close:
80
+ fod: Tools, rags and loose items accounted for (no FOD)
81
+ panels: Inspection plates, access doors and fairings reinstalled and secured
82
+ cowl: Cowling reinstalled and secured
83
+ safety: Safety wire, cotter pins and fasteners checked
84
+ fluids: Oil, brake and hydraulic fluid levels checked and serviced
85
+ docs: Aircraft documents and placards in place (airworthiness, registration, POH, weight and balance)
86
+ leak: "Leak check after the run: fuel, oil, hydraulic, brake and exhaust"
87
+ opck: "Operational check: flight controls, trim, flaps, brakes, lights and avionics"
88
+ elt:
89
+ corr: Battery corrosion
90
+ ctrl: Controls and crash sensor
91
+ inst: Proper installation
92
+ sig: Signal radiation
@@ -47,9 +47,8 @@ module Drive
47
47
  uri = URI "https://api.cloudflare.com/client/v4/zones/#{zone}/purge_cache"
48
48
  response = Net::HTTP.post uri, body.to_json, 'Authorization' => "Bearer #{token}",
49
49
  'Content-Type' => 'application/json'
50
- return if response.is_a? Net::HTTPSuccess
51
-
52
- raise "Cloudflare purge failed: #{response.code} #{response.body}"
50
+ failure = "Cloudflare purge failed: #{response.code} #{response.body}"
51
+ raise failure unless response.is_a? Net::HTTPSuccess
53
52
  end
54
53
 
55
54
  # The zone, from the environment or the credentials.
data/lib/drive/engine.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Drive
2
- # Lends the host its models (Crawler, NNumber, Designation, Serial) and RateLimited.
2
+ # Lends the host its models (Crawler, NNumber, Designation, Serial, Inspection, the refinery's
3
+ # Refined) and RateLimited.
3
4
  class Engine < ::Rails::Engine
4
5
  engine_name 'drive'
5
6
 
data/lib/drive/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Drive
2
2
  # Version of the gem, read by the gemspec.
3
- VERSION = '0.26.0'.freeze
3
+ VERSION = '0.28.0'.freeze
4
4
  end
data/lib/drive.rb CHANGED
@@ -3,7 +3,7 @@ require 'drive/inflections'
3
3
  require 'drive/cloudflare'
4
4
  require 'drive/engine'
5
5
 
6
- # What every easyFAA app in front of Cloudflare needs alike: Drive::Cloudflare, Crawler,
7
- # RateLimited, NNumber, Designation and Serial. What its pages look like is wordmark's.
6
+ # What every easyFAA app in front of Cloudflare needs alike: Drive::Cloudflare, Crawler, RateLimited, NNumber,
7
+ # Designation and Serial; and Inspection, what 14 CFR Part 43 Appendix D lists. What its pages look like is easyfaa's.
8
8
  module Drive
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
@@ -37,8 +37,24 @@ files:
37
37
  - app/controllers/concerns/rate_limited.rb
38
38
  - app/models/crawler.rb
39
39
  - app/models/designation.rb
40
+ - app/models/inspection.rb
40
41
  - app/models/n_number.rb
42
+ - app/models/refined/aircraft.rb
43
+ - app/models/refined/aircraft_engine.rb
44
+ - app/models/refined/appliance.rb
45
+ - app/models/refined/choices.rb
46
+ - app/models/refined/choices/modified.rb
47
+ - app/models/refined/engine.rb
48
+ - app/models/refined/engine_appliance.rb
49
+ - app/models/refined/model.rb
50
+ - app/models/refined/model_appliance.rb
51
+ - app/models/refined/model_engine.rb
52
+ - app/models/refined/modification.rb
53
+ - app/models/refined/modification_appliance.rb
54
+ - app/models/refined/modification_engine.rb
55
+ - app/models/refined/record.rb
41
56
  - app/models/serial.rb
57
+ - config/inspection.yml
42
58
  - lib/drive.rb
43
59
  - lib/drive/cloudflare.rb
44
60
  - lib/drive/engine.rb