Class: QMK::Firmware
- Inherits:
-
Object
- Object
- QMK::Firmware
- Defined in:
- lib/firmware.rb
Instance Method Summary collapse
- #checkout_stable ⇒ Object
-
#initialize(keyboard, keymap, config) ⇒ Firmware
constructor
A new instance of Firmware.
- #keyboards ⇒ Object
- #make(target = nil) ⇒ Object
- #programmer ⇒ Object
- #qmk_keyboards(keymap = nil) ⇒ Object
- #setup ⇒ Object
- #standalone_keyboards ⇒ Object
- #update ⇒ Object
- #update_submodules ⇒ Object
Constructor Details
#initialize(keyboard, keymap, config) ⇒ Firmware
Returns a new instance of Firmware.
11 12 13 14 15 16 17 18 19 |
# File 'lib/firmware.rb', line 11 def initialize(keyboard, keymap, config) @config = config @keyboard = keyboard @qmk_keyboard = get_keyboard keyboard @keymap = get_keymap(keyboard) || keymap @repo = Git.new(LIB_PATH) end |
Instance Method Details
#checkout_stable ⇒ Object
45 46 47 48 49 50 |
# File 'lib/firmware.rb', line 45 def checkout_stable in_repo do @repo.fetch_origin @repo.checkout_latest_tag end end |
#keyboards ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/firmware.rb', line 59 def keyboards if @config[:standalone_keymaps] standalone_keyboards else qmk_keyboards @keymap end end |
#make(target = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/firmware.rb', line 21 def make(target = nil) if @config[:standalone_keymaps] prepare_firmware end in_repo do run "make #{make_target(target)}" end end |
#programmer ⇒ Object
86 87 88 |
# File 'lib/firmware.rb', line 86 def programmer Programmer.new(keyboard_path).flasher end |
#qmk_keyboards(keymap = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/firmware.rb', line 73 def qmk_keyboards(keymap = nil) Dir["#{keyboards_path}/**/#{keymap}/keymap.c"] .map {|path| File.dirname(path) .gsub(keyboards_path, '') .split('/') .reject(&:empty?) .first } .uniq .sort end |
#setup ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/firmware.rb', line 31 def setup @repo.clone 'https://github.com/qmk/qmk_firmware.git' in_repo do @repo.checkout_latest_tag end end |
#standalone_keyboards ⇒ Object
67 68 69 70 71 |
# File 'lib/firmware.rb', line 67 def standalone_keyboards Dir["**/keymap.c"] .map {|path| File.dirname(path) } .sort end |
#update ⇒ Object
52 53 54 55 56 57 |
# File 'lib/firmware.rb', line 52 def update in_repo do @repo.clean checkout_stable end end |
#update_submodules ⇒ Object
39 40 41 42 43 |
# File 'lib/firmware.rb', line 39 def update_submodules in_repo do run "make git-submodule" end end |