gluby-tk 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 88bdbec6a3b26aeaaedbef372b27927afbae8b4f
4
- data.tar.gz: 2192394b9cefcc9e37d9528e7a97ba2ce89218bc
3
+ metadata.gz: 0bb8abeea6ca07743b1abcce319ec97bdca8c423
4
+ data.tar.gz: 830041b5858c07fe90681e9751b13808dfa007e5
5
5
  SHA512:
6
- metadata.gz: f026a3bee2456fb7e92ae94f22836d83264400b88f79c663c261617aed073bc1c7ada621e3d9c521e1cab624c1f2f65daa6678b608e22cad783f63a93e2fe51c
7
- data.tar.gz: fce9719f976b68e9df469b248874ef173c0f84d7ec01fdf26692f439b61cdf5544365089762fb2a84313120e9f0a3ca76b84023b4723b5b7dd476c2ffcfc6fe3
6
+ metadata.gz: aee4b78a8a6aa2ede1f6983b4a94b5ab50aa623a1e390ea463ec6ab68159084a241f2fc49c5e281ab5bc5b4d8df0a8d88b5132abb3977c460a79254b3d894a02
7
+ data.tar.gz: c12de13b272b6adf3dc6a3b83856b86bf7fc44c390f04dfbc485f51a882777b1b01004f35302ff515969d4444174025d88720c0a6fc443e26547fa3b7c9a61ce
@@ -1,5 +1,5 @@
1
1
  class String
2
- DISALLOWED_CHARACTERS = "[\-\s\.\,\?\'\"\:\;\\\/]"
2
+ DISALLOWED_CHARACTERS = /[\-\_\s.,?\'\":\/;\\]/
3
3
 
4
4
  def humanize
5
5
  gsub(DISALLOWED_CHARACTERS, " ").split(" ").map(&:capitalize).join("")
@@ -7,12 +7,28 @@ class String
7
7
 
8
8
  def underscore
9
9
  u = ""
10
- sanitize.split("").each_with_index do |c, i|; if i > 0 && c == c.upcase; u += " "; end; u += c.downcase; end;
11
- u.gsub(" ", "_")
10
+ chars = sanitize.split("")
11
+ unless chars.count == 0
12
+ while chars.first.match(DISALLOWED_CHARACTERS)
13
+ chars.delete_at(0)
14
+ end
15
+
16
+ while chars.last.match(DISALLOWED_CHARACTERS)
17
+ chars.delete_at(chars.count - 1)
18
+ end
19
+ end
20
+
21
+ chars.each_with_index do |c, i|
22
+ if c.match(/[A-Za-z]/) && i > 0 && c == c.upcase
23
+ u += " "
24
+ end
25
+ u += c.downcase
26
+ end
27
+ u.gsub(/\s/, "_")
12
28
  end
13
29
 
14
30
  def sanitize
15
- gsub(DISALLOWED_CHARACTERS, "_")
31
+ gsub(/_{2,}/, "_").gsub(DISALLOWED_CHARACTERS, "_")
16
32
  end
17
33
 
18
34
  end
@@ -3,6 +3,23 @@ require 'pp'
3
3
 
4
4
  module GlubyTK
5
5
  class Generator
6
+ DIRECTORIES = [
7
+ "assets",
8
+ "assets/images",
9
+ "interface",
10
+ "src",
11
+ "src/model",
12
+ "src/view",
13
+ "src/controller"
14
+ ]
15
+
16
+ TEMPLATES = [
17
+ {:name => "main.rb", :path => ""},
18
+ {:name => "includes.rb", :path => "src"},
19
+ {:name => "application.rb", :path => "src"},
20
+ {:name => "ApplicationWindow.glade", :path => "interface"}
21
+ ]
22
+
6
23
  def self.create app_name
7
24
  if File.exist?(app_name)
8
25
  puts "#{app_name} already exists!"
@@ -10,51 +27,31 @@ module GlubyTK
10
27
  end
11
28
 
12
29
  root = "#{Dir.pwd}/#{app_name}"
13
- directories = [
14
- "assets",
15
- "assets/images",
16
- "interface",
17
- "src",
18
- "src/model",
19
- "src/view",
20
- "src/controller"
21
- ]
30
+
31
+ module_name = "#{app_name.underscore}"
32
+
33
+ app_id = module_name.humanize.downcase
22
34
 
23
35
  # Create root directory
24
36
  Dir.mkdir "#{Dir.pwd}/#{app_name}"
25
37
 
38
+ # Create gluby-tkrc file
39
+ File.open("#{root}/.gluby-tkrc", "w+") { |file|
40
+ file.write(module_name)
41
+ }
42
+
26
43
  # Create sub-directories
27
- directories.each do |dir|
44
+ DIRECTORIES.each do |dir|
28
45
  Dir.mkdir "#{root}/#{dir}"
29
46
  end
30
47
 
31
- # Create includes file
32
- File.open("#{root}/src/includes.rb", "w+") { |file|
33
- file.write(get_template_contents("includes.rb.template"))
34
- }
48
+ # Generate files from templates
49
+ TEMPLATES.each do |template|
50
+ File.open("#{root}/#{template[:path]}/#{template[:name]}", "w+") { |file|
51
+ file.write(get_template_contents("#{template[:name]}.template").gsub("gluby-tk_app_id", app_id))
52
+ }
53
+ end
35
54
 
36
- # Create app entry point
37
- module_name = "#{app_name.underscore}"
38
- app_id = module_name.humanize.downcase
39
-
40
- main_file = "#{root}/#{module_name}.rb"
41
- File.open(main_file, "w+") { |file|
42
- file.write(get_template_contents("boot.rb.template"))
43
- }
44
- File.open("#{root}/.gluby-tkrc", "w+") { |file|
45
- file.write(module_name)
46
- }
47
-
48
- # Create Application
49
- File.open("#{root}/src/application.rb", "w+") { |file|
50
- file.write(get_template_contents("application.rb.template").gsub("gluby-tk_app_id", app_id))
51
- }
52
-
53
- # Make initial application window
54
- File.open("#{root}/interface/ApplicationWindow.glade", "w+") { |file|
55
- file.write(get_template_contents("ApplicationWindow.glade.template"))
56
- }
57
-
58
55
  rebuild(root, true)
59
56
  end
60
57
 
@@ -1,3 +1,3 @@
1
1
  module GlubyTK
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,7 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <!-- Generated with glade 3.20.0 -->
3
2
  <interface>
4
- <requires lib="gtk+" version="3.20"/>
5
3
  <template class="ApplicationWindow" parent="GtkApplicationWindow">
6
4
  <property name="can_focus">False</property>
7
5
  <property name="window_position">center</property>
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2097i
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.5.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.5.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: gtk3
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -95,8 +109,8 @@ files:
95
109
  - lib/gluby-tk/version.rb
96
110
  - templates/ApplicationWindow.glade.template
97
111
  - templates/application.rb.template
98
- - templates/boot.rb.template
99
112
  - templates/includes.rb.template
113
+ - templates/main.rb.template
100
114
  homepage: https://github.com/i2097i/gluby-tk
101
115
  licenses:
102
116
  - MIT
@@ -117,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  version: '0'
118
132
  requirements: []
119
133
  rubyforge_project:
120
- rubygems_version: 2.5.1
134
+ rubygems_version: 2.4.8
121
135
  signing_key:
122
136
  specification_version: 4
123
137
  summary: Ruby+GTK+Glade