MangUpdate 0.0.1 → 0.0.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.
data/README.md CHANGED
@@ -1,27 +1,27 @@
1
- MangUpdate
2
- ==========
3
-
4
- Installation
5
- ------------
6
-
7
- gem install mangupdate
8
-
9
- Usage
10
- -----
11
-
12
- ### WARNING!!!
13
- **Always check you config with `mangupdate -nl` (dry run and list updates) before using `mangupdate`!**
14
-
15
- - Create `Mupfile` with `mangupdate init`.
16
- - Edit and configure `Mupfile` as you need.
17
- - Run `mangupdate -nl` to check that lists and jobs are configured.
18
- - Check `Mupfile.dump` file and change numbers there to your server's current revisions.
19
- - Use `mangupdate` to run the update.
20
-
21
- Feel free to use `mangupdate -h update` to see all the options available.
22
-
23
-
24
- Mupfile examples
25
- ----------------
26
-
1
+ MangUpdate
2
+ ==========
3
+
4
+ Installation
5
+ ------------
6
+
7
+ gem install mangupdate
8
+
9
+ Usage
10
+ -----
11
+
12
+ ### WARNING!!!
13
+ **Always check you config with `mangupdate -nl` (dry run and list updates) before using `mangupdate`!**
14
+
15
+ - Create `Mupfile` with `mangupdate init`.
16
+ - Edit and configure `Mupfile` as you need.
17
+ - Run `mangupdate -nl` to check that lists and jobs are configured.
18
+ - Check `Mupfile.dump` file and change numbers there to your server's current revisions.
19
+ - Use `mangupdate` to run the update.
20
+
21
+ Feel free to use `mangupdate -h update` to see all the options available.
22
+
23
+
24
+ Mupfile examples
25
+ ----------------
26
+
27
27
  Just use `mangupdate init` to get a basic `Mupfile`.
@@ -1,4 +1,4 @@
1
- require "MangUpdate"
2
- require "MangUpdate/cli"
3
-
1
+ require "MangUpdate"
2
+ require "MangUpdate/cli"
3
+
4
4
  MangUpdate::CLI.start
@@ -1,66 +1,66 @@
1
- require 'thor'
2
- require 'MangUpdate/version'
3
-
4
- module MangUpdate
5
-
6
- class CLI < Thor
7
-
8
- default_task :update
9
-
10
- desc 'update', 'Runs the update'
11
-
12
- method_option :debug,
13
- :type => :boolean,
14
- :default => false,
15
- :aliases => '-d',
16
- :banner => 'Print debug messages'
17
-
18
- method_option :mupfile,
19
- :type => :string,
20
- :aliases => '-M',
21
- :banner => 'Specify a Mupfile'
22
-
23
- method_option :dry_run,
24
- :type => :boolean,
25
- :default => false,
26
- :aliases => '-n',
27
- :banner => 'Do not upload SQL files'
28
-
29
- method_option :list,
30
- :type => :boolean,
31
- :default => false,
32
- :aliases => '-l',
33
- :banner => 'Print SQL filenames'
34
-
35
- method_option :nodump,
36
- :type => :boolean,
37
- :default => false,
38
- :banner => 'Do not dump update info'
39
-
40
- def update
41
- ::MangUpdate.run(options)
42
- end
43
-
44
-
45
- desc 'version', 'Shows the MangUpdate version'
46
-
47
- map %w(-v --version) => :version
48
-
49
- def version
50
- ::MangUpdate::UI.info "MangUpdate version #{ MangUpdate::VERSION }"
51
- end
52
-
53
-
54
- desc 'init', 'Generates a Mupfile at the current working directory'
55
-
56
- method_option :mupfile,
57
- :type => :string,
58
- :aliases => '-M',
59
- :banner => 'Specify a Mupfile path'
60
-
61
- def init
62
- ::MangUpdate.initialize_template(options)
63
- end
64
-
65
- end
1
+ require 'thor'
2
+ require 'MangUpdate/version'
3
+
4
+ module MangUpdate
5
+
6
+ class CLI < Thor
7
+
8
+ default_task :update
9
+
10
+ desc 'update', 'Runs the update'
11
+
12
+ method_option :debug,
13
+ :type => :boolean,
14
+ :default => false,
15
+ :aliases => '-d',
16
+ :banner => 'Print debug messages'
17
+
18
+ method_option :mupfile,
19
+ :type => :string,
20
+ :aliases => '-M',
21
+ :banner => 'Specify a Mupfile'
22
+
23
+ method_option :dry_run,
24
+ :type => :boolean,
25
+ :default => false,
26
+ :aliases => '-n',
27
+ :banner => 'Do not upload SQL files'
28
+
29
+ method_option :list,
30
+ :type => :boolean,
31
+ :default => false,
32
+ :aliases => '-l',
33
+ :banner => 'Print SQL filenames'
34
+
35
+ method_option :nodump,
36
+ :type => :boolean,
37
+ :default => false,
38
+ :banner => 'Do not dump update info'
39
+
40
+ def update
41
+ ::MangUpdate.run(options)
42
+ end
43
+
44
+
45
+ desc 'version', 'Shows the MangUpdate version'
46
+
47
+ map %w(-v --version) => :version
48
+
49
+ def version
50
+ ::MangUpdate::UI.info "MangUpdate version #{ MangUpdate::VERSION }"
51
+ end
52
+
53
+
54
+ desc 'init', 'Generates a Mupfile at the current working directory'
55
+
56
+ method_option :mupfile,
57
+ :type => :string,
58
+ :aliases => '-M',
59
+ :banner => 'Specify a Mupfile path'
60
+
61
+ def init
62
+ ::MangUpdate.initialize_template(options)
63
+ end
64
+
65
+ end
66
66
  end
