api_diff 0.3.2 → 0.3.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 +4 -4
- data/lib/api_diff.rb +1 -0
- data/lib/api_diff/api.rb +6 -1
- data/lib/api_diff/struct.rb +4 -0
- data/lib/api_diff/swift_interface_parser.rb +15 -0
- data/lib/api_diff/version.rb +1 -1
- data/test/swift_interface_parser_test.rb +20 -0
- metadata +8 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5f502c34ac580dadc1abab3ddc39102ba86a4f4ec4cade0fe0c616310de5e6ed
         | 
| 4 | 
            +
              data.tar.gz: 1638231a645d0610290f43add23960ca971ef366236d68466fe62a7d9ced26e2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9adadc2b1658936cca2eded8c2e2ca067b46533d9bc32c6a65955e86c4fefaa265729cc9655e2ff0ff853a47c016a99db72c7892b343b50cd7ee1d2f3b528849
         | 
| 7 | 
            +
              data.tar.gz: cd7c77b6ddb6970115eadd74745bc5775808065d15baec0717e8ada95ea3ec6b0611798549d74012b10c46d7957ae71fd75b8d6aed9ff86d0a25dc1a0c85e442
         | 
    
        data/lib/api_diff.rb
    CHANGED
    
    
    
        data/lib/api_diff/api.rb
    CHANGED
    
    | @@ -1,9 +1,10 @@ | |
| 1 1 | 
             
            module ApiDiff
         | 
| 2 2 | 
             
              class Api
         | 
| 3 | 
            -
                attr_accessor :classes, :interfaces, :enums
         | 
| 3 | 
            +
                attr_accessor :classes, :structs, :interfaces, :enums
         | 
| 4 4 |  | 
| 5 5 | 
             
                def initialize
         | 
| 6 6 | 
             
                  @classes = []
         | 
| 7 | 
            +
                  @structs = []
         | 
| 7 8 | 
             
                  @interfaces = []
         | 
| 8 9 | 
             
                  @enums = []
         | 
| 9 10 | 
             
                end
         | 
| @@ -12,6 +13,10 @@ module ApiDiff | |
| 12 13 | 
             
                  classes.find { |c| c.name == named || c.fully_qualified_name == fully_qualified_name }
         | 
| 13 14 | 
             
                end
         | 
| 14 15 |  | 
| 16 | 
            +
                def struct(named: nil, fully_qualified_name: nil)
         | 
| 17 | 
            +
                  structs.find { |s| s.name == named || s.fully_qualified_name == fully_qualified_name }
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 15 20 | 
             
                def interface(named: nil, fully_qualified_name: nil)
         | 
| 16 21 | 
             
                  interfaces.find { |i| i.name == named || i.fully_qualified_name == fully_qualified_name }
         | 
| 17 22 | 
             
                end
         | 
| @@ -17,6 +17,8 @@ module ApiDiff | |
| 17 17 | 
             
                    first_line = section.split("\n")[0]
         | 
| 18 18 | 
             
                    if first_line.include? "public class"
         | 
| 19 19 | 
             
                      parse_class(section, container_types)
         | 
| 20 | 
            +
                    elsif first_line.include? "public struct"
         | 
| 21 | 
            +
                      parse_struct(section, container_types)
         | 
| 20 22 | 
             
                    elsif first_line.include? "public protocol"
         | 
| 21 23 | 
             
                      parse_ptotocol(section, container_types)
         | 
| 22 24 | 
             
                    elsif first_line.start_with? "extension"
         | 
| @@ -46,6 +48,18 @@ module ApiDiff | |
| 46 48 | 
             
                  parse_nested_types(class_content, [*container_types, name])
         | 
| 47 49 | 
             
                end
         | 
| 48 50 |  | 
| 51 | 
            +
                def parse_struct(struct_content, container_types)
         | 
| 52 | 
            +
                  name = struct_content.match(/public struct (\w+)/)[1]
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  struct = Struct.new(name, qualified_name(name, container_types))
         | 
| 55 | 
            +
                  struct.parents = parse_parents(struct_content)
         | 
| 56 | 
            +
                  struct.properties = parse_properties(struct_content)
         | 
| 57 | 
            +
                  struct.functions = parse_functions(struct_content)
         | 
| 58 | 
            +
                  api.structs << struct
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  parse_nested_types(struct_content, [*container_types, name])
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 49 63 | 
             
                def parse_ptotocol(protocol_content, container_types)
         | 
| 50 64 | 
             
                  name = protocol_content.match(/public protocol (\w+)/)[1]
         | 
