glimmer-dsl-libui 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3ad3f4e1a2e367a8e95fba05f1b539f2aa865dfab7e2234541933be97dda171
4
- data.tar.gz: 44255036ce4a887224c84f861d0654483bada4ff8ed3c2a1c4192083a19cf45b
3
+ metadata.gz: f0fd65bf048edb4ec2556097bcbbe82b2dd2c1411e6a2c81d592901a40fdcf0f
4
+ data.tar.gz: 4e48a01e498afdf21fc72a82891106e8198360eeea971f98663e585b6c2ba6d1
5
5
  SHA512:
6
- metadata.gz: e018c132e8b838ce839adeaae9d812d52ab8be960b87a8d3e5c85cf8045d988b83495640fb4bef7cb778960d2f25b7da8fcf4d659bd8ada7ed8277d26cc9ff9f
7
- data.tar.gz: 3fb97e3a7946c9690c0bd48fdbee89d65f99833b11bd9b033c21b099e51f394b98d1aa96c4c51b9e0445c309a5b28f4f272c53174617e20b4e578dc602338c5a
6
+ metadata.gz: 45492206e1c62e3daf5199a6551029300a8f73a8fdf1cf40b38a3efdaddc49f8b123c18ae61c2b233ed2c19272aa9661c35043b2adccc2cc4f487f004486e8a1
7
+ data.tar.gz: 0c2b32d5c933da94e99f07926491d1423b29e36b91ad8e2a207472d5235d199a7761f9d768ce7a4eea02287515837aa4c35c0aeb6ed9b1d5c21d387fd796e9c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.3
4
+
5
+ - Application Scaffolding via `glimmer scaffold[app_name]` includes a Model layer
6
+
3
7
  ## 0.9.2
4
8
 
5
9
  - Add `glimmer` commands `glimmer package:gem`, `glimmer package:gemspec`, and `glimmer package:clean`
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.9.2
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.9.3
2
2
  ## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -421,7 +421,7 @@ gem install glimmer-dsl-libui
421
421
  Or install via Bundler `Gemfile`:
422
422
 
423
423
  ```ruby
424
- gem 'glimmer-dsl-libui', '~> 0.9.2'
424
+ gem 'glimmer-dsl-libui', '~> 0.9.3'
425
425
  ```
426
426
 
427
427
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -645,6 +645,7 @@ Created hello_world/Gemfile
645
645
  Created hello_world/Rakefile
646
646
  Created hello_world/app/hello_world.rb
647
647
  Created hello_world/app/hello_world/view/hello_world.rb
648
+ Created hello_world/app/hello_world/model/greeting.rb
648
649
  Created hello_world/icons/windows/Hello World.ico
649
650
  Created hello_world/icons/macosx/Hello World.icns
650
651
  Created hello_world/icons/linux/Hello World.png
@@ -655,6 +656,7 @@ Created hello_world/bin/hello_world
655
656
  They include a basic Hello, World! application with menus and about/preferences dialogs.
656
657
 
657
658
  Views live under `app/app_name/view` (e.g. `app/hello_world/view`)
659
+
658
660
  Models live under `app/app_name/model` (e.g. `app/hello_world/model`)
659
661
 
660
662
  Once you step into the application directory, you can run it in one of multiple ways:
@@ -681,7 +683,9 @@ glimmer run
681
683
 
682
684
  ![glimmer-dsl-libui-mac-scaffold-app-changed-greeting.png](images/glimmer-dsl-libui-mac-scaffold-app-changed-greeting.png)
683
685
 