@@ -1,44 +1,44 @@
1
- require 'yaml'
2
-
3
- module MangUpdate
4
- class Dumpfile
5
-
6
- class << self
7
- def load(path = "Mupfile.dump")
8
- from_hash(YAML.load(File.read(path)))
9
- rescue
10
- nil
11
- end
12
-
13
- def write(dump, path = "Mupfile.dump")
14
- File.open(path, "wb") do |f|
15
- f.write dump.to_hash.to_yaml
16
- end
17
- end
18
-
19
- def from_hash(hash)
20
- dumpfile = self.new
21
- dumpfile.revs = hash[:revs]
22
- dumpfile
23
- end
24
- end
25
-
26
- attr_accessor :revs
27
- def initialize(revs = {})
28
- @revs = revs
29
- end
30
-
31
- def update_revs(revs_new = {})
32
- revs_new.each do |key, value|
33
- @revs[key] = value if !@revs.key?(key) || @revs[key] < value
34
- end
35
- end
36
-
37
- def to_hash
38
- {
39
- :revs => revs
40
- }
41
- end
42
-
43
- end
1
+ require 'yaml'
2
+
3
+ module MangUpdate
4
+ class Dumpfile
5
+
6
+ class << self
7
+ def load(path = "Mupfile.dump")
8
+ from_hash(YAML.load(File.read(path)))
9
+ rescue
10
+ nil
11
+ end
12
+
13
+ def write(dump, path = "Mupfile.dump")
14
+ File.open(path, "wb") do |f|
15
+ f.write dump.to_hash.to_yaml
16
+ end
17
+ end
18
+
19
+ def from_hash(hash)
20
+ dumpfile = self.new
21
+ dumpfile.revs = hash[:revs]
22
+ dumpfile
23
+ end
24
+ end
25
+
26
+ attr_accessor :revs
27
+ def initialize(revs = {})
28
+ @revs = revs
29
+ end
30
+
31
+ def update_revs(revs_new = {})
32
+ revs_new.each do |key, value|
33
+ @revs[key] = value if !@revs.key?(key) || @revs[key] < value
34
+ end
35
+ end
36
+
37
+ def to_hash
38
+ {
39
+ :revs => revs
40
+ }
41
+ end
42
+
43
+ end
44
44
  end
@@ -1,54 +1,54 @@
1
- module MangUpdate
2
- class Job
3
- attr_reader :name, :updates, :latest_revs
4
-
5
- def initialize(name, applies)
6
- @name = name
7
- @applies = applies
8
- @updates = nil
9
- @latest_revs = {}
10
- end
11
-
12
- def collect_updates
13
- @updates = []
14
- @applies.each do |apply|
15
- type = apply.shift
16
- case type
17
- when :list
18
- options, filters = apply
19
-
20
- updates = []
21
- MangUpdate.lists(options).each do |list|
22
- next unless list.built?
23
-
24
- list.updates.each do |update|
25
- selected = filters.all? do |filter|
26
- filter.call(update, list)
27
- end
28
-
29
- if selected
30
- @latest_revs[list.name] = update.rev
31
- updates << update
32
- end
33
- end
34
-
35
- end
36
-
37
- @updates << updates
38
- when :file
39
- filename, database, rev = apply
40
- model = Model::Common.new(filename, database, rev || 0)
41
- @updates << [ model ]
42
-
43
- when :inline
44
- sql, database, rev = apply
45
- model = Model::InlineSql.new(nil, database, rev || 0, { :sql => sql })
46
- @updates << [ model ]
47
-
48
- end
49
-
50
- end
51
- end
52
-
53
- end
1
+ module MangUpdate
2
+ class Job
3
+ attr_reader :name, :updates, :latest_revs
4
+
5
+ def initialize(name, applies)
6
+ @name = name
7
+ @applies = applies
8
+ @updates = nil
9
+ @latest_revs = {}
10
+ end
11
+
12
+ def collect_updates
13
+ @updates = []
14
+ @applies.each do |apply|
15
+ type = apply.shift
16
+ case type
17
+ when :list
18
+ options, filters = apply
19
+
20
+ updates = []
21
+ MangUpdate.lists(options).each do |list|
22
+ next unless list.built?
23
+
24
+ list.updates.each do |update|
25
+ selected = filters.all? do |filter|
26
+ filter.call(update, list)
27
+ end
28
+
29
+ if selected
30
+ @latest_revs[list.name] = update.rev
31
+ updates << update
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ @updates << updates
38
+ when :file
39
+ filename, database, rev = apply
40
+ model = Model::Common.new(filename, database, rev || 0)
41
+ @updates << [ model ]
42
+
43
+ when :inline
44
+ sql, database, rev = apply
45
+ model = Model::InlineSql.new(nil, database, rev || 0, { :sql => sql })
46
+ @updates << [ model ]
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+ end
54
54
  end
@@ -1 +1,58 @@
1
- module MangUpdate
2
1
  class List
3
2
 
4
3
  attr_reader :name, :updates
5
4
  attr_accessor :current_rev
6
5
 
7
6
  def initialize(name, paths)
8
7
  @name = name
9
8
  @paths = []
10
9
  @updates = []
11
10
  @built = false
12
11
  @current_rev = 0
13
12
  add_paths(paths)
14
13
  end
15
14
 
16
15
  def add_paths(paths)
17
16
  paths.each do |path|
18
17
  _path, options = path
19
18
  @paths << Path.new(_path, options)
20
19
  end
21
20
  end
22
21
 
23
22
  def build!
24
23
  @built = true
25
24
  @paths.each do |path|
26
25
  path.scan do |update|
27
26
  @updates << update
28
27
  end
29
28
  end
30
29
  sort_list!(@updates)
31
30
  rescue
32
31
  @built = false
33
32
  raise
34
33
  end
35
34
 
36
35
  def built?
37
36
  @built
38
37
  end
39
38
 
40
39
  private
41
40
 
42
41
  # This sorts the array of updates by it's sort_data field
43
42
  def sort_list!(list)
44
43
  list.sort! do |a,b|
45
44
  a, b = a.sort_data, b.sort_data
46
45
  i = 0
47
46
  i += 1 while a[i] == b[i] && (a[i+1] || b[i+1])
48
47
  if a[i] && b[i]
49
48
  a[i] <=> b[i]
50
49
  else
51
50
  a[i] ? 1 : -1
52
51
  end
53
52
  end
54
53
  list
55
54
  end
56
55
 
57
56
  end
57
+ module MangUpdate
58
+ class List
59
+
60
+ attr_reader :name, :updates
61
+ attr_accessor :current_rev
62
+
63
+ def initialize(name, paths)
64
+ @name = name
65
+ @paths = []
66
+ @updates = []
67
+ @built = false
68
+ @current_rev = 0
69
+ add_paths(paths)
70
+ end
71
+
72
+ def add_paths(paths)
73
+ paths.each do |path|
74
+ _path, options = path
75
+ @paths << Path.new(_path, options)
76
+ end
77
+ end
78
+
79
+ def build!
80
+ @built = true
81
+ @paths.each do |path|
82
+ path.scan do |update|
83
+ @updates << update
84
+ end
85
+ end
86
+ sort_list!(@updates)
87
+ rescue
88
+ @built = false
89
+ raise
90
+ end
91
+
92
+ def built?
93
+ @built
94
+ end
95
+
96
+ private
97
+
98
+ # This sorts the array of updates by it's sort_data field
99
+ def sort_list!(list)
100
+ list.sort! do |a,b|
101
+ a, b = a.sort_data, b.sort_data
102
+ i = 0
103
+ i += 1 while a[i] == b[i] && (a[i+1] || b[i+1])
104
+ if a[i] && b[i]
105
+ a[i] <=> b[i]
106
+ else
107
+ a[i] ? 1 : -1
108
+ end
109
+ end
110
+ list
111
+ end
112
+
113
+ end
114
+ end
@@ -1,38 +1,38 @@
1
- module MangUpdate
2
- module Model
3
-
4
- autoload :Common, 'MangUpdate/models/common'
5
- autoload :InlineSql, 'MangUpdate/models/inline_sql'
6
-
7
- class Base
8
-
9
- attr_reader :filename, :database, :rev, :info
10
- attr_accessor :applied
11
-
12
- def self.build(filename, options = {})
13
- raise "Do not know how to build #{name}"
14
-
15
- # Should be overwritten by subclasses with something like self.new ...
16
- end
17
-
18
- def initialize(filename, database, rev, info = {})
19
- @filename = filename
20
- @database = database
21
- @rev = rev
22
- @info = info
23
- end
24
-
25
- def sort_data
26
- [rev]
27
- end
28
-
29
- def to_s
30
- "Rev#{rev} [#{self.class.name}:#{filename}]"
31
- end
32
-
33
- def upload
34
- MangUpdate.upload_file_to_db(filename, database)
35
- end
36
- end
37
- end
1
+ module MangUpdate
2
+ module Model
3
+
4
+ autoload :Common, 'MangUpdate/models/common'
5
+ autoload :InlineSql, 'MangUpdate/models/inline_sql'
6
+
7
+ class Base
8
+
9
+ attr_reader :filename, :database, :rev, :info
10
+ attr_accessor :applied
11
+
12
+ def self.build(filename, options = {})
13
+ raise "Do not know how to build #{name}"
14
+
15
+ # Should be overwritten by subclasses with something like self.new ...
16
+ end
17
+
18
+ def initialize(filename, database, rev, info = {})
19
+ @filename = filename
20
+ @database = database
21
+ @rev = rev
22
+ @info = info
23
+ end
24
+
25
+ def sort_data
26
+ [rev]
27
+ end
28
+
29
+ def to_s
30
+ "Rev#{rev} [#{self.class.name}:#{filename}]"
31
+ end
32
+
33
+ def upload
34
+ MangUpdate.upload_file_to_db(filename, database)
35
+ end
36
+ end
37
+ end
38
38
  end
@@ -1,14 +1,14 @@
1
- module MangUpdate
2
- module Model
3
-
4
- class Common < Base
5
-
6
- def self.build(filename, options = {})
7
- data = File.basename(filename, '.sql').split('_')
8
- self.new filename, data[1], data[0].gsub(/[^0-9]/, '').to_i
9
- end
10
-
11
- end
12
-
13
- end
1
+ module MangUpdate
2
+ module Model
3
+
4
+ class Common < Base
5
+
6
+ def self.build(filename, options = {})
7
+ data = File.basename(filename, '.sql').split('_')
8
+ self.new filename, data[1], data[0].gsub(/[^0-9]/, '').to_i
9
+ end
10
+
11
+ end
12
+
13
+ end
14
14
  end
@@ -1,23 +1,23 @@
1
- module MangUpdate
2
- module Model
3
-
4
- class InlineSql < Base
5
- attr_reader :sql
6
-
7
- def self.build(filename, options = {})
8
- raise "#{name} can not be used as a model"
9
- end
10
-
11
- def initialize(filename, database, rev, info = {})
12
- super("<Inline SQL>", database, rev, info)
13
- @sql = @info[:sql]
14
- end
15
-
16
- def upload
17
- MangUpdate.upload_inline_sql(sql, database)
18
- end
19
-
20
- end
21
-
22
- end
1
+ module MangUpdate
2
+ module Model
3
+
4
+ class InlineSql < Base
5
+ attr_reader :sql
6
+
7
+ def self.build(filename, options = {})
8
+ raise "#{name} can not be used as a model"
9
+ end
10
+
11
+ def initialize(filename, database, rev, info = {})
12
+ super("<Inline SQL>", database, rev, info)
13
+ @sql = @info[:sql]
14
+ end
15
+
16
+ def upload
17
+ MangUpdate.upload_inline_sql(sql, database)
18
+ end
19
+
20
+ end
21
+
22
+ end
23
23
  end