| 51 65 |  | 
| @@ -62,6 +76,7 @@ module ApiDiff | |
| 62 76 | 
             
                  name = content.match(/extension ([\w\.]+)/)[1]
         | 
| 63 77 |  | 
| 64 78 | 
             
                  base_type = api.class(fully_qualified_name: qualified_name(name, container_types))
         | 
| 79 | 
            +
                  base_type ||= api.struct(fully_qualified_name: qualified_name(name, container_types))
         | 
| 65 80 | 
             
                  base_type ||= api.interface(fully_qualified_name: qualified_name(name, container_types))
         | 
| 66 81 | 
             
                  base_type ||= api.enum(fully_qualified_name: qualified_name(name, container_types))
         | 
| 67 82 | 
             
                  raise Error.new "Unable to find base type for extension `#{name}`" if base_type.nil?
         | 
    
        data/lib/api_diff/version.rb
    CHANGED
    
    
| @@ -43,6 +43,26 @@ class SwiftInterfaceParserTest < Minitest::Test | |
| 43 43 | 
             
                assert_equal "class Fourth : Codable, Hashable", fourth.declaration
         | 
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 | 
            +
              def test_struct
         | 
| 47 | 
            +
                input = <<~EOF
         | 
| 48 | 
            +
                  public struct First {
         | 
| 49 | 
            +
                  }
         | 
| 50 | 
            +
                  public struct Second : Package.Parent {
         | 
| 51 | 
            +
                  }
         | 
| 52 | 
            +
                EOF
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                api = parse(input)
         | 
| 55 | 
            +
                structs = api.structs
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                first = structs[0]
         | 
| 58 | 
            +
                assert_equal "First", first.name
         | 
| 59 | 
            +
                assert_equal "struct First", first.declaration
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                second = structs[1]
         | 
| 62 | 
            +
                assert_equal "Second", second.name
         | 
| 63 | 
            +
                assert_equal "struct Second : Parent", second.declaration
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 46 66 | 
             
              def test_properties
         | 
| 47 67 | 
             
                input = <<~EOF
         | 
| 48 68 | 
             
                  public class FirstClass {
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: api_diff
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sebastian Ludwig
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-06-28 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: minitest
         | 
| @@ -38,7 +38,7 @@ dependencies: | |
| 38 38 | 
             
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: '11'
         | 
| 41 | 
            -
            description: | 
| 41 | 
            +
            description:
         | 
| 42 42 | 
             
            email:
         | 
| 43 43 | 
             
            - sebastian@lurado.de
         | 
| 44 44 | 
             
            executables:
         | 
| @@ -60,6 +60,7 @@ files: | |
| 60 60 | 
             
            - lib/api_diff/kotlin_bcv_parser.rb
         | 
| 61 61 | 
             
            - lib/api_diff/parser.rb
         | 
| 62 62 | 
             
            - lib/api_diff/property.rb
         | 
| 63 | 
            +
            - lib/api_diff/struct.rb
         | 
| 63 64 | 
             
            - lib/api_diff/swift_interface_parser.rb
         | 
| 64 65 | 
             
            - lib/api_diff/type.rb
         | 
| 65 66 | 
             
            - lib/api_diff/version.rb
         | 
| @@ -72,7 +73,7 @@ licenses: | |
| 72 73 | 
             
            metadata:
         | 
| 73 74 | 
             
              homepage_uri: https://github.com/sebastianludwig/api-diff
         | 
| 74 75 | 
             
              source_code_uri: https://github.com/sebastianludwig/api_diff
         | 
| 75 | 
            -
            post_install_message: | 
| 76 | 
            +
            post_install_message:
         | 
| 76 77 | 
             
            rdoc_options: []
         | 
| 77 78 | 
             
            require_paths:
         | 
| 78 79 | 
             
            - lib
         | 
| @@ -87,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 87 88 | 
             
                - !ruby/object:Gem::Version
         | 
| 88 89 | 
             
                  version: '0'
         | 
| 89 90 | 
             
            requirements: []
         | 
| 90 | 
            -
            rubygems_version: 3. | 
| 91 | 
            -
            signing_key: | 
| 91 | 
            +
            rubygems_version: 3.2.15
         | 
| 92 | 
            +
            signing_key:
         | 
| 92 93 | 
             
            specification_version: 4
         | 
| 93 94 | 
             
            summary: Bring APIs into an easily diff-able format
         | 
| 94 95 | 
             
            test_files:
         |