volley 0.1.2 → 0.1.6

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/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## v0.1.5:
4
+ * action#stop should delegate to plan#stop
5
+
6
+ ## v0.1.4:
7
+ * fix problem with expand path throwing errors when HOME environment variable is not set
8
+ * fix problem with volley:meta when the meta file doesn't exist
9
+ * add -q --quiet option to CLI (bumps log level to warn)
10
+ * add volley:published plan, show all published artifacts (used by jenkins for selecting version to deploy)
11
+ * add version_data method to publisher, primarily to have access to modified time for sorting
12
+ * bug fixes, meta and published plan work
13
+
14
+ ## v0.1.3:
15
+ * bug fixes, meta and published plan work
16
+
17
+ ## v0.1.2:
18
+ * add code to generate changelog
19
+ * attempting to publish a duplicate artifact shouldn't throw an error
20
+ * properly support force=true argument
21
+ * allow for stopping plan processing with plan#stop
22
+
23
+ ## v0.1.1:
24
+ * add the ability to daemonize the process using Daemons gem.
25
+ * add Volley::Log#reset to forget previous log configuration in parent, before forking
26
+
data/bin/volley CHANGED
@@ -3,15 +3,14 @@
3
3
  require 'rubygems'
4
4
  require 'docopt'
5
5
  require 'volley'
6
- require 'awesome_print'
7
6
  require 'daemons'
8
7
 
9
8
  DOC = <<-DOC
10
9
  Usage: volley [options] <plan> <descriptor> [argument]...
11
10
 
12
11
  <plan>
13
- The plan to run.
14
- reserved plan names: [versions, latest, list]
12
+ The plan to run. This can be just the plan name or the project:plan.
13
+ (will check in the reserved volley project for plan first)
15
14
 
16
15
  <descriptor>
17
16
  A descriptor should conform to the following format:
@@ -31,7 +30,8 @@ Usage: volley [options] <plan> <descriptor> [argument]...
31
30
  Options:
32
31
  -h --help show this help message and exit
33
32
  --version show version and exit
34
- -d --debug show debug output, change log level to debug
33
+ -d --debug change log level to debug
34
+ -q --quiet change log level to warn (generally this means no output)
35
35
  -c --config FILE load additional Volleyfile [default: ~/.Volleyfile]
36
36
  -p --primary FILE load primary Volleyfile [default: ./Volleyfile]
37
37
  -F --force force operations (redeploy version, republish artifact)
@@ -50,6 +50,7 @@ module Volley
50
50
  STDOUT.sync = true
51
51
  options = Docopt(DOC, Volley::Version::STRING)
52
52
  debug = options[:debug]
53
+ quiet = options[:quiet]
53
54
  config = options[:config]
54
55
  primary = options[:primary]
55
56
  fork = options[:fork]
@@ -63,9 +64,15 @@ module Volley
63
64
  Volley::Dsl::VolleyFile.load(config, :optional => true)
64
65
  Volley::Dsl::VolleyFile.load(primary, :primary => true) if File.file?(primary)
65
66
 
66
- Volley::Log.add(level.to_sym, log)
67
- Volley::Log.console_debug if debug
68
67
  Volley.config.debug = debug
68
+ Volley.config.quiet = quiet
69
+
70
+ Volley::Log.add(level.to_sym, log)
71
+ if debug
72
+ Volley::Log.console_debug
73
+ elsif quiet
74
+ Volley::Log.console_quiet
75
+ end
69
76
 
70
77
  kvs = argv.select { |e| e.match(/(\w+)\=(\w+)/) }
71
78
  pos = argv.reject { |e| e.match(/(\w+)\=(\w+)/) }
@@ -74,8 +81,9 @@ module Volley
74
81
  desc = pos.shift
75
82
 
76
83
  raise "must specify plan" unless plan
84
+ if plan =~ /\:/
77
85
 
78
- if Volley::Dsl.project(:volley).plan?(plan)
86
+ elsif Volley::Dsl.project(:volley).plan?(plan)
79
87
  # the plan is reserved
80
88
  plan = "volley:#{plan}"
81
89
  else
@@ -116,14 +124,10 @@ module Volley
116
124
  rescue Interrupt
117
125
  Volley::Log.info "interrupted"
118
126
  rescue SystemExit
119
- Volley::Log.info "exited"
127
+ Volley::Log.debug "exited"
120
128
  rescue => e
121
129
  Volley::Log.error "error: #{e.message} at #{e.backtrace.first}"
122
- #if debug
123
- Volley::Log.error e
124
- #else
125
- # Volley::Log.debug e
126
- #end
130
+ Volley::Log.debug e
127
131
  end
128
132
  end
129
133
  end
@@ -8,6 +8,7 @@ project :volley do
8
8
  puts "created: #{dest}"
9
9
  end
10
10
  end
11
+
11
12
  plan :list, :remote => false do
12
13
  default do
13
14
  Volley::Dsl::Project.projects.each do |p, project|
@@ -18,15 +19,17 @@ project :volley do
18
19
  end
19
20
  end
20
21
  end
22
+
21
23
  plan :latest do
22
24
  default do
23
- (project,branch,_) = args.descriptor.get
25
+ (project, branch, _) = args.descriptor.get
24
26
  raise "project and branch must be specified" unless project && branch
25
27
 
26
28
  pub = Volley::Dsl.publisher
27
29
  puts pub.latest(project, branch)
28
30
  end
29
31
  end
32
+
30
33
  plan :versions, :remote => false do
31
34
  argument :all, :convert => :boolean, :default => false
32
35
  argument :output, :default => "list", :convert => :to_sym, :choices => ["json", "xml", "list"]
@@ -37,7 +40,7 @@ project :volley do
37
40
  pub = Volley::Dsl.publisher
38
41
  data = []
39
42
  if args.all
40
- data = pub.all.keys.reject {|e| e =~ /latest$/}
43
+ data = pub.all.keys.reject { |e| e =~ /latest$/ }
41
44
  data.each { |k, v| puts "%2s %s" % [v, k] }
42
45
  else
43
46
  if project
@@ -65,10 +68,38 @@ project :volley do
65
68
  end
66
69
  end
67
70
  end
71
+
68
72
  plan :meta, :remote => false do
69
73
  default do
70
- Volley.meta.projects.each do |k, v|
71
- puts "#{k} => #{v}"
74
+ list = Volley.meta.projects
75
+ unless list && list.count > 0
76
+ Volley::Log.info "no projects found"
77
+ stop
78
+ end
79
+
80
+ project = args.descriptor.get.first
81
+ if project
82
+ project = args.descriptor.get.first
83
+ Volley::Log.warn "#{list[project.to_sym]}"
84
+ else
85
+ list.each do |k, v|
86
+ Volley::Log.warn "#{k} => #{v}"
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ plan :published, :remote => false do
93
+ default do
94
+ pub = Volley::Dsl.publisher
95
+
96
+ unless pub
97
+ Volley::Log.error "publisher must be configured"
98
+ stop
99
+ end
100
+
101
+ pub.list do |p, b, v, data|
102
+ Volley::Log.warn "#{p}@#{b}:#{v}"
72
103
  end
73
104
  end
74
105
  end
@@ -21,7 +21,7 @@ module Volley
21
21
  self.instance_eval &@block if @block
22
22
  end
23
23
 
24
- delegate :project, :args, :files, :file, :attributes, :log, :arguments, :argv, :branch, :version, :action, :volley,
24
+ delegate :project, :args, :files, :file, :attributes, :log, :arguments, :argv, :branch, :version, :action, :volley, :stop,
25
25
  :to => :plan
26
26
 
27
27
  def command(cmd)
@@ -63,6 +63,8 @@ module Volley
63
63
  return f if File.file?(f)
64
64
  end
65
65
  nil
66
+ rescue ArgumentError # rescue errors with expand path
67
+ nil
66
68
  end
67
69
  end
68
70
  end
@@ -61,9 +61,10 @@ module Volley
61
61
 
62
62
  begin
63
63
  run_actions
64
+ rescue ExecutionStopped => e
65
+ Volley::Log.debug "stopping execution at #{e.backtrace.first}"
64
66
  rescue => e
65
67
  puts "plan#call error: #{e.message} at #{e.backtrace.first}"
66
- ap self
67
68
  raise e
68
69
  end
69
70
  [branch, version].join(":")
@@ -94,6 +95,7 @@ module Volley
94
95
 
95
96
  def stop
96
97
  @stopped = true
98
+ raise ExecutionStopped, "stopped"
97
99
  end
98
100
 
99
101
  def stopped?
@@ -0,0 +1,4 @@
1
+
2
+ module Volley
3
+ class ExecutionStopped < StandardError; end
4
+ end
data/lib/volley/log.rb CHANGED
@@ -32,6 +32,12 @@ module Volley
32
32
  @loggers["STDERR"] = Yell.new(STDERR, :level => [:error, :fatal], :format => Yell::NoFormat)
33
33
  end
34
34
 
35
+ def console_quiet
36
+ console_disable
37
+ @loggers["STDOUT"] = Yell.new(STDOUT, :level => [:warn], :format => Yell::NoFormat)
38
+ @loggers["STDERR"] = Yell.new(STDERR, :level => [:error, :fatal], :format => Yell::NoFormat)
39
+ end
40
+
35
41
  %w{debug info warn error fatal}.each do |method_name|
36
42
  class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
37
43
  def #{method_name}(msg=nil, &block)
