highway 0.0.1 → 1.0.1

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/lib/highway.rb +8 -4
  3. data/lib/highway/compiler/analyze/analyzer.rb +249 -0
  4. data/lib/highway/compiler/analyze/tree/root.rb +95 -0
  5. data/lib/highway/compiler/analyze/tree/segments/text.rb +36 -0
  6. data/lib/highway/compiler/analyze/tree/segments/variable.rb +43 -0
  7. data/lib/highway/compiler/analyze/tree/stage.rb +48 -0
  8. data/lib/highway/compiler/analyze/tree/step.rb +69 -0
  9. data/lib/highway/compiler/analyze/tree/values/array.rb +45 -0
  10. data/lib/highway/compiler/analyze/tree/values/base.rb +67 -0
  11. data/lib/highway/compiler/analyze/tree/values/hash.rb +45 -0
  12. data/lib/highway/compiler/analyze/tree/values/primitive.rb +43 -0
  13. data/lib/highway/compiler/analyze/tree/variable.rb +48 -0
  14. data/lib/highway/compiler/build/builder.rb +154 -0
  15. data/lib/highway/compiler/build/output/invocation.rb +70 -0
  16. data/lib/highway/compiler/build/output/manifest.rb +52 -0
  17. data/lib/highway/compiler/parse/parser.rb +92 -0
  18. data/lib/highway/compiler/parse/tree/root.rb +73 -0
  19. data/lib/highway/compiler/parse/tree/step.rb +62 -0
  20. data/lib/highway/compiler/parse/tree/variable.rb +48 -0
  21. data/lib/highway/compiler/parse/versions/v1.rb +110 -0
  22. data/lib/highway/compiler/suite.rb +56 -0
  23. data/lib/highway/environment.rb +282 -0
  24. data/lib/highway/fastlane/action.rb +67 -0
  25. data/lib/highway/interface.rb +135 -0
  26. data/lib/highway/main.rb +173 -0
  27. data/lib/highway/runtime/context.rb +229 -0
  28. data/lib/highway/runtime/report.rb +80 -0
  29. data/lib/highway/runtime/runner.rb +286 -0
  30. data/lib/highway/steps/infrastructure.rb +20 -0
  31. data/lib/highway/steps/library/action.rb +42 -0
  32. data/lib/highway/steps/library/appcenter.rb +106 -0
  33. data/lib/highway/steps/library/appstore.rb +137 -0
  34. data/lib/highway/steps/library/carthage.rb +67 -0
  35. data/lib/highway/steps/library/cocoapods.rb +76 -0
  36. data/lib/highway/steps/library/copy_artifacts.rb +36 -0
  37. data/lib/highway/steps/library/lane.rb +42 -0
  38. data/lib/highway/steps/library/sh.rb +36 -0
  39. data/lib/highway/steps/library/slack.rb +381 -0
  40. data/lib/highway/steps/library/testflight.rb +105 -0
  41. data/lib/highway/steps/library/xcode_archive.rb +162 -0
  42. data/lib/highway/steps/library/xcode_test.rb +264 -0
  43. data/lib/highway/steps/parameters/base.rb +52 -0
  44. data/lib/highway/steps/parameters/compound.rb +141 -0
  45. data/lib/highway/steps/parameters/single.rb +74 -0
  46. data/lib/highway/steps/registry.rb +92 -0
  47. data/lib/highway/steps/step.rb +52 -0
  48. data/lib/highway/steps/types/any.rb +65 -0
  49. data/lib/highway/steps/types/anyof.rb +64 -0
  50. data/lib/highway/steps/types/array.rb +44 -0
  51. data/lib/highway/steps/types/bool.rb +36 -0
  52. data/lib/highway/steps/types/enum.rb +44 -0
  53. data/lib/highway/steps/types/hash.rb +45 -0
  54. data/lib/highway/steps/types/number.rb +38 -0
  55. data/lib/highway/steps/types/set.rb +39 -0
  56. data/lib/highway/steps/types/string.rb +47 -0
  57. data/lib/highway/steps/types/url.rb +35 -0
  58. data/lib/highway/utilities.rb +51 -0
  59. data/lib/highway/version.rb +9 -1
  60. metadata +194 -22
  61. data/.gitignore +0 -4
  62. data/Gemfile +0 -4
  63. data/Rakefile +0 -1
  64. data/highway.gemspec +0 -24
