gluby-tk 0.1.2 → 0.1.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
  SHA1:
3
- metadata.gz: 0bb8abeea6ca07743b1abcce319ec97bdca8c423
4
- data.tar.gz: 830041b5858c07fe90681e9751b13808dfa007e5
3
+ metadata.gz: df814d914256418a1371666ceccd4e4df8fb5317
4
+ data.tar.gz: 46f945053c302840b0ed4d3815ecf82712b4e733
5
5
  SHA512:
6
- metadata.gz: aee4b78a8a6aa2ede1f6983b4a94b5ab50aa623a1e390ea463ec6ab68159084a241f2fc49c5e281ab5bc5b4d8df0a8d88b5132abb3977c460a79254b3d894a02
7
- data.tar.gz: c12de13b272b6adf3dc6a3b83856b86bf7fc44c390f04dfbc485f51a882777b1b01004f35302ff515969d4444174025d88720c0a6fc443e26547fa3b7c9a61ce
6
+ metadata.gz: bff13c27d15fe3bbf8f35dd5a1fbf217e7083d76d009964c1e7c7a4ececf775ff1d263a2ca58616de41ca44c625550994086b5e615d31b0819fcc8fe913d757d
7
+ data.tar.gz: 61b20596daf636c1c709d4a0d511cdb8bded7184bb88bac869388a256e9b05c9e9d6aff7b026d6576dd866a452987a1c24d8d920ff0e3fa08aafc5245f270af6
data/bin/gluby CHANGED
@@ -19,7 +19,7 @@ require "wannabe_bool"
19
19
  # GlubyTK.hi
20
20
  # end
21
21
 
22
- puts "No commands specified - exiting now..." and exit(0) if ARGV.empty?
22
+ puts "No command specified - exiting now..." and exit(0) if ARGV.empty?
23
23
 
24
24
  if ARGV[0] == "new"
25
25
  if ARGV[1].nil? || ARGV[1].strip.empty?
@@ -8,9 +8,7 @@ module GlubyTK
8
8
  "assets/images",
9
9
  "interface",
10
10
  "src",
11
- "src/model",
12
- "src/view",
13
- "src/controller"
11
+ "src/gluby"
14
12
  ]
15
13
 
16
14
  TEMPLATES = [
@@ -70,9 +68,7 @@ module GlubyTK
70
68
  gresource_file_contents += "<gresource prefix=\"/app/#{current_app_name(root)}\">"
71
69
  gresource_file_contents += "<file preprocess=\"xml-stripblanks\">#{File.basename(filename)}</file>"
72
70
  gresource_file_contents += "</gresource>"
73
- if generate_ruby_classes
74
- generate_ruby_class_for_document(File.basename(filename), File.read(filename), root)
75
- end
71
+ generate_ruby_class_for_document(File.basename(filename), File.read(filename), root, generate_ruby_classes)
76
72
  }
77
73
  gresource_file_contents += "</gresources>\n"
78
74
 
@@ -81,7 +77,7 @@ module GlubyTK
81
77
  }
82
78
  end
83
79
 
84
- def self.generate_ruby_class_for_document(file_name, file_contents, root)
80
+ def self.generate_ruby_class_for_document(file_name, file_contents, root, generate_ruby_classes)
85
81
  doc = Nokogiri::XML(file_contents)
86
82
 
87
83
  if doc.css("template").first.nil?
@@ -96,21 +92,47 @@ module GlubyTK
96
92
 
97
93
  parent = parent.gsub("Gtk","")
98
94
 
99
- class_file_contents = [
100
- "class #{class_name} < Gtk::#{parent}",
95
+ base_file_name = "#{file_name.gsub(File.extname(file_name), "").underscore}"
96
+
97
+ gluby_file_dir = "#{root}/src/gluby"
98
+ gluby_file_path = "#{gluby_file_dir}/gluby_#{base_file_name}.rb"
99
+ gluby_class_file_contents = [
100
+ "class #{class_name.underscore.humanize} < Gtk::#{parent}",
101
101
  "\ttype_register",
102
102
  "\tclass << self",
103
103
  "\t\tdef init",
104
104
  "\t\t\tset_template(:resource => '/app/#{current_app_name(root)}/#{file_name}')",
105
- "\t\t\t#{doc.css("[id]").map{|e| e.attributes["id"].value }.to_s}.each{|child_id| bind_template_child(child_id)}",
105
+ "\t\t\t#{doc.css("[id]").map{|e| e.attributes["id"].value.to_sym }.select{|e| e != class_name.to_sym }}.each{|child_id| bind_template_child(child_id)}",
106
106
  "\t\tend",
107
107
  "\tend",
108
108
  "end"
109
109
  ].join("\n")
110
110
 
111
- new_file_path = "#{root}/src/view/#{file_name.gsub(File.extname(file_name), "").underscore}.rb"
112
- File.open(new_file_path, "w+") { |file|
113
- file.write class_file_contents
111
+ File.open(gluby_file_path, "w+") { |file|
112
+ file.write gluby_class_file_contents
113
+ }
114
+
115
+ if generate_ruby_classes
116
+ file_path = "#{root}/src/#{base_file_name}.rb"
117
+ class_file_contents = [
118
+ "class #{class_name.underscore.humanize}",
119
+ "\tdef initialize(args = nil)",
120
+ "\t\tsuper(args)",
121
+ "\tend",
122
+ "end",
123
+ ].join("\n")
124
+
125
+ File.open(file_path, "w+") { |file|
126
+ file.write class_file_contents
127
+ }
128
+ end
129
+
130
+ File.open("#{gluby_file_dir}/gluby_includes.rb", "a+") { |file|
131
+ contents = file.read
132
+ g_req = "require 'gluby_#{base_file_name}'"
133
+ req = "require '#{base_file_name}'"
134
+ file.write("#{g_req}\n") if contents.match(g_req).nil?
135
+ file.write("#{req}\n") if contents.match(req).nil?
114
136
  }
115
137
  end
116
138
 
@@ -1,3 +1,3 @@
1
1
  module GlubyTK
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  class Application < Gtk::Application
2
2
  def initialize
3
3
  super('app.gluby-tk_app_id', :handles_open)
4
+ GLib.set_application_name('gluby-tk_app_id')
4
5
  signal_connect 'activate' do |application|
5
6
  @window = ApplicationWindow.new(:application => application)
6
7
  @window.present
@@ -1,11 +1,15 @@
1
1
  # Search paths
2
- $: << 'src/model/'
3
- $: << 'src/view/'
4
- $: << 'src/controller/'
5
- $: << 'src/helpers/'
2
+ $: << 'src/gluby/'
6
3
 
7
4
  # Dependencies
8
5
  require 'fileutils'
9
6
  require 'gtk3'
10
- require 'application_window'
7
+
8
+ # Include all auto-generated gluby helpers - do not remove
9
+ require 'gluby_includes'
10
+
11
+ # User Defined - Require any custom files here
12
+ # ...
13
+
14
+ # Application
11
15
  require 'application'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gluby-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2097i
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler