app_stack 1.4.4 → 1.5.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2MxNDZkZTAxMmI2MTExMGM1Y2VmZGUyMTBlZTk0OTBlMGVhNjBjMg==
4
+ MDM0Y2Q5OGY5NDkwMDliNmVhNzUwNTVlNWFkYTJkYWNhYjI3YjhmZQ==
5
5
  data.tar.gz: !binary |-
6
- Yjk5MzUxMGM5MzJmNzBjZDZhNTE5OGJjOTcxZDc1NTBkNzE4MDY3Mg==
6
+ YjdjNDQ0NzVjNzlkYjYxNWE5OGRhNjg3N2E3ZmUxOTg5MmVjODFjNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjVmN2NkNTMyZDM2NDQ2ZjZkNDkwMzVmM2UwNThiYzAwNTc4NzljMjY3Y2Rk
10
- ODRjNzViYjYzNWM0Y2IwMWU2YTBlOWVlZDFlYTAyNzUwODgxYTNjNjkyNzdj
11
- OTlkMzQ4ZTJlNmRlZDUxZjY2YjdjY2JhNWYzNzYzNDIwN2UxZmE=
9
+ ZmFhOTcwNjI5NjhkM2JiNjcyODc0Y2RiMTBjOWYwMjhkNWU1ZGU0ZWNjMGMz
10
+ YjhjYjNkZGYyYjAxY2IzZDc4MmFlNmQ1ODM1OGUzYzc0Mjk4Mjc4NmU2MGEw
11
+ M2FlN2VhNTYyODE3YjhhNTU5ODcxNGZkMTc2NzA1ZjkyYWUwMDc=
12
12
  data.tar.gz: !binary |-
13
- Mjk3N2NkYzk5ZGUyZTU0MWM5OWVlNDg4ZWZiZGVhOTQxYzdkNTIxMzU2MjY1
14
- M2JjYWYzOTNjYWNjMzczZGIxNTdmOTYyMTZmMDI5MGU2YjhjZWE4MThmMzk0
15
- NGE5NDU3NThkZmFmYTJjNGZiMTQ0NDkyMWFhMTRjNWJmN2JmMGQ=
13
+ MjA2MjRkZTk2NTUyOTI3NmVjYzE3YmM4MjgyMmEyM2Q2MDJiMmM0OTZkNTFm
14
+ M2RkN2E5YWFmNWQxNTdhZTNmMDQwYTA2NTkwMWMzNzM3ZTJlMjNmZWMyMzA1
15
+ OGQwNzllZmEwMGNiMDg5N2EwYjlkMzU5ZTI1NzJkMzYyZGNlODM=
data/lib/app_stack/app.rb CHANGED
@@ -50,7 +50,7 @@ module AppStack
50
50
  load_stack!
51
51
  load_compare_list!
52
52
  build_copy_list!
53
- merge!
53
+ options.reverse ? do_reverse! : merge!
54
54
  end
55
55
 
56
56
  def options
@@ -6,7 +6,7 @@ module AppStack
6
6
  # parse command line options based
7
7
  # rubocop:disable MethodLength
8
8
  class CliOptions
9
- attr_accessor :force, :simulate, :verbose, :recursive, :conf_file
9
+ attr_accessor :force, :simulate, :verbose, :reverse, :conf_file
10
10
 
11
11
  def initialize(argv = ARGV)
12
12
  parse_opt!(argv)
@@ -33,8 +33,8 @@ module AppStack
33
33
  self.simulate = true
34
34
  end
35
35
 
36
- opts.on('-r', '--recursive', 'recursively stackup all apps') do
37
- self.recursive = true
36
+ opts.on('-r', '--reverse', 'copy local update to remote') do
37
+ self.reverse = true
38
38
  end
39
39
 
40
40
  opts.on('--verbose', 'show debug messages') do
@@ -10,6 +10,13 @@ module AppStack
10
10
  @to_file ||= to_app.get_file_path(from_file_short_name)
11
11
  end
12
12
 
13
+ def reverse!
14
+ fail 'can not reverse an import or render item' if import? || render?
15
+ from_app_, from_file_ = from_app.dup, from_file.dup
16
+ @from_app, @from_file = to_app, to_file
17
+ @to_app, @to_file = from_app_, from_file_
18
+ end
19
+
13
20
  def render?
14
21
  render ? true : false
15
22
  end
@@ -57,8 +64,15 @@ module AppStack
57
64
  end
58
65
 
59
66
  def label
60
- "#{operation} #{from_file_short_name.blue} from " +
61
- "#{from_app.app_name.bold} as #{to_file_short_name.blue}"
67
+ str = "#{operation} #{from_file_short_name.blue} from " +
68
+ "#{from_app.app_name.bold}"
69
+ str << "as #{to_file_short_name.blue}" unless
70
+ to_file_short_name == from_file_short_name
71
+ str
72
+ end
73
+
74
+ def reverse_label
75
+ "Copy back #{from_file_short_name.blue} to #{to_app.app_name.bold}"
62
76
  end
63
77
 
64
78
  def skip(msg)
@@ -35,6 +35,21 @@ module AppStack
35
35
  end
36
36
  end
37
37
 
38
+ def do_reverse!
39
+ @rev_list = {}
40
+ @diff_list.each_with_index do |f, i|
41
+ f.reverse!
42
+ puts "[#{i + 1}] " + f.reverse_label
43
+ @rev_list[i + 1] = f
44
+ end
45
+
46
+ puts "Which file you want to copy reversely?"
47
+ print "(1 2 ...):"
48
+ lists = gets.chomp.split(/\s+/)
49
+ lists.each { |i| fail "unknown option #{i}" unless @rev_list[i.to_i] }
50
+ lists.each { |i| @rev_list[i.to_i].process }
51
+ end
52
+
38
53
  private
39
54
 
40
55
  def do_copy!
@@ -2,5 +2,5 @@
2
2
 
3
3
  # AppStack module
4
4
  module AppStack
5
- VERSION = '1.4.4'
5
+ VERSION = '1.5.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huang Wei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt