build-tool 0.6.3 → 0.6.4

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.
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- build-tool (0.6.2)
4
+ build-tool (0.6.4)
5
5
  activerecord (>= 3.2.1)
6
6
  ansi (>= 1.4.2)
7
7
  grit (>= 2.4.1)
8
+ inifile (>= 1.1.0)
8
9
  logging (>= 1.6.0)
9
10
  sqlite3 (>= 1.3.5)
10
11
 
@@ -26,22 +27,25 @@ GEM
26
27
  arel (3.0.2)
27
28
  builder (3.0.0)
28
29
  diff-lcs (1.1.3)
29
- grit (2.4.1)
30
+ grit (2.5.0)
30
31
  diff-lcs (~> 1.1)
31
32
  mime-types (~> 1.15)
33
+ posix-spawn (~> 0.3.6)
32
34
  i18n (0.6.0)
35
+ inifile (1.1.0)
33
36
  little-plugger (1.1.3)
34
37
  logging (1.7.2)
35
38
  little-plugger (>= 1.1.3)
36
39
  mime-types (1.18)
37
- multi_json (1.2.0)
40
+ multi_json (1.3.6)
41
+ posix-spawn (0.3.6)
38
42
  racc (1.4.7)
39
43
  rake (0.9.2.2)
40
44
  rexical (1.0.5)
41
- sqlite3 (1.3.5)
45
+ sqlite3 (1.3.6)
42
46
  turn (0.9.3)
43
47
  ansi
44
- tzinfo (0.3.32)
48
+ tzinfo (0.3.33)
45
49
  yard (0.7.5)
46
50
 
47
51
  PLATFORMS
data/History.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ == Version 0.6.4
2
+ === Enhancements
3
+ - Check for xdg-open before using it and give error message if missing.
4
+ - Give error message if opening the editor fails.
5
+ - Changed file format for <tt>configuration edit</tt> from yaml to ini file. Easier to read for
6
+ humans.
7
+
8
+ === Bugfixes
9
+ - Fix <tt>recipe install</tt> creating an invalid link on <tt>ruby19</tt> systems.
10
+ - Set build directory as working directory for <tt>module shell</tt> as advertised.
11
+ - Fix editor beeing hardcoded to <tt>gvim -f</tt>. Tries VISUAL, GUIEDITOR (both when DISPLAY set)
12
+ and EDITOR now.
13
+
1
14
  == Version 0.6.3
2
15
  === Enhancements
3
16
  - <tt>module shell<</tt>: Add <tt>--batch</tt> option.
data/build-tool.gemspec CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_dependency( 'sqlite3', '>= 1.3.5' ) # SQLite Database Support
34
34
  s.add_dependency( 'ansi', '>= 1.4.2' ) # ANSI Codes at your Fingertips
35
35
  s.add_dependency( 'grit', '>= 2.4.1' ) # Git Support
36
+ s.add_dependency( 'inifile', '>= 1.1.0' ) # INI File
36
37
 
37
38
  # Development Dependencies
38
39
  s.add_development_dependency( 'racc', '>= 1.4.7' ) # A LALR(1) parser generator.
@@ -73,7 +73,7 @@ def do_execute( args )
73
73
 
74
74
  def do_execute_module( mod )
75
75
  verbose "> #{@command}"
76
- rc = mod.shell( @command, { detach: @detach } )
76
+ rc = mod.shell( @command, { detach: @detach, wd: mod.build_directory } )
77
77
  verbose "> #{rc}" if not @detach
78
78
  verbose "> send to background" if @detach
79
79
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'build-tool/commands'
4
4
  require 'build-tool/recipe'
5
+ require 'mj/path'
5
6
 
6
7
  require 'fileutils'
7
8
 
@@ -47,15 +48,15 @@ def do_execute( args )
47
48
 
48
49
  if @global
49
50
  if @browser
50
- system( 'xdg-open %s' % [ rec.global_path ] )
51
+ MJ::Path::open( rec.global_path )
51
52
  else
52
- system( 'xdg-open %s' % [ rec.global_config_file_path( 'recipe' ) ] )
53
+ MJ::Path::open( rec.global_config_file_path( 'recipe' ) )
53
54
  end
54
55
  else
55
56
  if @browser
56
- system( 'xdg-open %s' % [ rec.local_path() ] )
57
+ MJ::Path::open( rec.local_path() )
57
58
  else
58
- system( 'xdg-open %s' % [ rec.local_config_file_path( 'recipe' ) ] )
59
+ MJ::Path::open( rec.local_config_file_path( 'recipe' ) )
59
60
  end
60
61
  end
61
62
  return 0
@@ -43,10 +43,9 @@ def do_execute(args)
43
43
  exename = "#{commandname}-build"
44
44
  conffile = Application::instance.local_configuration_dir.join("#{commandname}.yaml")
45
45
 
46
- # Our executable
47
- buildtool = Application::instance.application_root.join(
48
- 'bin',
49
- Pathname.new( $0 ).basename ).to_s
46
+ # Our executable. We use $0 directly here to pick up any rubygem wrapper that could
47
+ # exists. But we use realpath to skip any unnecessary link
48
+ buildtool = Pathname.new( $0 ).realpath()
50
49
 
51
50
  # Load the recipe
52
51
  recipe = Recipe.find_recipe(recipename)
@@ -98,7 +97,7 @@ def do_execute(args)
98
97
  error( "a symbolic link in a directory that is part of $PATH yourself." )
99
98
  error( "> ln -s #{buildtool} #{exename}" )
100
99
  else
101
- File.symlink(buildtool, Pathname.new(dir).join(exename))
100
+ File.symlink( buildtool, link )
102
101
  end
103
102
  end
104
103
 
@@ -21,6 +21,9 @@
21
21
  require 'build-tool/build-system/kdel10n'
22
22
  require 'build-tool/build-system/qmake'
23
23
 
24
+ require 'stringio'
25
+ require 'inifile'
26
+
24
27
 
25
28
  module BuildTool
26
29
 
@@ -32,15 +35,36 @@ def self.edit( only = [] )
32
35
  BuildTool::Application.instance.configuration.settings,
33
36
  only )
34
37
 
35
- editor = MJ::Tools::TmpFileEditor.new( YAML::dump( settings ) )
38
+ text = StringIO.new
39
+ settings.each do |s|
40
+ text << '# ' << s[:description].gsub( /\n(?!\z)/, "\n# " )
41
+ text << s[:name] << ' = ' << s[:value]
42
+ text << "\n"
43
+ text << "\n"
44
+ end
45
+
46
+ editor = MJ::Tools::TmpFileEditor.new( text.string )
36
47
 
48
+ # Give the user the possibility to edit the file
37
49
  editor.edit()
38
50
  if not Pathname.new( editor.path() ).exist?
39
- info( "File deleted!" )
51
+ logger.info( "File deleted!" )
40
52
  return 0
41
53
  end
42
- values = YAML::load( File.open( editor.path(), 'r:UTF-8' ) )
43
54
 
55
+ # Reparse it
56
+ values = Array.new
57
+ file = IniFile.new( editor.path() )
58
+ file.each do | section, param, value |
59
+ if section != 'global'
60
+ logger.error( 'section is not global?' )
61
+ end
62
+ values << {
63
+ name: param,
64
+ value: value }
65
+ end
66
+
67
+ # Write it back
44
68
  BuildTool::Setting::import(
45
69
  BuildTool::Application.instance.configuration.settings,
46
70
  values )
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'active_record'
4
4
 
5
+ # This class uses the active_record logger !!!!!!!!!!!!!!!!
6
+
5
7
  module BuildTool
6
8
 
7
9
  class Setting < ActiveRecord::Base
@@ -64,7 +66,7 @@ def import( settings, new )
64
66
  s = settings[v[:name]]
65
67
  if s.value != v[:value]
66
68
  s.value = v[:value]
67
- logger.info( 'Setting %s to "%s"' % [ s.name, s.value ] )
69
+ Logging.logger.root.info( 'Setting %s to "%s"' % [ s.name, s.value ] )
68
70
  s.save!
69
71
  end
70
72
  end
@@ -26,5 +26,5 @@ def recipe_version()
26
26
 
27
27
  end
28
28
 
29
- VERSION = Version.new( 0, 6, 3 )
29
+ VERSION = Version.new( 0, 6, 4 )
30
30
  end
data/lib/mj/path.rb ADDED
@@ -0,0 +1,41 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ module MJ;
4
+
5
+ #
6
+ # Utility functions to work with PATH
7
+ #
8
+ module Path;
9
+
10
+ #
11
+ # Open the given +path+ in a file browser with +xdg-open+.
12
+ #
13
+ # Will print an error if xdg-open is not found.
14
+ #
15
+ # @param [#to_s] Pathname to open.
16
+ def Path.open( path )
17
+ if Path.which( 'xdg-open' ).nil?
18
+ logger.error( 'xdg-open is not available.' )
19
+ end
20
+ if system( 'xdg-open %s' % [ path ] ).nil?
21
+ logger.error( 'xdg-open failed to start' )
22
+ end
23
+ end
24
+
25
+
26
+ #
27
+ # Find +cmd+ in environment variable +$PATH+
28
+ #
29
+ def Path.which( cmd )
30
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
31
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
32
+ exts.each { |ext|
33
+ exe = "#{path}/#{cmd}#{ext}"
34
+ return exe if File.executable? exe
35
+ }
36
+ end
37
+ return nil
38
+ end
39
+
40
+
41
+ end; end # module MJ::Path
@@ -1,9 +1,34 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
 
3
+ require 'mj/path'
3
4
  require 'tempfile'
4
5
 
5
6
  module MJ; module Tools
6
7
 
8
+ @@editor = nil
9
+
10
+ # Look for a suitable editor in the users environment.
11
+ #
12
+ # We check
13
+ # 1. +$VISUAL+ (if +$DISPLAY+ is set)
14
+ # 2. +$GUIEDITOR+ (if +$DISPLAY+ is set)
15
+ # 3. +$EDITOR+
16
+ # 4. Giving up
17
+ # The result is cached.
18
+ def Tools.editor()
19
+ return @@editor if @@editor
20
+ logger.debug( 'Looking for a editor.' )
21
+
22
+ if ENV.include?( 'DISPLAY' )
23
+ logger.debug( 'Checking $VISUAL' )
24
+ return @@editor = ENV['VISUAL'] if ENV.include?( 'VISUAL' )
25
+ logger.debug( 'Checking $GUIEDITOR' )
26
+ return @@editor = ENV['GUIEDITOR'] if ENV.include?( 'GUIEDITOR' )
27
+ end
28
+ logger.debug( 'Checking $EDITOR' )
29
+ return @@editor = ENV['EDITOR'] if ENV.include?( 'EDITOR' )
30
+ end
31
+
7
32
  # A class that puts the given content in a tmpfile, opens an editor for the user to play with
8
33
  # it. After the user closed the editor it will give back the new content.
9
34
  class TmpFileEditor
@@ -15,13 +40,19 @@ def initialize( content )
15
40
  @file.close()
16
41
  end
17
42
 
18
- def editor()
19
- "gvim -f"
20
- end
21
-
22
43
  def edit()
23
- system( "#{editor()} #{@file.path}" )
24
- return $? == 0
44
+ # Check if there is a editor around here.
45
+ editor = Tools::editor()
46
+ if editor.nil?
47
+ logger.error( 'Could not find a editor to use (xdg-open, $VISUAL, $GUIEDITOR, $EDITOR).' )
48
+ end
49
+ # Execute the editor
50
+ cmd = "#{editor} #{@file.path}"
51
+ logger.trace( "> #{cmd}" )
52
+ if system( cmd ).nil?
53
+ logger.error( "Failed to start editor #{editor}" )
54
+ end
55
+ return 0
25
56
  end
26
57
 
27
58
  def path()
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-tool
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 3
10
- version: 0.6.3
9
+ - 4
10
+ version: 0.6.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Jansen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-27 00:00:00 +02:00
18
+ date: 2012-05-31 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -99,9 +99,25 @@ dependencies:
99
99
  type: :runtime
100
100
  version_requirements: *id005
101
101
  - !ruby/object:Gem::Dependency
102
- name: racc
102
+ name: inifile
103
103
  prerelease: false
104
104
  requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 19
110
+ segments:
111
+ - 1
112
+ - 1
113
+ - 0
114
+ version: 1.1.0
115
+ type: :runtime
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: racc
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
105
121
  none: false
106
122
  requirements:
107
123
  - - ">="
@@ -113,11 +129,11 @@ dependencies:
113
129
  - 7
114
130
  version: 1.4.7
115
131
  type: :development
116
- version_requirements: *id006
132
+ version_requirements: *id007
117
133
  - !ruby/object:Gem::Dependency
118
134
  name: rexical
119
135
  prerelease: false
120
- requirement: &id007 !ruby/object:Gem::Requirement
136
+ requirement: &id008 !ruby/object:Gem::Requirement
121
137
  none: false
122
138
  requirements:
123
139
  - - ">="
@@ -129,11 +145,11 @@ dependencies:
129
145
  - 5
130
146
  version: 1.0.5
131
147
  type: :development
132
- version_requirements: *id007
148
+ version_requirements: *id008
133
149
  - !ruby/object:Gem::Dependency
134
150
  name: rake
135
151
  prerelease: false
136
- requirement: &id008 !ruby/object:Gem::Requirement
152
+ requirement: &id009 !ruby/object:Gem::Requirement
137
153
  none: false
138
154
  requirements:
139
155
  - - ">="
@@ -145,11 +161,11 @@ dependencies:
145
161
  - 2
146
162
  version: 0.9.2
147
163
  type: :development
148
- version_requirements: *id008
164
+ version_requirements: *id009
149
165
  - !ruby/object:Gem::Dependency
150
166
  name: yard
151
167
  prerelease: false
152
- requirement: &id009 !ruby/object:Gem::Requirement
168
+ requirement: &id010 !ruby/object:Gem::Requirement
153
169
  none: false
154
170
  requirements:
155
171
  - - ">="
@@ -161,11 +177,11 @@ dependencies:
161
177
  - 5
162
178
  version: 0.7.5
163
179
  type: :development
164
- version_requirements: *id009
180
+ version_requirements: *id010
165
181
  - !ruby/object:Gem::Dependency
166
182
  name: turn
167
183
  prerelease: false
168
- requirement: &id010 !ruby/object:Gem::Requirement
184
+ requirement: &id011 !ruby/object:Gem::Requirement
169
185
  none: false
170
186
  requirements:
171
187
  - - ">="
@@ -176,7 +192,7 @@ dependencies:
176
192
  - 9
177
193
  version: "0.9"
178
194
  type: :development
179
- version_requirements: *id010
195
+ version_requirements: *id011
180
196
  description: "\n The tool helps \n\n ...\n "
181
197
  email:
182
198
  - info@michael-jansen.biz
@@ -282,6 +298,7 @@ files:
282
298
  - lib/mj/error.rb
283
299
  - lib/mj/logging.rb
284
300
  - lib/mj/mixins/inherited_attributes.rb
301
+ - lib/mj/path.rb
285
302
  - lib/mj/tools/editor.rb
286
303
  - lib/mj/tools/ssh.rb
287
304
  - lib/mj/tools/subprocess.rb