@@ -33,17 +33,31 @@ module Volley
33
33
  br = branch.to_s
34
34
  r = files[:desc][pr][br].keys || [] rescue []
35
35
  Volley::Log.info "could not find #{pr}@#{br}" unless r.count > 0
36
- r
36
+ r.reject { |e| e == "latest" || e == "" }
37
37
  rescue => e
38
38
  Volley::Log.warn "error getting version list from publisher: #{e.message}"
39
39
  []
40
40
  end
41
41
 
42
+ def version_data(project, branch, version)
43
+ pr = project.to_s
44
+ br = branch.to_s
45
+ vr = version.to_s
46
+ list = files[:desc][pr][br][vr]
47
+ files = contents(project, branch, version)
48
+ time = list.map { |e| e.last_modified }.sort.uniq.last
49
+ {
50
+ :contents => files,
51
+ :timestamp => time,
52
+ :latest => (latest_version(project, branch) == vr)
53
+ }
54
+ end
55
+
42
56
  def contents(project, branch, version)
43
57
  pr = project.to_s
44
58
  br = branch.to_s
45
59
  vr = version.to_s
46
- r = files[:desc][pr][br][vr].map {|e| e.gsub("#{pr}/#{br}/#{vr}/","")} || [] rescue []
60
+ r = files[:desc][pr][br][vr].map { |e| e.key.gsub("#{pr}/#{br}/#{vr}/", "") } || [] rescue []
47
61
  Volley::Log.info "could not find #{pr}@#{br}:#{vr}" unless r.count > 0
48
62
  r
49
63
  rescue => e
@@ -123,21 +137,22 @@ module Volley
123
137
  end
124
138
 
125
139
  def files
126
- hash = { :desc => { }, :all => { }, :latest => { } }
127
- @connection.directories.get(@bucket).files.collect { |e| e.key }.each do |e|
128
- (pr, br, vr) = e.split(/\//)
129
- hash[:desc][pr] ||= { }
130
- hash[:desc][pr][br] ||= { }
131
- hash[:desc][pr][br][vr] ||= []
132
- hash[:desc][pr][br][vr] << e
133
- hash[:all] ||= { }
134
- hash[:latest] ||= { }
135
- v = "#{pr}/#{br}/#{vr}"
136
- #hash[:latest]["#{pr}/#{br}"] ||= latest(pr, br)
137
- hash[:all][v] = hash["latest"] == v
140
+ @files ||= begin
141
+ hash = { :desc => { }, :all => { }, :latest => { } }
142
+ @connection.directories.get(@bucket).files.each do |e|
143
+ (pr, br, vr) = e.key.split(/\//)
144
+ hash[:desc][pr] ||= { }
145
+ hash[:desc][pr][br] ||= { }
146
+ hash[:desc][pr][br][vr] ||= []
147
+ hash[:desc][pr][br][vr] << e
148
+ hash[:all] ||= { }
149
+ hash[:latest] ||= { }
150
+ v = "#{pr}/#{br}/#{vr}"
151
+ #hash[:latest]["#{pr}/#{br}"] ||= latest(pr, br)
152
+ hash[:all][v] = hash["latest"] == v
153
+ end
154
+ hash
138
155
  end
139
- #ap hash
140
- hash
141
156
  end
142
157
  end
143
158
  end
@@ -12,12 +12,40 @@ module Volley
12
12
  @encrypted = optional(:encrypted, false)
13
13
  @local = optional(:local, Volley.config.directory)
14
14
  @loglevel = @debug ? :info : :debug
15
- @latest = {}
15
+ @latest = { }
16
16
  @force = false
17
17
 
18
18
  load_configuration
19
19
  end
20
20
 
21
+ def list(&block)
22
+ hash = { }
23
+ unsorted = { }
24
+ plist = projects
25
+ plist.each do |p|
26
+ hash[p] = { }
27
+ blist = branches(p)
28
+ blist.each do |b|
29
+ hash[p][b] = { }
30
+ vlist = versions(p, b)
31
+ vlist.each do |v|
32
+ d = version_data(p, b, v)
33
+ hash[p][b][v] = d
34
+ unsorted["#{p}@#{b}:#{v}"] = d if d[:contents] && d[:contents].count > 0
35
+ end
36
+ end
37
+ end
38
+
39
+ sorted = unsorted.sort_by { |k, v| v[:timestamp] }.reverse
40
+ sorted.each do |k, v|
41
+ d = Volley::Descriptor.new(k)
42
+ next unless d
43
+ yield d.project, d.branch, d.version, v
44
+ end
45
+
46
+ hash
47
+ end
48
+
21
49
  def projects
22
50
  raise "not implemented"
23
51
  end
@@ -43,7 +71,7 @@ module Volley
43
71
  end
44
72
 
45
73
  def latest(project, branch)
46
- @latest["#{project}/#{branch}"] ||= pull_file(dir(project,branch), "latest")
74
+ @latest["#{project}/#{branch}"] ||= pull_file(dir(project, branch), "latest")
47
75
  end
48
76
 
49
77
  def latest_version(project, branch)
@@ -51,10 +79,10 @@ module Volley
51
79
  end
52
80
 
53
81
  def volleyfile(project, branch, version="latest")
54
- d = dir(project,branch,version)
82
+ d = dir(project, branch, version)
55
83
  contents = pull_file(d, "Volleyfile")
56
84
 
57
- dest = "#@local/Volleyfile-#{Time.now.to_i}-#{$$}"
85
+ dest = "#@local/Volleyfile-#{Time.now.to_i}-#{$$}"
58
86
  raise "File #{dest} already exists" if File.exists?(dest)
59
87
 
60
88
  log "saving Volleyfile: #{dest}"
@@ -84,7 +112,7 @@ module Volley
84
112
  end
85
113
 
86
114
  def pull(project, branch, version="latest")
87
- dir = dir(project, branch, version)
115
+ dir = dir(project, branch, version)
88
116
  file = remote_file(branch, version)
89
117
 
90
118
  log "vv #{me}#pull"
@@ -122,7 +150,6 @@ module Volley
122
150
  end
123
151
 
124
152
 
125
-
126
153
  def push_file(dir, name, contents)
127
154
  raise "not implemented"
128
155
  end
@@ -18,7 +18,7 @@ module Volley
18
18
  def versions(pr, br)
19
19
  Dir["#@directory/#{pr}/#{br}/*"].map do |e|
20
20
  e.gsub(/#@directory\/#{pr}\/#{br}\//,"")
21
- end
21
+ end.reject {|e| e == "latest" || e == ""}
22
22
  end
23
23
 
24
24
  def exists?(project, branch, version)
@@ -33,6 +33,20 @@ module Volley
33
33
  end
34
34
  end
35
35
 
36
+ def version_data(project, branch, version)
37
+ pr = project.to_s
38
+ br = branch.to_s
39
+ vr = version.to_s
40
+ list = Dir["#@directory/#{project}/#{branch}/#{version}/*"]
41
+ files = contents(project, branch, version)
42
+ time = list.map { |e| File.mtime(e) }.sort.uniq.last
43
+ {
44
+ :contents => files,
45
+ :timestamp => time,
46
+ :latest => (latest_version(project, branch) == vr)
47
+ }
48
+ end
49
+
36
50
  def delete_project(project)
37
51
  FileUtils.rm_rf("#@directory/#{project}")
38
52
  true
@@ -3,7 +3,7 @@ unless defined?(Volley::Version)
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 2
6
+ TINY = 6
7
7
  TAG = nil
8
8
  STRING = [MAJOR, MINOR, TINY, TAG].compact.join('.')
9
9
  end
data/lib/volley.rb CHANGED
@@ -1,8 +1,8 @@
1
- #require "awesome_print"
2
1
  require "ostruct"
3
2
  require "active_support/all"
4
3
 
5
4
  require "volley/version"
5
+ require "volley/exceptions"
6
6
  require "volley/log"
7
7
  require "volley/publisher/base"
8
8
  require "volley/publisher/exceptions"
@@ -45,7 +45,7 @@ shared_examples_for Volley::Publisher::Base do
45
45
  end
46
46
 
47
47
  it "should be able to tell me the list of versions" do
48
- expect(@pub.versions("spec", "trunk")).to match_array(%w{1 2 latest})
48
+ expect(@pub.versions("spec", "trunk")).to match_array(%w{1 2})
49
49
  end
50
50
 
51
51
  it "should be able to tell me the list of files" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-21 00:00:00.000000000 Z
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -133,6 +133,7 @@ extra_rdoc_files: []
133
133
  files:
134
134
  - .gitignore
135
135
  - .rspec
136
+ - CHANGELOG.md
136
137
  - Gemfile
137
138
  - LICENSE
138
139
  - README.md
@@ -157,6 +158,7 @@ files:
157
158
  - lib/volley/dsl/push_action.rb
158
159
  - lib/volley/dsl/stage.rb
159
160
  - lib/volley/dsl/volley_action.rb
161
+ - lib/volley/exceptions.rb
160
162
  - lib/volley/log.rb
161
163
  - lib/volley/meta.rb
162
164
  - lib/volley/publisher/amazons3.rb
@@ -203,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
205
  version: '0'
204
206
  requirements: []
205
207
  rubyforge_project:
206
- rubygems_version: 1.8.21
208
+ rubygems_version: 1.8.24
207
209
  signing_key:
208
210
  specification_version: 3
209
211
  summary: PubSub Deployment tool