@@ -1,19 +1,19 @@
1
- module MangUpdate
2
- module Model
3
-
4
- class MainCore < Base
5
- APPLY_PRIORITY = 1
6
-
7
- def self.build(filename, options = {})
8
- data = File.basename(filename, '.sql').split('_')
9
- self.new filename, data[2], data[0].to_i, :num => data[1].to_i
10
- end
11
-
12
- def sort_data
13
- [rev, APPLY_PRIORITY, info[:num]]
14
- end
15
-
16
- end
17
-
18
- end
1
+ module MangUpdate
2
+ module Model
3
+
4
+ class MainCore < Base
5
+ APPLY_PRIORITY = 1
6
+
7
+ def self.build(filename, options = {})
8
+ data = File.basename(filename, '.sql').split('_')
9
+ self.new filename, data[2], data[0].to_i, :num => data[1].to_i
10
+ end
11
+
12
+ def sort_data
13
+ [rev, APPLY_PRIORITY, info[:num]]
14
+ end
15
+
16
+ end
17
+
18
+ end
19
19
  end
@@ -1,20 +1,20 @@
1
- module MangUpdate
2
- module Model
3
-
4
- class YtdbCore < Base
5
- APPLY_PRIORITY = 2
6
-
7
- def self.build(filename, options = {})
8
- data = File.basename(filename, '.sql').split('_')
9
- return if data[1] == 'corepatch' # skip all corepatches...
10
- self.new filename, data[1], data[3].gsub(/[^0-9]/, '').to_i
11
- end
12
-
13
- def sort_data
14
- [rev, APPLY_PRIORITY]
15
- end
16
-
17
- end
18
-
19
- end
1
+ module MangUpdate
2
+ module Model
3
+
4
+ class YtdbCore < Base
5
+ APPLY_PRIORITY = 2
6
+
7
+ def self.build(filename, options = {})
8
+ data = File.basename(filename, '.sql').split('_')
9
+ return if data[1] == 'corepatch' # skip all corepatches...
10
+ self.new filename, data[1], data[3].gsub(/[^0-9]/, '').to_i
11
+ end
12
+
13
+ def sort_data
14
+ [rev, APPLY_PRIORITY]
15
+ end
16
+
17
+ end
18
+
19
+ end
20
20
  end
@@ -1 +1,44 @@
1
- require 'active_support/inflector'
2
1
  class Path
3
2
 
4
3
  def initialize(path, options = {})
5
4
  @path = path
6
5
  @options = options
7
6
 
8
7
  @model_class = get_model_class(options[:model] || :common)
9
8
  raise "Unable to load model!" unless @model_class
10
9
  end
11
10
 
12
11
  def scan
13
12
  Dir.glob(@path).each do |file|
14
13
  model = @model_class.build(file, @options)
15
14
  yield(model) if model
16
15
  end
17
16
  end
18
17
 
19
18
  private
20
19
 
21
20
  def get_model_class(name)
22
21
  name = name.to_s
23
22
  file_name = name.underscore
24
23
  const_name = name.camelize
25
24
  try_require = false
26
25
  begin
27
26
  require "MangUpdate/models/#{ file_name }" if try_require
28
27
  ::MangUpdate::Model.const_get(::MangUpdate::Model.constants.find { |c| c.to_s.downcase == const_name.downcase })
29
28
  rescue TypeError
30
29
  unless try_require
31
30
  try_require = true
32
31
  retry
33
32
  else
34
33
  UI.error "Could not find class MangUpdate::Model::#{ const_name }"
35
34
  end
36
35
  rescue LoadError => loadError
37
36
  UI.error "Could not load 'MangUpdate/models/#{ file_name }' or find class MangUpdate::Model::#{ const_name }"
38
37
  UI.error loadError.to_s
39
38
  end
40
39
  end
41
40
 
42
41
  end
42
+ require 'active_support/inflector'
43
+ module MangUpdate
44
+ class Path
45
+
46
+ def initialize(path, options = {})
47
+ @path = path
48
+ @options = options
49
+
50
+ @model_class = get_model_class(options[:model] || :common)
51
+ raise "Unable to load model!" unless @model_class
52
+ end
53
+
54
+ def scan
55
+ Dir.glob(@path).each do |file|
56
+ model = @model_class.build(file, @options)
57
+ yield(model) if model
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def get_model_class(name)
64
+ name = name.to_s
65
+ file_name = name.underscore
66
+ const_name = name.camelize
67
+ try_require = false
68
+ begin
69
+ require "MangUpdate/models/#{ file_name }" if try_require
70
+ ::MangUpdate::Model.const_get(::MangUpdate::Model.constants.find { |c| c.to_s.downcase == const_name.downcase })
71
+ rescue TypeError
72
+ unless try_require
73
+ try_require = true
74
+ retry
75
+ else
76
+ UI.error "Could not find class MangUpdate::Model::#{ const_name }"
77
+ end
78
+ rescue LoadError => loadError
79
+ UI.error "Could not load 'MangUpdate/models/#{ file_name }' or find class MangUpdate::Model::#{ const_name }"
80
+ UI.error loadError.to_s
81
+ end
82
+ end
83
+
84
+ end
85
+ end
@@ -1,32 +1,32 @@
1
- base_path = "."
2
- mangos_path = base_path + "/mangos"
3
- scriptdev2_path = base_path + "/scriptdev2"
4
-
5
- config :mysql_user, "mangos"
6
- config :mysql_pass, "mangos"
7
-
8
- list("Main Core") do
9
- path "#{mangos_path}/sql/updates/*.sql", :model => :main_core
10
- end
11
-
12
- list("Main SD2") do
13
- path "#{scriptdev2_path}/sql/updates/r*.sql"
14
- end
15
-
16
- job("Update all") do
17
- filtered do
18
-
19
- # only apply updates that have revision number
20
- # greater than currently installed revision
21
- filter do |update, list|
22
- update.rev > list.current_rev
23
- end
24
-
25
- apply
26
-
27
- end
28
- end
29
-
30
- #job("Custom SQL") do
31
- # upload_file "#{base_path}/mangos_custom.sql", "mangos"
32
- #end
1
+ base_path = "."
2
+ mangos_path = base_path + "/mangos"
3
+ scriptdev2_path = base_path + "/scriptdev2"
4
+
5
+ config :mysql_user, "mangos"
6
+ config :mysql_pass, "mangos"
7
+
8
+ list("Main Core") do
9
+ path "#{mangos_path}/sql/updates/*.sql", :model => :main_core
10
+ end
11
+
12
+ list("Main SD2") do
13
+ path "#{scriptdev2_path}/sql/updates/r*.sql"
14
+ end
15
+
16
+ job("Update all") do
17
+ filtered do
18
+
19
+ # only apply updates that have revision number
20
+ # greater than currently installed revision
21
+ filter do |update, list|
22
+ update.rev > list.current_rev
23
+ end
24
+
25
+ apply
26
+
27
+ end
28
+ end
29
+
30
+ #job("Custom SQL") do
31
+ # upload_file "#{base_path}/mangos_custom.sql", "mangos"
32
+ #end
@@ -1,23 +1,23 @@
1
- require 'erb'
2
-
3
- module MangUpdate
4
- module Templating
5
- class << self
6
-
7
- def init_template(options = {})
8
- b = binding
9
- template_filename = File.join(File.dirname(__FILE__), "templates", "Mupfile.erb")
10
-
11
- template = ERB.new(File.read(template_filename))
12
- template.filename = template_filename
13
-
14
- result = template.result(b)
15
-
16
- File.open(options[:mupfile], 'wb') do |f|
17
- f.puts(result)
18
- end
19
- end
20
-
21
- end
22
- end
23
- end
1
+ require 'erb'
2
+
3
+ module MangUpdate
4
+ module Templating
5
+ class << self
6
+
7
+ def init_template(options = {})
8
+ b = binding
9
+ template_filename = File.join(File.dirname(__FILE__), "templates", "Mupfile.erb")
10
+
11
+ template = ERB.new(File.read(template_filename))
12
+ template.filename = template_filename
13
+
14
+ result = template.result(b)
15
+
16
+ File.open(options[:mupfile], 'wb') do |f|
17
+ f.puts(result)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MangUpdate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MangUpdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &28246692 !ruby/object:Gem::Requirement
16
+ requirement: &22141480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *28246692
24
+ version_requirements: *22141480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &28245336 !ruby/object:Gem::Requirement
27
+ requirement: &22141020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *28245336
35
+ version_requirements: *22141020
36
36
  description: This is a small gem that will help you with updating your MaNGOS server.
37
37
  It uses Mupfile to keep all database update logic simple.
38
38
  email:
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project: MangUpdate
87
- rubygems_version: 1.8.10
87
+ rubygems_version: 1.8.11
88
88
  signing_key:
89
89
  specification_version: 3
90
90
  summary: Use Mupfiles to update your MaNGOS server database.