run_loop 1.2.2 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48987ab3216b9f32eca927721cdbfa4e81d5f4bd
4
- data.tar.gz: 790af8c1087bf824cc75147fa1b636210b268674
3
+ metadata.gz: 9da716f7c4eedfede252a5aaac22eae7f1ee78a2
4
+ data.tar.gz: 957fa9424bbf824af7abf0c95c92875a9d823f4b
5
5
  SHA512:
6
- metadata.gz: 0a8aec93d2cb4922b59b116d4b7c478301ce8597e3ef359ccccc567f48052c616f81ea97b38bed46825e55b8589da516ead349f9c1b2fc44fcbe06d2fb18b629
7
- data.tar.gz: 1997c6e2ac97f2c38be03468654c55dce4973d36e764bf211c7b8d3fd7d8813ca0452610b203e432779744d3c202d51fb0dc9f0324f8d77eca457b735063b15e
6
+ metadata.gz: b360c995c90565518d15b3a79431211010e123f10a05712a25b2061e8ce50d650ce3993e2cbe6ce7fadf1710019082ef61bcf058ef92949e7da15edc8c1d1cc4
7
+ data.tar.gz: 0dc1b9c88db2367aec2a565c1813bab0772cf863fbc8237316db452930875ff5cb1bb2ee6fbee94d393eeac5a09028c755c04449b536aca01799fbc2dccc03fc
data/lib/run_loop.rb CHANGED
@@ -6,4 +6,4 @@ require 'run_loop/sim_control'
6
6
  require 'run_loop/device'
7
7
  require 'run_loop/instruments'
8
8
  require 'run_loop/lipo'
9
-
9
+ require 'run_loop/host_cache'
data/lib/run_loop/core.rb CHANGED
@@ -170,6 +170,7 @@ module RunLoop
170
170
  uia_strategy = options[:uia_strategy]
171
171
  if uia_strategy == :host
172
172
  create_uia_pipe(repl_path)
173
+ RunLoop::HostCache.default.clear
173
174
  end
174
175
 
175
176
  cal_script = File.join(SCRIPTS_PATH, 'calabash_script_uia.js')
@@ -409,11 +410,11 @@ module RunLoop
409
410
  # version.
410
411
  def self.default_simulator(xcode_tools=RunLoop::XCTools.new)
411
412
  if xcode_tools.xcode_version_gte_62?
412
- 'iPhone 5 (8.2 Simulator)'
413
+ 'iPhone 5s (8.2 Simulator)'
413
414
  elsif xcode_tools.xcode_version_gte_61?
414
- 'iPhone 5 (8.1 Simulator)'
415
+ 'iPhone 5s (8.1 Simulator)'
415
416
  elsif xcode_tools.xcode_version_gte_6?
416
- 'iPhone 5 (8.0 Simulator)'
417
+ 'iPhone 5s (8.0 Simulator)'
417
418
  else
418
419
  'iPhone Retina (4-inch) - Simulator - iOS 7.1'
419
420
  end
@@ -511,7 +512,7 @@ module RunLoop
511
512
  raise RunLoop::WriteFailedError.new("Trying write of command #{cmd_str} at index #{index}")
512
513
  end
513
514
  run_loop[:index] = index + 1
514
-
515
+ RunLoop::HostCache.default.write(run_loop)
515
516
  index
516
517
  end
517
518
 
@@ -534,7 +535,6 @@ module RunLoop
534
535
  end
535
536
 
536
537
  def self.read_response(run_loop, expected_index, empty_file_timeout=10, search_for_property='index')
537
-
538
538
  log_file = run_loop[:log_file]
539
539
  initial_offset = run_loop[:initial_offset] || 0
540
540
  offset = initial_offset
@@ -606,9 +606,8 @@ module RunLoop
606
606
  end
607
607
 
608
608
  run_loop[:initial_offset] = offset
609
-
609
+ RunLoop::HostCache.default.write(run_loop)
610
610
  result
611
-
612
611
  end
613
612
 
614
613
  # @deprecated 1.0.5
@@ -0,0 +1,106 @@
1
+ require 'fileutils'
2
+ require 'digest/sha1'
3
+
4
+ module RunLoop
5
+
6
+ # @!visibility private
7
+ # A class for managing an on-disk hash table that represents the current
8
+ # state of the :host strategy run-loop. It is used by Calabash iOS
9
+ # `console_attach` method.
10
+ # @see http://calabashapi.xamarin.com/ios/Calabash/Cucumber/Core.html#console_attach-instance_method
11
+ #
12
+ # Marshal is safe to use here because:
13
+ # 1. This code is not executed on the XTC.
14
+ # 2. Users who muck about with this cache can only hurt themselves.
15
+ class HostCache
16
+
17
+ # The path to the cache file.
18
+ #
19
+ # @!attribute [r] path
20
+ # @return [String] An expanded path to the cache file.
21
+ attr_reader :path
22
+
23
+ # The directory where the cache is stored.
24
+ # @return [String] Expanded path to the default cache directory.
25
+ def self.default_directory
26
+ File.expand_path('/tmp/run-loop-host-cache')
27
+ end
28
+
29
+ # The default cache.
30
+ def self.default
31
+ RunLoop::HostCache.new(self.default_directory)
32
+ end
33
+
34
+ # Creates a new HostCache that is ready for IO.
35
+ #
36
+ # @param [String] directory The directory where the cache file is located.
37
+ # If the directory does not exist, it will be created.
38
+ # @options [Hash] options Options to control the state of the new object.
39
+ # @option [String] filename (host_run_loop.hash) The cache filename.
40
+ # @option [Boolean] clear (false) If true, the current cache will be cleared.
41
+ # @return [RunLoop::HostCache] A cache that is ready for IO.
42
+ def initialize(directory, options = {})
43
+ sha1 = Digest::SHA1.hexdigest 'host_run_loop.hash'
44
+ default_opts = {:filename => sha1,
45
+ :clear => false}
46
+ merged_opts = default_opts.merge(options)
47
+
48
+ dir_expanded = File.expand_path(directory)
49
+ unless Dir.exist?(dir_expanded)
50
+ FileUtils.mkdir_p(dir_expanded)
51
+ end
52
+
53
+ @path = File.join(dir_expanded, merged_opts[:filename])
54
+
55
+ if merged_opts[:clear] && File.exist?(@path)
56
+ FileUtils.rm_rf @path
57
+ end
58
+ end
59
+
60
+ # Reads the current cache.
61
+ # @return [Hash] A hash representation of the current state of the run-loop.
62
+ def read
63
+ if File.exist? @path
64
+ File.open(@path) do |file|
65
+ Marshal.load(file)
66
+ end
67
+ else
68
+ self.write({})
69
+ self.read
70
+ end
71
+ end
72
+
73
+ # @!visibility private
74
+ #
75
+ # Writes `hash` as a serial object. The existing data is overwritten.
76
+ #
77
+ # @param [Hash] hash The hash to write.
78
+ # @raise [ArgumentError] The `hash` parameter must not be nil and it must
79
+ # be a Hash.
80
+ # @raise [TypeError] If the hash contains objects that cannot be written
81
+ # by Marshal.dump.
82
+ #
83
+ # @return [Boolean] Returns true if `hash` was successfully Marshal.dump'ed.
84
+ def write(hash)
85
+ if hash.nil?
86
+ raise ArgumentError, 'Expected the hash parameter to be non-nil'
87
+ end
88
+
89
+ unless hash.is_a?(Hash)
90
+ raise ArgumentError, "Expected #{hash} to a Hash, but it is a #{hash.class}"
91
+ end
92
+
93
+ File.open(@path, 'w+') do |file|
94
+ Marshal.dump(hash, file)
95
+ end
96
+ true
97
+ end
98
+
99
+ # @!visibility private
100
+ # Clears the current cache.
101
+ # @return [Boolean] Returns true if the hash was cleared.
102
+ def clear
103
+ self.write({})
104
+ end
105
+ end
106
+ end
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
@@ -148,11 +148,14 @@ module RunLoop
148
148
  return a.patch.to_i > b.patch.to_i ? 1 : -1
149
149
  end
150
150
 
151
- return 1 if a.pre and (not b.pre)
152
- return -1 if (not a.pre) and b.pre
151
+ return -1 if a.pre and (not a.pre_version) and b.pre_version
152
+ return 1 if a.pre_version and b.pre and (not b.pre_version)
153
153
 
154
- return 1 if a.pre_version and (not b.pre_version)
155
- return -1 if (not a.pre_version) and b.pre_version
154
+ return -1 if a.pre and (not b.pre)
155
+ return 1 if (not a.pre) and b.pre
156
+
157
+ return -1 if a.pre_version and (not b.pre_version)
158
+ return 1 if (not a.pre_version) and b.pre_version
156
159
 
157
160
  if a.pre_version != b.pre_version
158
161
  return a.pre_version.to_i > b.pre_version.to_i ? 1 : -1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.1
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.8.1
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: retriable
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -221,6 +221,7 @@ files:
221
221
  - lib/run_loop/cli.rb
222
222
  - lib/run_loop/core.rb
223
223
  - lib/run_loop/device.rb
224
+ - lib/run_loop/host_cache.rb
224
225
  - lib/run_loop/instruments.rb
225
226
  - lib/run_loop/lipo.rb
226
227
  - lib/run_loop/plist_buddy.rb