@@ -0,0 +1,64 @@
1
+ #
2
+ # anyof.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents a parameter type that's any of given types.
13
+ class AnyOf < Types::Any
14
+
15
+ public
16
+
17
+ # Initialize an instance.
18
+ #
19
+ # The variadic argument accepts types keyed by a tag symbol. Tags are
20
+ # used to later denote which type the value falls to.
21
+ #
22
+ # Consider a step which defines the following parameter:
23
+ #
24
+ # ```
25
+ # Types::AnyOf(
26
+ # channel: Types::String.regex(/#\w+/),
27
+ # user: Types::String.regex(/@\w+/),
28
+ # )
29
+ # ```
30
+ #
31
+ # Later, when a step which defined such a parameter receives a value,
32
+ # it doesn't receive just a plain `String`, it receives:
33
+ #
34
+ # ```
35
+ # { tag: :channel, value: "#general" }
36
+ # ```
37
+ #
38
+ # Thus retaining the information about which type definition matched
39
+ # the value.
40
+ #
41
+ # @param type_defs [Array] Type definitions. First match wins.
42
+ def initialize(**type_defs)
43
+ super(validate: nil)
44
+ @type_defs = type_defs
45
+ end
46
+
47
+ # Typecheck and coerce a value if possible.
48
+ #
49
+ # This method returns a typechecked and coerced value or `nil` if value
50
+ # has invalid type and can't be coerced.
51
+ #
52
+ # @param value [Object] A value.
53
+ #
54
+ # @return [Object, nil]
55
+ def typecheck(value)
56
+ typechecked_defs = @type_defs.map { |tag, type| {tag: tag, value: type.typecheck_and_validate(value) } }
57
+ typechecked_defs.find { |typechecked_def| typechecked_def[:value] != nil }
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # array.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents an array parameter type.
13
+ class Array < Types::Any
14
+
15
+ public
16
+
17
+ # Initialize an instance.
18
+ #
19
+ # @param element_type [Object] Type of inner elements.
20
+ # @param validate [Proc] A custom value validation block.
21
+ def initialize(element_type, validate: nil)
22
+ super(validate: validate)
23
+ @element_type = element_type
24
+ end
25
+
26
+ # Typecheck and coerce a value if possible.
27
+ #
28
+ # This method returns a typechecked and coerced value or `nil` if value
29
+ # has invalid type and can't be coerced.
30
+ #
31
+ # @param value [Object] A value.
32
+ #
33
+ # @return [Array, nil]
34
+ def typecheck(value)
35
+ return nil unless value.kind_of?(::Array)
36
+ typechecked = value.map { |element| @element_type.typecheck_and_validate(element) }
37
+ typechecked if typechecked.all? { |element| !element.nil? }
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # bool.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents a boolean parameter type.
13
+ class Bool < Types::Any
14
+
15
+ public
16
+
17
+ # Typecheck and coerce a value if possible.
18
+ #
19
+ # This method returns a typechecked and coerced value or `nil` if value
20
+ # has invalid type and can't be coerced.
21
+ #
22
+ # @param value [Object] A value.
23
+ #
24
+ # @return [Boolean, nil]
25
+ def typecheck(value)
26
+ case value
27
+ when ::TrueClass, 1, "1", "true", "yes" then true
28
+ when ::FalseClass, 0, "0", "false", "no" then false
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # enum.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+ require "highway/steps/types/string"
8
+
9
+ module Highway
10
+ module Steps
11
+ module Types
12
+
13
+ # This class represents an enum parameter type. It can be used in
14
+ # parameters which have a finite set of valid values.
15
+ class Enum < Types::String
16
+
17
+ public
18
+
19
+ # Initialize an instance.
20
+ #
21
+ # @param *values [String] Allowed enum values.
22
+ def initialize(*values)
23
+ super(validate: nil)
24
+ @values = values
25
+ end
26
+
27
+ # Typecheck and coerce a value if possible.
28
+ #
29
+ # This method returns a typechecked and coerced value or `nil` if value
30
+ # has invalid type and can't be coerced.
31
+ #
32
+ # @param value [Object] A value.
33
+ #
34
+ # @return [String, nil]
35
+ def typecheck(value)
36
+ typechecked = super(value)
37
+ typechecked if !typechecked.nil? && @values.include?(typechecked)
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # hash.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+ require "highway/utilities"
8
+
9
+ module Highway
10
+ module Steps
11
+ module Types
12
+
13
+ # This class represents a dictionary parameter type.
14
+ class Hash < Types::Any
15
+
16
+ public
17
+
18
+ # Initialize an instance.
19
+ #
20
+ # @param element_type [Object] Type of inner elements.
21
+ # @param validate [Proc] A custom value validation block.
22
+ def initialize(element_type, validate: nil)
23
+ super(validate: validate)
24
+ @element_type = element_type
25
+ end
26
+
27
+ # Typecheck and coerce a value if possible.
28
+ #
29
+ # This method returns a typechecked and coerced value or `nil` if value
30
+ # has invalid type and can't be coerced.
31
+ #
32
+ # @param value [Object] A value.
33
+ #
34
+ # @return [Hash, nil]
35
+ def typecheck(value)
36
+ return nil unless value.is_a?(::Hash)
37
+ typechecked = Utilities::hash_map(value) { |key, element| [key, @element_type.typecheck_and_validate(element)] }
38
+ typechecked if typechecked.values.all? { |element| !element.nil? }
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # number.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents a numeric parameter type. It can be used in
13
+ # parameters which have an integer or float value.
14
+ class Number < Types::Any
15
+
16
+ public
17
+
18
+ # Typecheck and coerce a value if possible.
19
+ #
20
+ # This method returns a typechecked and coerced value or `nil` if value
21
+ # has invalid type and can't be coerced.
22
+ #
23
+ # @param value [Object] A value.
24
+ #
25
+ # @return [Integer, Float, nil]
26
+ def typecheck(value)
27
+ case value
28
+ when ::Numeric then value
29
+ when ::String && value.to_i.to_s == value then value.to_i
30
+ when ::String && value.to_f.to_s == value then value.to_f
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # set.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "set"
7
+
8
+ require "highway/steps/types/any"
9
+
10
+ module Highway
11
+ module Steps
12
+ module Types
13
+
14
+ # This class represents a set parameter type. It's like array but ensures
15
+ # the values occur only once.
16
+ class Set < Types::Array
17
+
18
+ public
19
+
20
+ # Typecheck and coerce a value if possible.
21
+ #
22
+ # This method returns a typechecked and coerced value or `nil` if value
23
+ # has invalid type and can't be coerced.
24
+ #
25
+ # @param value [Object] A value.
26
+ #
27
+ # @return [Set, nil]
28
+ def typecheck(value)
29
+ typechecked_array = super(value)
30
+ return nil if typechecked_array == nil
31
+ typechecked_set = ::Set.new(typechecked_array)
32
+ typechecked_set if typechecked_set.count == typechecked_array.count
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # string.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents a string parameter type.
13
+ class String < Types::Any
14
+
15
+ public
16
+
17
+ # Initialize an instance.
18
+ #
19
+ # @param regex [Regexp] A regular expression string must match.
20
+ #
21
+ # @return [Highway::Steps::Types::String]
22
+ def self.regex(regex)
23
+ self.new(validate: lambda { |value| regex =~ value })
24
+ end
25
+
26
+ # Typecheck and coerce a value if possible.
27
+ #
28
+ # This method returns a typechecked and coerced value or `nil` if value
29
+ # has invalid type and can't be coerced.
30
+ #
31
+ # @param value [Object] A value.
32
+ #
33
+ # @return [String, nil]
34
+ def typecheck(value)
35
+ case value
36
+ when ::String then value
37
+ when ::Numeric then value.to_s
38
+ when ::TrueClass then "true"
39
+ when ::FalseClass then "false"
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # url.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ require "highway/steps/types/any"
7
+
8
+ module Highway
9
+ module Steps
10
+ module Types
11
+
12
+ # This class represents an URL parameter type.
13
+ class Url < Types::String
14
+
15
+ public
16
+
17
+ # Typecheck and coerce a value if possible.
18
+ #
19
+ # This method returns a typechecked and coerced value or `nil` if value
20
+ # has invalid type and can't be coerced.
21
+ #
22
+ # @param value [Object] A value.
23
+ #
24
+ # @return [URI, nil]
25
+ def typecheck(value)
26
+ typechecked = super(value)
27
+ parsed = URI.parse(typechecked) rescue nil
28
+ parsed if parsed && parsed.kind_of?(URI::HTTP)
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # utilities.rb
3
+ # Copyright © 2019 Netguru S.A. All rights reserved.
4
+ #
5
+
6
+ module Highway
7
+
8
+ # This class contains a collection of utility functions used throughout the
9
+ # codebase.
10
+ class Utilities
11
+
12
+ public
13
+
14
+ # Map pairs of keys and values and combine them again into a Hash.
15
+ #
16
+ # @param subject [Hash] An input hash.
17
+ # @param transform [Proc] A transformation block.
18
+ #
19
+ # @return [Hash]
20
+ def self.hash_map(subject, &transform)
21
+ Hash[subject.map(&transform)]
22
+ end
23
+
24
+ # Join keypath into a string.
25
+ #
26
+ # @param keypath [Array<String>] A keypath.
27
+ #
28
+ # @return [String]
29
+ def self.keypath_to_s(keypath)
30
+ keypath.join(".")
31
+ end
32
+
33
+ # Recursively check whether the subject includes an element.
34
+ #
35
+ # @param subject [Object] A haystack.
36
+ # @param element [Object] A needle.
37
+ #
38
+ # @return [Boolean]
39
+ def self.recursive_include?(subject, element)
40
+ if subject.is_a?(Hash)
41
+ recursive_include?(subject.values, element)
42
+ elsif subject.respond_to?(:any?)
43
+ subject.any? { |value| recursive_include?(value, element) }
44
+ else
45
+ subject == element
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end