ssource 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddf1f3e17e7c2bed07024eb1c436dde98b82e7b5
4
- data.tar.gz: 8d755340ebcf8602fe862a8d1ee37c8c2e0e8aa6
3
+ metadata.gz: d4c72c5b5334c98667260a99921f8a99f37d5270
4
+ data.tar.gz: d6b4d21fa6c804d11d2c4836752a46ff1981befc
5
5
  SHA512:
6
- metadata.gz: 392ee99ed712d0b12e565c963efc2a0eaa9e5689f0d111015211e606efb86087e5b072a274bdf0e0e474435bf36a7e605bb4250575e21130f7f2000319d3548b
7
- data.tar.gz: e562719e5dfa8dc38fc72249367734f9f1e3beb8f7987f6f5ed0c8c244c45fb687df40479c3063d33e511caeb36a538c5373b71e2f677ae25f855db270db78c3
6
+ metadata.gz: 15f87ac2eb0c7fac01e6ff06afb8e3b96e8259b175731f4781a53f572165394688b01a2ac2a6d5d67050a981f7216568d90dbb34418dd2d70c2f38f88efdd377
7
+ data.tar.gz: 171ff8f43c7a37873b34ce19105647b772c5b0aa8a3883522bcfd0388037f1d4503725d1d719756a7d43c77d2f0677e147095d179cc624ef47abfeb3aebeb4a9
@@ -1,9 +1,9 @@
1
- require_relative 'source/root'
1
+ require_relative 'source/root_object'
2
2
 
3
3
  module Ssource
4
4
  module Source
5
5
  def self.from(file)
6
- Root.new(file)
6
+ RootObject.new(file)
7
7
  end
8
8
  end
9
9
  end
@@ -2,11 +2,21 @@ module Ssource
2
2
  module Source
3
3
  class Element
4
4
  attr_reader :name, :kind, :accessibility, :elements
5
+
6
+ attr_reader :offset, :length, :name_offset, :name_length, :body_offset, :body_length
7
+
5
8
  def initialize(json)
6
9
  @name = json['name']
7
10
  @accessibility = json['accessibility']
8
11
  @kind = json['kind']
9
12
 
13
+ @offset = json['offset']
14
+ @length = json['length']
15
+ @name_offset = json['nameoffset']
16
+ @name_length = json['namelength']
17
+ @body_offset = json['bodyoffset']
18
+ @body_length = json['bodylength']
19
+
10
20
  @elements = json.fetch('substructure', []).reduce([]) do |arr, structure|
11
21
  arr << Factory.build(structure)
12
22
  end
@@ -21,7 +31,7 @@ module Ssource
21
31
  end
22
32
 
23
33
  def pretty_print
24
- dispay_name
34
+ display_name
25
35
  end
26
36
  end
27
37
  end
@@ -3,6 +3,13 @@ require_relative 'klass'
3
3
  module Ssource
4
4
  module Source
5
5
  class Extension < Klass
6
+ def initialize(json)
7
+ super
8
+ if superklass
9
+ @protocols << superklass
10
+ @superklass = nil
11
+ end
12
+ end
6
13
  end
7
14
  end
8
15
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require_relative 'element'
2
3
  require_relative 'method'
3
4
  require_relative 'variable'
@@ -5,8 +6,14 @@ require_relative 'variable'
5
6
  module Ssource
6
7
  module Source
7
8
  class Klass < Element
9
+ attr_reader :superklass
10
+ attr_reader :protocols
11
+
8
12
  def initialize(json)
9
13
  super
14
+ inherited_types = json.fetch('inheritedtypes', []).map { |hash| hash['key.name'] }
15
+ @superklass = inherited_types.first
16
+ @protocols = inherited_types[1..-1] || []
10
17
  end
11
18
 
12
19
  def methods
@@ -37,9 +44,9 @@ module Ssource
37
44
  end
38
45
 
39
46
  def pretty_print
40
- result = elements_variables.each_with_object(super) do |method, hash|
47
+ result = elements_variables.each_with_object({}) do |method, hash|
41
48
  collections = send(method).map(&:pretty_print)
42
- hash[instance_variable.to_s.capitalize] = collections unless collections.empty?
49
+ hash[method.to_s.capitalize] = collections unless collections.empty?
43
50
  end
44
51
  { display_name => result }
45
52
  end
@@ -3,7 +3,7 @@ require_relative 'klass'
3
3
 
4
4
  module Ssource
5
5
  module Source
6
- class Root
6
+ class RootObject
7
7
  extend Forwardable
8
8
 
9
9
  attr_reader :elements
@@ -1,3 +1,3 @@
1
1
  module Ssource
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - draveness
@@ -120,7 +120,7 @@ files:
120
120
  - lib/ssource/source/factory.rb
121
121
  - lib/ssource/source/klass.rb
122
122
  - lib/ssource/source/method.rb
123
- - lib/ssource/source/root.rb
123
+ - lib/ssource/source/root_object.rb
124
124
  - lib/ssource/source/variable.rb
125
125
  - lib/ssource/source_kitten.rb
126
126
  - lib/ssource/version.rb