684
- The application comes with `juwelier` for auto-generating an application gem from its `Rakefile` gem configuration.
686
+ ![glimmer-dsl-libui-mac-scaffold-app-about.png](images/glimmer-dsl-libui-mac-scaffold-app-about.png)
687
+
688
+ The application comes with the [juwelier](https://rubygems.org/gems/juwelier) gem for auto-generating an application gem from the app `Rakefile` and `Gemfile` configuration (no need to manually declare gems in a gemspec... just use `Gemfile` normally and [juwelier](https://rubygems.org/gems/juwelier) takes care of the rest by generating an app gemspec automatically from `Gemfile`).
685
689
 
686
690
  You can package the newly scaffolded app as a Ruby gem by running this command:
687
691
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
Binary file
@@ -155,6 +155,7 @@ module Glimmer
155
155
  mkdir_p "app/#{file_name(app_name)}/model"
156
156
  mkdir_p "app/#{file_name(app_name)}/view"
157
157
  custom_window(class_name(app_name), current_dir_name, window_type, custom_window_class_name: 'Application')
158
+ application_model(current_dir_name)
158
159
 
159
160
  mkdir_p 'icons/windows'
160
161
  icon_file = "icons/windows/#{human_name(app_name)}.ico"
@@ -366,6 +367,16 @@ module Glimmer
366
367
  puts 'Run `rake build` to build gem.'
367
368
  puts 'Run `rake release` to release into rubygems.org once ready.'
368
369
  end
370
+
371
+ def application_model(current_dir_name)
372
+ model_name = 'Greeting'
373
+ namespace ||= current_dir_name
374
+ root_dir = File.exist?('app') ? 'app' : 'lib'
375
+ parent_dir = "#{root_dir}/#{file_name(namespace)}/model"
376
+ return puts("The file '#{parent_dir}/#{file_name(model_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(model_name)}.rb")
377
+ mkdir_p parent_dir unless File.exist?(parent_dir)
378
+ write "#{parent_dir}/#{file_name(model_name)}.rb", model_file(model_name, namespace)
379
+ end
369
380
 
370
381
  private
371
382
 
@@ -527,7 +538,16 @@ module Glimmer
527
538
  window_options[:custom_window_class_name] ||= 'CustomWindow'
528
539
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
529
540
 
530
- custom_window_file_content = <<-MULTI_LINE_STRING
541
+ custom_window_file_content = ''
542
+
543
+ if %i[gem app].include?(window_type)
544
+ custom_window_file_content += <<-MULTI_LINE_STRING
545
+ require '#{current_dir_name}/model/greeting'
546
+
547
+ MULTI_LINE_STRING
548
+ end
549
+
550
+ custom_window_file_content += <<-MULTI_LINE_STRING
531
551
  #{namespace_type} #{class_name(namespace)}
532
552
  module View
533
553
  class #{class_name(custom_window_name)}
@@ -543,15 +563,6 @@ module Glimmer
543
563
  MULTI_LINE_STRING
544
564
  end
545
565
 
546
- if %i[gem app].include?(window_type)
547
- custom_window_file_content += <<-MULTI_LINE_STRING
548
- GREETINGS = [
549
- 'Hello, World!',
550
- 'Howdy, Partner!'
551
- ]
552
- MULTI_LINE_STRING
553
- end
554
-
555
566
  custom_window_file_content += <<-MULTI_LINE_STRING
556
567
 
557
568
  ## Add options like the following to configure CustomWindow by outside consumers
@@ -561,14 +572,6 @@ module Glimmer
561
572
  # option :height, default: 240
562
573
  MULTI_LINE_STRING
563
574
 
564
- if %i[gem app].include?(window_type)
565
- custom_window_file_content += <<-MULTI_LINE_STRING
566
-
567
- # GREETING Array selected index
568
- option :greeting_index, default: 0
569
- MULTI_LINE_STRING
570
- end
571
-
572
575
  custom_window_file_content += <<-MULTI_LINE_STRING
573
576
 
574
577
  ## Use before_body block to pre-initialize variables to use in body and
@@ -579,6 +582,8 @@ module Glimmer
579
582
  if %i[gem app].include?(window_type)
580
583
  custom_window_file_content += <<-MULTI_LINE_STRING
581
584
  before_body do
585
+ @greeting = Model::Greeting.new
586
+
582
587
  menu('File') {
583
588
  menu_item('Preferences...') {
584
589
  on_clicked do
@@ -634,7 +639,7 @@ module Glimmer
634
639
  margined true
635
640
 
636
641
  label {
637
- text <= [self, :greeting_index, on_read: -> { greeting }]
642
+ text <= [@greeting, :text]
638
643
  }
639
644
  }
640
645
  }
@@ -643,10 +648,6 @@ module Glimmer
643
648
  if %i[gem app].include?(window_type)
644
649
  custom_window_file_content += <<-MULTI_LINE_STRING
645
650
 
646
- def greeting
647
- GREETINGS[greeting_index]
648
- end
649
-
650
651
  def display_about_dialog
651
652
  message = "#{human_name(namespace)}#{" - #{human_name(custom_window_name)}" if window_type == :gem} \#{VERSION}\\n\\n\#{LICENSE}"
652
653
  msg_box('About', message)
@@ -674,8 +675,8 @@ module Glimmer
674
675
  radio_buttons {
675
676
  stretchy false
676
677
 
677
- items GREETINGS
678
- selected <=> [self, :greeting_index]
678
+ items Model::Greeting::GREETINGS
679
+ selected <=> [@greeting, :text_index]
679
680
  }
680
681
  }
681
682
  }.show
@@ -790,6 +791,37 @@ end
790
791
  MULTI_LINE_STRING
791
792
  end
792
793
 
794
+ def model_file(model_name, namespace)
795
+ namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
796
+
797
+ <<-MULTI_LINE_STRING
798
+ #{namespace_type} #{class_name(namespace)}
799
+ module Model
800
+ class #{class_name(model_name)}
801
+ GREETINGS = [
802
+ 'Hello, World!',
803
+ 'Howdy, Partner!'
804
+ ]
805
+
806
+ attr_accessor :text
807
+
808
+ def initialize
809
+ @text = GREETINGS.first
810
+ end
811
+
812
+ def text_index=(new_text_index)
813
+ self.text = GREETINGS[new_text_index]
814
+ end
815
+
816
+ def text_index
817
+ GREETINGS.index(text)
818
+ end
819
+ end
820
+ end
821
+ end
822
+ MULTI_LINE_STRING
823
+ end
824
+
793
825
  end
794
826
 
795
827
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-20 00:00:00.000000000 Z
11
+ date: 2023-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer