fpm-scriptable 1.0 → 1.0.1

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: 462abaa26e46eef0c790fd3817797f0fd773a68f
4
- data.tar.gz: c5f38036216be412ec63e8db0359b7988403eb37
3
+ metadata.gz: 7dda735651b1e39ddc8914ed1b8d81df040df757
4
+ data.tar.gz: bb76ab8965379c1435ef8c603efc3f5cc560cf73
5
5
  SHA512:
6
- metadata.gz: ec2237f35dcd887378dd5546940cf4a55577820ec04ce95c21d8bbb94e9b927eea144cf05c080d3246043acecb33cfe1074c5f08e41470c052cc382cfd870e84
7
- data.tar.gz: 3d9e535434ae2d547c07312732c06b5fa552c4ea1093abbf697946e5ab3ebcbfcb99f9c842b20ea23f013adbabec2af2f0b3d58aab26eb2e1fa86d81284aba49
6
+ metadata.gz: b3273b44adbb74ef99e11eaa7c4564908d46ae4e1433e70896c973228c338630ab6a966147e02c67f6c8598b27d203895f21a4b82bfa90bb86088d8f6b3309f7
7
+ data.tar.gz: 4723d15dc9e4bbb5d20c7ccb7a5d655ac67eafa9c6a18d0738501d9d34b9719d596d899dfbc4eea1395c859a47e3cc80f12dca1e088c621f5d5341d6f7768d61
data/bin/fpm-script CHANGED
@@ -13,25 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- bin_path = String.new
17
- bin_dir = String.new
18
- app_dir = String.new
16
+ require 'rubygems'
17
+ $: << File.join(File.dirname(__FILE__), "..", "lib")
18
+ require 'fpm/scriptable'
19
19
 
20
- bin_path = File.expand_path($0)
21
- if bin_path && bin_path != ""
22
- bin_dir = File.dirname(bin_path)
23
- end
24
-
25
- if bin_dir && bin_dir != ''
26
- app_dir = "#{bin_dir}/.."
27
- $:.push "#{app_dir}/lib"
28
- else
29
- puts 'Error: unable to locate bin directory'
30
- exit 1
31
- end
32
-
33
- Dir.chdir(app_dir) do
34
- require 'fpm/scriptable'
35
- end
36
- FPM::Scriptable::App.run(app_dir)
37
- exit 0
20
+ exit(FPM::Scriptable::App.run || 0)
@@ -19,18 +19,12 @@ require 'fpm'
19
19
  require 'curb'
20
20
 
21
21
  require 'fpm/scriptable/version'
22
+ require 'fpm/scriptable/app'
23
+ require 'fpm/scriptable/config'
24
+ require 'fpm/scriptable/log'
25
+ require 'fpm/scriptable/util'
26
+ require 'fpm/scriptable/constants'
27
+ require 'fpm/scriptable/script'
22
28
 
23
- module FPM
24
- module Scriptable
25
- # Core classes
26
- autoload :App, "fpm/scriptable/app"
27
- autoload :Config, "fpm/scriptable/config"
28
- autoload :Log, "fpm/scriptable/log"
29
- autoload :Util, "fpm/scriptable/util"
30
- autoload :Constants, "fpm/scriptable/constants"
31
- autoload :Script, "fpm/scriptable/script"
32
-
33
- # Package type plugins
34
- autoload :RPM, "fpm/scriptable/plugin/rpm"
35
- end
36
- end
29
+ # Package type plugins
30
+ require 'fpm/scriptable/plugin/rpm'
@@ -16,7 +16,7 @@ module FPM
16
16
  module Scriptable
17
17
  class App
18
18
 
19
- def self.run(app_dir)
19
+ def self.run
20
20
  @log = FPM::Scriptable::Log.instance
21
21
  args = FPM::Scriptable::Util.get_args
22
22
 
@@ -30,31 +30,24 @@ module FPM
30
30
  @log.add(level.to_sym, @log.color, STDOUT)
31
31
  end
32
32
 
33
- @log.show FPM::Scriptable::Util.banner, @log.quiet, true
33
+ @log.show FPM::Scriptable::Util.banner unless args[:nobanner]
34
34
 
35
35
  if args[:help] || args[:h]
36
- @log.show FPM::Scriptable::Util.usage, false, false
37
- exit 0
36
+ @log.show FPM::Scriptable::Util.usage, false
37
+ return 1
38
38
  end
39
39
 
40
40
  cfg = FPM::Scriptable::Config.instance
41
41
  @config = cfg.config
42
- @config.app_dir = app_dir
43
42
  @config.working_dir = Dir.getwd
44
43
 
45
44
  script = args[:script]
46
45
  if script.nil?
47
46
  @log.fatal 'FPM::Scriptable::App - No script file was specified'
48
- @log.show FPM::Scriptable::Util.usage, @log.quiet, false
49
- exit 1
47
+ @log.show FPM::Scriptable::Util.usage
50
48
  else
51
49
  if script !~ /^\//
52
- script = "#{@config.app_dir}/#{script}"
53
-
54
- if !File.exists? script
55
- script = args[:script]
56
- script = "#{@config.working_dir}/#{script}"
57
- end
50
+ script = "#{@config.working_dir}/#{script}"
58
51
  end
59
52
 
60
53
  @log.debug "FPM::Scriptable::App - Script file path set to: #{script}"
@@ -94,7 +87,8 @@ module FPM
94
87
  end
95
88
  end
96
89
 
97
- exit 0
90
+ return 1 if @log.has_error
91
+ return 0
98
92
  end
99
93
 
100
94
  end
@@ -29,11 +29,8 @@ module FPM
29
29
  protected
30
30
 
31
31
  class GeneralConfig
32
- attr_accessor :app_dir
33
32
 
34
33
  def initialize
35
- @app_dir = nil
36
-
37
34
  @u_defined = {}
38
35
  end
39
36
 
@@ -17,21 +17,18 @@ module FPM
17
17
  class Log
18
18
  include Singleton
19
19
  attr_accessor :quiet, :color
20
+ attr_reader :has_error
20
21
 
21
22
  def initialize
22
23
  @quiet = false
23
24
  @color = true
24
25
 
25
26
  @logger = nil
27
+ @has_error = false
26
28
  end
27
29
 
28
- def show(msg,quiet=@is_quiet,in_color=false)
29
- if msg
30
- if @color && in_color
31
- msg = "\e[33m#{msg}\e[0m"
32
- else
33
- msg = "\e[0m#{msg}\e[0m"
34
- end
30
+ def show(msg,quiet=@quiet)
31
+ if !msg.nil?
35
32
  puts msg unless quiet
36
33
  end
37
34
  end
@@ -49,7 +46,7 @@ module FPM
49
46
  end
50
47
 
51
48
  def info(msg)
52
- if msg
49
+ if !msg.nil?
53
50
  if !@logger.nil?
54
51
  @logger.info msg
55
52
  end
@@ -57,7 +54,7 @@ module FPM
57
54
  end
58
55
 
59
56
  def warn(msg)
60
- if msg
57
+ if !msg.nil?
61
58
  if !@logger.nil?
62
59
  @logger.warn msg
63
60
  end
@@ -65,7 +62,7 @@ module FPM
65
62
  end
66
63
 
67
64
  def debug(msg)
68
- if msg
65
+ if !msg.nil?
69
66
  if !@logger.nil?
70
67
  @logger.debug msg
71
68
  end
@@ -73,7 +70,8 @@ module FPM
73
70
  end
74
71
 
75
72
  def error(msg)
76
- if msg
73
+ @has_error = true
74
+ if !msg.nil?
77
75
  if !@logger.nil?
78
76
  @logger.error msg
79
77
  end
@@ -81,7 +79,8 @@ module FPM
81
79
  end
82
80
 
83
81
  def fatal(msg)
84
- if msg
82
+ @has_error = true
83
+ if !msg.nil?
85
84
  if !@logger.nil?
86
85
  @logger.fatal msg
87
86
  end
@@ -52,7 +52,7 @@ module FPM
52
52
  @config = FPM::Scriptable::Config.instance.config
53
53
  c = FPM::Scriptable::Constants.instance
54
54
 
55
- @log.debug 'FPM::Scriptable::RPM - initializing Script'
55
+ @log.debug 'FPM::Scriptable::Script - initializing Script'
56
56
 
57
57
  @version = c.script.version
58
58
  @iteration = c.script.iteration
@@ -63,11 +63,11 @@ module FPM
63
63
  end
64
64
 
65
65
  def fpm_obj
66
- @log.error 'fpm_obj method not implemented in plugin'
66
+ @log.warn 'FPM::Scriptable::Script - fpm_obj method not implemented in plugin'
67
67
  end
68
68
 
69
69
  def fpm_convert
70
- @log.error 'fpm_convert method not implemented in plugin'
70
+ @log.warn 'FPM::Scriptable::Script - fpm_convert method not implemented in plugin'
71
71
  end
72
72
 
73
73
  def plugin_init
@@ -128,7 +128,7 @@ module FPM
128
128
  #@fpm.directories +=
129
129
  #@fom.attributes[:excludes]
130
130
  rescue Exception => e
131
- log.error "#{e}"
131
+ @log.error "FPM::Scriptable::Script - #{e}"
132
132
  end
133
133
 
134
134
  package = nil
@@ -141,20 +141,20 @@ module FPM
141
141
  if !overwrite.nil?
142
142
  force = overwrite.to_s.downcase
143
143
  if force == 'true'
144
- @log.info "Overwrite enabled - Removing package: #{package.to_s}"
144
+ @log.warn "FPM::Scriptable::Script - overwrite enabled - removing package: #{package.to_s}"
145
145
  FileUtils.rm_f(package.to_s)
146
146
  end
147
147
  end
148
148
  end
149
149
 
150
- @log.info "Building package: #{package.to_s}"
150
+ @log.info "FPM::Scriptable::Script - building package: #{package.to_s}"
151
151
  package.output(package.to_s)
152
152
  end
153
153
  else
154
- @log.error 'Failed to convert - Packaging object is invalid'
154
+ @log.error 'FPM::Scriptable::Script - failed to convert - packaging object is invalid'
155
155
  end
156
156
  rescue Exception => e
157
- log.error "#{e}"
157
+ @log.error "FPM::Scriptable::Script - #{e}"
158
158
  end
159
159
 
160
160
  end
@@ -51,17 +51,17 @@ module FPM
51
51
 
52
52
  def self.usage
53
53
  usage = <<EOF
54
-
55
- Usage:
54
+ Usage:
56
55
  #{$0} OPTIONS
57
56
 
58
- Options:
59
- --help Display this help screen
60
- --quiet Messages are not displayed to the console
61
- --nocolor Turn off colors in console output
62
- --log_level <lvl> STDOUT log level (info, debug, error)
57
+ Options:
58
+ --help Display this help screen
59
+ --quiet Messages are not displayed to the console
60
+ --nocolor Turn off colors in console output
61
+ --log_level <lvl> Log level (info, debug, error)
62
+ --nobanner Do not show the banner
63
63
 
64
- --script <file> Script to build
64
+ --script <file> Script to build
65
65
 
66
66
  EOF
67
67
  usage
@@ -78,11 +78,11 @@ EOF
78
78
  |_| | .__/|_| |_| |_| |___/\\___|_| |_| .__/ \\__\\__,_|_.__/|_|\\___|
79
79
  |_| |_|
80
80
 
81
+ #{c.name}
82
+ Version: #{c.version}
83
+ Author: #{c.author}
84
+ Website: #{c.website}
81
85
 
82
- #{c.name}
83
- Version: #{c.version}
84
- Author: #{c.author}
85
- Website: #{c.website}
86
86
  EOF
87
87
  banner
88
88
  end
@@ -15,7 +15,7 @@
15
15
  module FPM
16
16
  module Scriptable
17
17
  NAME = 'fpm-scriptable'
18
- VERSION = '1.0'
18
+ VERSION = '1.0.1'
19
19
  AUTHOR = 'Ted Elwartowski'
20
20
  EMAIL = '<xelwarto.pub@gmail.com>'
21
21
  WEBSITE = 'https://github.com/xelwarto/fpm-scriptable'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-scriptable
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ted Elwartowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb