petasos 0.5.2 → 0.5.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/petasos.rb +22 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb623c372e4177df95553923e61d111337bb01b28ace724d443d2a2014631ad2
4
- data.tar.gz: b914c31bbd9c6743f662c051b881ca9e9195542e5ec6b7b1c8890b33496470a6
3
+ metadata.gz: aa99f3e5d9f11e0330a51234fbfa8ed194368cf471a3d70306e4751fdd716e79
4
+ data.tar.gz: dd22a538aab970b00ab9535c034ff07c44562b6d80fd7bf7b6abaf461bcacfb2
5
5
  SHA512:
6
- metadata.gz: 8882b063964e50f3c3e6109d652eedac094c619007d173760ccc769c2452b86ab875b1355c5434d431e20a1e634624dd642207484f76d1c13de6bcc96ceaa03d
7
- data.tar.gz: 5e545b2c1fbe779f1effa4641fe3fa93b5f46aa60611bacaae6e24d9b57a5809fe5bac79c17ab5f996dfa80a62dfe2258b6289faa3ba9a817653b81f43e1adfd
6
+ metadata.gz: fba6de2e29d35efcba72bed8d2fe2afad5b63aa45aab4d1924da9e81e6ea9e6916984ecdf4b0ee3a06bc7d15a66279267a0cda77596f85955ca1092f2fb59625
7
+ data.tar.gz: b2f040050ae79ca54120ed1aabc94b0933ab9258a685f51129b5e5d04b09b0a6b9cdf79da88391ffd8fcd320ba5010004baf394f370c1330d80a0e3ccff45b2d
data/lib/petasos.rb CHANGED
@@ -7,14 +7,30 @@ class Petasos
7
7
  class Error < StandardError; end
8
8
 
9
9
  def run(mode = "")
10
- unless File.file?("petasos_is_running")
11
- `touch petasos_is_running`
12
- process_locations
13
- unless mode == "locations"
14
- process_distribution if File.file?(File.join(Dir.pwd, "petasos_distribution-config.yaml"))
10
+ if mode == "locations"
11
+ lock_and_run("locations") do
15
12
  process_locations
16
13
  end
17
- `rm petasos_is_running`
14
+ elsif mode == "distribution"
15
+ lock_and_run("distribution") do
16
+ process_distribution
17
+ end
18
+ else # mode is neither distribution or locations
19
+ lock_and_run("locations") do
20
+ process_locations
21
+ end
22
+ lock_and_run("distribution") do
23
+ process_distribution
24
+ end
25
+ end
26
+ end
27
+
28
+ def lock_and_run(mode, &block)
29
+ lock_filename = "petasos_is_running_#{mode}"
30
+ if !File.file?(lock_filename)
31
+ `touch #{lock_filename}`
32
+ yield
33
+ `rm #{lock_filename}`
18
34
  end
19
35
  end
20
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petasos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Myers