gluby-tk 0.1.8 → 0.1.9

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: b8fd6875edb76324c7c4ed17ae1624498cdfad7b
4
- data.tar.gz: 6933dfccd9966b6b72ea09fbac9bec703461f06d
3
+ metadata.gz: 04a9d5feb2582bd6a2ad93c493264a379db2c62b
4
+ data.tar.gz: ec51208086f8b60c5329947e013413d0b4bbb915
5
5
  SHA512:
6
- metadata.gz: bcb2770a385c66b61bddde42d6709ef669829f15bed117398ffe328adcf9ed4222b2d14ccf7e86948730c3d1f1c4211af6fead59b249da123ae7dafe24203f70
7
- data.tar.gz: 2e0b04df29b294494324aaba83cd2cc3bb7e188b5faf1cff5e083b3c1d3eff0bf3564d3c5fece4dbc64f4601e433a3398d30eba0c1ab2af70434507917d699ed
6
+ metadata.gz: 4885d5302d4f4995c466d296c5a02c9593e4fbad0ced1bcc6e521217533d9d2f931915206c9779e141f432e7034ac8d56d880f4659fa5e77fe16eec929a272e0
7
+ data.tar.gz: 655f3ecefd9bfddb8b32b2f103afaf16da392cc4a256935bc560659e0282ccebff71191fe2599c1838af1c97460e1535f8178b811fd6f15958bc2a188d59a3a5
@@ -4,6 +4,7 @@ require "gluby-tk/logger"
4
4
  require "gluby-tk/generator"
5
5
  require "gluby-tk/listener"
6
6
  require "gluby-tk/tweeter"
7
+ require "gluby-tk/file_operator"
7
8
 
8
9
  module GlubyTK
9
10
 
@@ -0,0 +1,38 @@
1
+ module GlubyTK
2
+ class FileOperator
3
+ def self.add_lines_to_file(path, lines = [], after_line_match = nil)
4
+ unless after_line_match.nil?
5
+ new_contents = ""
6
+ get_io_contents(path).each do |line|
7
+ new_contents << line
8
+ if line.include?(after_line_match)
9
+ lines.each do |l|
10
+ new_contents << l
11
+ end
12
+ end
13
+ end
14
+ write_file path, new_contents
15
+ end
16
+ end
17
+
18
+ def self.file_contains_line?(path, line_match)
19
+ get_io_contents(path).each do |line|
20
+ return true if line.include?(line_match)
21
+ end
22
+ false
23
+ end
24
+
25
+ private
26
+
27
+ def self.get_io_contents(path)
28
+ if File.exist?(path)
29
+ return StringIO.open(File.read(path))
30
+ end
31
+ nil
32
+ end
33
+
34
+ def self.write_file(path, contents)
35
+ File.open(path, "wb").write contents
36
+ end
37
+ end
38
+ end
@@ -72,34 +72,20 @@ module GlubyTK
72
72
  rebuild(root)
73
73
 
74
74
  # Add in example code
75
- add_sample_code_to_new_project root
75
+ GlubyTK::FileOperator.add_lines_to_file("#{root}/#{DIR_SRC}/application_window.rb", SAMPLE_CODE_LINES.map{|scl| "\t\t#{scl}\n"}, "super(args")
76
76
 
77
77
  GlubyTK.gputs "Finished creating #{module_name}"
78
78
  GlubyTK.gputs "Done!"
79
79
  end
80
80
 
81
- def self.add_sample_code_to_new_project(root)
82
- app_window_path = "#{root}/#{DIR_SRC}/application_window.rb"
83
- contents = StringIO.open(File.read(app_window_path))
84
- new_contents = ""
85
- contents.each do |line|
86
- new_contents << line
87
- if line.include?("super(args)")
88
- tab = "\t\t"
89
- nl = "\n"
90
- SAMPLE_CODE_LINES.each do |scl|
91
- new_contents << "#{tab}#{scl}#{nl}"
92
- end
93
- end
94
- end
95
- File.open(app_window_path, "wb").write new_contents
96
- end
97
-
98
81
  def self.rebuild(root = nil)
99
82
  GlubyTK.gputs "Constructing gresource file..."
100
83
  root = root || Dir.pwd
101
84
 
102
85
  interface_files = Dir["#{root}/interface/*.glade"]
86
+
87
+ gluby_class_matcher = "#{root}/src/gluby/gluby_*.rb"
88
+ system("rm #{gluby_class_matcher}") if Dir[gluby_class_matcher].any?
103
89
 
104
90
  gresource_file_contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
105
91
  gresource_file_contents += "<gresources>\n"
@@ -174,7 +160,7 @@ module GlubyTK
174
160
  }
175
161
  end
176
162
 
177
- File.open("#{gluby_file_dir}/gluby_includes.rb", "a+") { |file|
163
+ File.open("#{gluby_file_dir}/gluby_includes.rb", "w+") { |file|
178
164
  contents = file.read
179
165
  g_req = "require 'gluby_#{base_file_name}'"
180
166
  req = "require '#{base_file_name}'"
@@ -15,7 +15,7 @@ module GlubyTK
15
15
  config.access_token = ENV["ACCESS_TOKEN"]
16
16
  config.access_token_secret = ENV["ACCESS_SECRET"]
17
17
  end
18
- client.update("Version #{GlubyTK::VERSION} has just been released! Check it out at https://rubygems.org/gems/gluby-tk")
18
+ client.update("#{GlubyTK::VERSION} changes: #{GlubyTK::RELEASE_NOTES}")
19
19
  end
20
20
  end
21
21
  end
@@ -1,3 +1,4 @@
1
1
  module GlubyTK
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
+ RELEASE_NOTES = "Added better maintenance of gluby includes file and created a file helper class"
3
4
  end
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.8
4
+ version: 0.1.9
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-05 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,6 +133,7 @@ files:
133
133
  - bin/gluby
134
134
  - lib/core_ext/string.rb
135
135
  - lib/gluby-tk.rb
136
+ - lib/gluby-tk/file_operator.rb
136
137
  - lib/gluby-tk/generator.rb
137
138
  - lib/gluby-tk/listener.rb
138
139
  - lib/gluby-tk/logger.rb