ddb_ruby 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: '018a12b0c43aec2c7ab3c1812a5efb09687ab71db7f57cc22f0a09f3d908f624'
4
- data.tar.gz: e86e683d47267c30313b0d6f353665e1eb9837e5ba75172bcf922f62f2bfa8db
3
+ metadata.gz: db69d51dc81dfc34084b4e79aabf09ef8e2f16693cd7ecbd0a71c2aa88c25608
4
+ data.tar.gz: a223580cc95afc1a2c40f39503dd8663df4ef1177e5e1c925f0bf6e11b817d75
5
5
  SHA512:
6
- metadata.gz: c680a8e154ab8a7ced526306ae0933a7531d3230ec847be96d4eddf584f93735b7f85d387cffa37e2dc5d1f216551df81e32655b69d2ec7b0684f1ed88218a6b
7
- data.tar.gz: 45d5fa79215b21d015de239f75f4adc76428607fae69d751906069ed707c36b66123a8b35710232932d79f622f7e652baaab25af64984655abab4a1a597db3a7
6
+ metadata.gz: febcf9f7742dda5c546e43aa488b4cfc301685483de310642c2946b1622d91cbfc616cc8f7042a257d2e64999018b9e45581469bcefa6408d60a2b56a50630d5
7
+ data.tar.gz: 03cbd21c17721bdeccd83ebb406db5676e3e47f9d4201c362990ecf99546b75271db04460a059a24ae64365541774ece72db30c010933f6ecabbe935286cec63
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ddb_ruby (0.0.4)
4
+ ddb_ruby (0.0.5)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  multi_json (~> 1.15)
@@ -3,8 +3,8 @@
3
3
  #
4
4
  # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
5
5
  #
6
- # top_level = TopLevel.from_json! "{…}"
7
- # puts top_level.optional_class_features.first
6
+ # character = Character.from_json! "{…}"
7
+ # puts character.optional_class_features.first
8
8
  #
9
9
  # If from_json! succeeds, the value returned matches the schema.
10
10
 
@@ -18,7 +18,7 @@ module DdbRuby
18
18
  include Dry.Types(default: :nominal)
19
19
 
20
20
  Integer = Coercible::Integer
21
- Bool = Types::Params::Bool
21
+ Bool = Coercible::Bool
22
22
  Hash = Coercible::Hash
23
23
  String = Coercible::String
24
24
  Double = Coercible::Float | Coercible::Integer
@@ -662,7 +662,7 @@ module DdbRuby
662
662
  end
663
663
  end
664
664
 
665
- class TopLevelBackground < Dry::Struct
665
+ class CharacterBackground < Dry::Struct
666
666
  attribute :has_custom_background, Types::Bool
667
667
  attribute :definition, CharacteristicsBackgroundClass.optional
668
668
  attribute :definition_id, Types::Nil
@@ -727,7 +727,7 @@ module DdbRuby
727
727
  end
728
728
  end
729
729
 
730
- class Character < Dry::Struct
730
+ class CharacterElement < Dry::Struct
731
731
  attribute :user_id, Types::Integer
732
732
  attribute :username, Types::String
733
733
  attribute :character_id, Types::Integer
@@ -790,7 +790,7 @@ module DdbRuby
790
790
  attribute :public_notes, Types::String
791
791
  attribute :dm_user_id, Types::Integer
792
792
  attribute :dm_username, Types::Username
793
- attribute :characters, Types.Array(Character)
793
+ attribute :characters, Types.Array(CharacterElement)
794
794
 
795
795
  def self.from_dynamic!(d)
796
796
  d = Types::Hash[d]
@@ -802,7 +802,7 @@ module DdbRuby
802
802
  public_notes: d.fetch("publicNotes"),
803
803
  dm_user_id: d.fetch("dmUserId"),
804
804
  dm_username: d.fetch("dmUsername"),
805
- characters: d.fetch("characters").map { |x| Character.from_dynamic!(x) },
805
+ characters: d.fetch("characters").map { |x| CharacterElement.from_dynamic!(x) },
806
806
  )
807
807
  end
808
808
 
@@ -828,6 +828,126 @@ module DdbRuby
828
828
  end
829
829
  end
830
830
 
831
+ class Definition2 < Dry::Struct
832
+ attribute :id, Types::Integer
833
+ attribute :entity_type_id, Types::Integer
834
+ attribute :definition_name, Types::String
835
+ attribute :description, Types::String
836
+ attribute :snippet, Types::String
837
+ attribute :activation, Types::Nil
838
+ attribute :source_id, Types::Integer.optional
839
+ attribute :source_page_number, Types::Integer.optional
840
+ attribute :creature_rules, Types.Array(Types::Any)
841
+ attribute :spell_list_ids, Types.Array(Types::Any)
842
+
843
+ def self.from_dynamic!(d)
844
+ d = Types::Hash[d]
845
+ new(
846
+ id: d.fetch("id"),
847
+ entity_type_id: d.fetch("entityTypeId"),
848
+ definition_name: d.fetch("name"),
849
+ description: d.fetch("description"),
850
+ snippet: d.fetch("snippet"),
851
+ activation: d.fetch("activation"),
852
+ source_id: d.fetch("sourceId"),
853
+ source_page_number: d.fetch("sourcePageNumber"),
854
+ creature_rules: d.fetch("creatureRules"),
855
+ spell_list_ids: d.fetch("spellListIds"),
856
+ )
857
+ end
858
+
859
+ def self.from_json!(json)
860
+ from_dynamic!(JSON.parse(json))
861
+ end
862
+
863
+ def to_dynamic
864
+ {
865
+ "id" => id,
866
+ "entityTypeId" => entity_type_id,
867
+ "name" => definition_name,
868
+ "description" => description,
869
+ "snippet" => snippet,
870
+ "activation" => activation,
871
+ "sourceId" => source_id,
872
+ "sourcePageNumber" => source_page_number,
873
+ "creatureRules" => creature_rules,
874
+ "spellListIds" => spell_list_ids,
875
+ }
876
+ end
877
+
878
+ def to_json(options = nil)
879
+ JSON.generate(to_dynamic, options)
880
+ end
881
+ end
882
+
883
+ class OptionsClass < Dry::Struct
884
+ attribute :component_id, Types::Integer
885
+ attribute :component_type_id, Types::Integer
886
+ attribute :definition, Definition2
887
+
888
+ def self.from_dynamic!(d)
889
+ d = Types::Hash[d]
890
+ new(
891
+ component_id: d.fetch("componentId"),
892
+ component_type_id: d.fetch("componentTypeId"),
893
+ definition: Definition2.from_dynamic!(d.fetch("definition")),
894
+ )
895
+ end
896
+
897
+ def self.from_json!(json)
898
+ from_dynamic!(JSON.parse(json))
899
+ end
900
+
901
+ def to_dynamic
902
+ {
903
+ "componentId" => component_id,
904
+ "componentTypeId" => component_type_id,
905
+ "definition" => definition.to_dynamic,
906
+ }
907
+ end
908
+
909
+ def to_json(options = nil)
910
+ JSON.generate(to_dynamic, options)
911
+ end
912
+ end
913
+
914
+ class Options < Dry::Struct
915
+ attribute :race, Types.Array(OptionsClass)
916
+ attribute :options_class, Types.Array(OptionsClass)
917
+ attribute :background, Types::Nil
918
+ attribute :item, Types::Nil
919
+ attribute :feat, Types.Array(OptionsClass)
920
+
921
+ def self.from_dynamic!(d)
922
+ d = Types::Hash[d]
923
+ new(
924
+ race: d.fetch("race").map { |x| OptionsClass.from_dynamic!(x) },
925
+ options_class: d.fetch("class").map { |x| OptionsClass.from_dynamic!(x) },
926
+ background: d.fetch("background"),
927
+ item: d.fetch("item"),
928
+ feat: d.fetch("feat").map { |x| OptionsClass.from_dynamic!(x) },
929
+ )
930
+ end
931
+
932
+ def self.from_json!(json)
933
+ from_dynamic!(JSON.parse(json))
934
+ end
935
+
936
+ def to_dynamic
937
+ {
938
+ "race" => race.map { |x| x.to_dynamic },
939
+ "class" => options_class.map { |x| x.to_dynamic },
940
+ "background" => background,
941
+ "item" => item,
942
+ "feat" => feat.map { |x| x.to_dynamic },
943
+ }
944
+ end
945
+
946
+ def to_json(options = nil)
947
+ JSON.generate(to_dynamic, options)
948
+ end
949
+ end
950
+
831
951
  class CharacterValue < Dry::Struct
832
952
  attribute :type_id, Types::Integer
833
953
  attribute :value, Types::Integer
@@ -2312,7 +2432,7 @@ module DdbRuby
2312
2432
  end
2313
2433
  end
2314
2434
 
2315
- class TopLevelClass < Dry::Struct
2435
+ class CharacterClass < Dry::Struct
2316
2436
  attribute :id, Types::Integer
2317
2437
  attribute :entity_type_id, Types::Integer
2318
2438
  attribute :level, Types::Integer
@@ -2364,7 +2484,7 @@ module DdbRuby
2364
2484
  end
2365
2485
  end
2366
2486
 
2367
- class TopLevelCondition < Dry::Struct
2487
+ class CharacterCondition < Dry::Struct
2368
2488
  attribute :id, Types::Integer
2369
2489
  attribute :level, Types::Integer
2370
2490
 
@@ -3855,126 +3975,6 @@ module DdbRuby
3855
3975
  Active = "active"
3856
3976
  end
3857
3977
 
3858
- class Definition2 < Dry::Struct
3859
- attribute :id, Types::Integer
3860
- attribute :entity_type_id, Types::Integer
3861
- attribute :definition_name, Types::String
3862
- attribute :description, Types::String
3863
- attribute :snippet, Types::String
3864
- attribute :activation, Types::Nil
3865
- attribute :source_id, Types::Integer.optional
3866
- attribute :source_page_number, Types::Integer.optional
3867
- attribute :creature_rules, Types.Array(Types::Any)
3868
- attribute :spell_list_ids, Types.Array(Types::Any)
3869
-
3870
- def self.from_dynamic!(d)
3871
- d = Types::Hash[d]
3872
- new(
3873
- id: d.fetch("id"),
3874
- entity_type_id: d.fetch("entityTypeId"),
3875
- definition_name: d.fetch("name"),
3876
- description: d.fetch("description"),
3877
- snippet: d.fetch("snippet"),
3878
- activation: d.fetch("activation"),
3879
- source_id: d.fetch("sourceId"),
3880
- source_page_number: d.fetch("sourcePageNumber"),
3881
- creature_rules: d.fetch("creatureRules"),
3882
- spell_list_ids: d.fetch("spellListIds"),
3883
- )
3884
- end
3885
-
3886
- def self.from_json!(json)
3887
- from_dynamic!(JSON.parse(json))
3888
- end
3889
-
3890
- def to_dynamic
3891
- {
3892
- "id" => id,
3893
- "entityTypeId" => entity_type_id,
3894
- "name" => definition_name,
3895
- "description" => description,
3896
- "snippet" => snippet,
3897
- "activation" => activation,
3898
- "sourceId" => source_id,
3899
- "sourcePageNumber" => source_page_number,
3900
- "creatureRules" => creature_rules,
3901
- "spellListIds" => spell_list_ids,
3902
- }
3903
- end
3904
-
3905
- def to_json(options = nil)
3906
- JSON.generate(to_dynamic, options)
3907
- end
3908
- end
3909
-
3910
- class OptionsClass < Dry::Struct
3911
- attribute :component_id, Types::Integer
3912
- attribute :component_type_id, Types::Integer
3913
- attribute :definition, Definition2
3914
-
3915
- def self.from_dynamic!(d)
3916
- d = Types::Hash[d]
3917
- new(
3918
- component_id: d.fetch("componentId"),
3919
- component_type_id: d.fetch("componentTypeId"),
3920
- definition: Definition2.from_dynamic!(d.fetch("definition")),
3921
- )
3922
- end
3923
-
3924
- def self.from_json!(json)
3925
- from_dynamic!(JSON.parse(json))
3926
- end
3927
-
3928
- def to_dynamic
3929
- {
3930
- "componentId" => component_id,
3931
- "componentTypeId" => component_type_id,
3932
- "definition" => definition.to_dynamic,
3933
- }
3934
- end
3935
-
3936
- def to_json(options = nil)
3937
- JSON.generate(to_dynamic, options)
3938
- end
3939
- end
3940
-
3941
- class Options < Dry::Struct
3942
- attribute :race, Types.Array(OptionsClass)
3943
- attribute :options_class, Types.Array(OptionsClass)
3944
- attribute :background, Types::Nil
3945
- attribute :item, Types::Nil
3946
- attribute :feat, Types.Array(OptionsClass)
3947
-
3948
- def self.from_dynamic!(d)
3949
- d = Types::Hash[d]
3950
- new(
3951
- race: d.fetch("race").map { |x| OptionsClass.from_dynamic!(x) },
3952
- options_class: d.fetch("class").map { |x| OptionsClass.from_dynamic!(x) },
3953
- background: d.fetch("background"),
3954
- item: d.fetch("item"),
3955
- feat: d.fetch("feat").map { |x| OptionsClass.from_dynamic!(x) },
3956
- )
3957
- end
3958
-
3959
- def self.from_json!(json)
3960
- from_dynamic!(JSON.parse(json))
3961
- end
3962
-
3963
- def to_dynamic
3964
- {
3965
- "race" => race.map { |x| x.to_dynamic },
3966
- "class" => options_class.map { |x| x.to_dynamic },
3967
- "background" => background,
3968
- "item" => item,
3969
- "feat" => feat.map { |x| x.to_dynamic },
3970
- }
3971
- end
3972
-
3973
- def to_json(options = nil)
3974
- JSON.generate(to_dynamic, options)
3975
- end
3976
- end
3977
-
3978
3978
  class Traits < Dry::Struct
3979
3979
  attribute :personality_traits, Types::String.optional
3980
3980
  attribute :ideals, Types::String.optional
@@ -4012,14 +4012,14 @@ module DdbRuby
4012
4012
  end
4013
4013
  end
4014
4014
 
4015
- class TopLevel < Dry::Struct
4015
+ class Character < Dry::Struct
4016
4016
  attribute :id, Types::Integer
4017
4017
  attribute :user_id, Types::Integer
4018
4018
  attribute :username, Types::Username
4019
4019
  attribute :is_assigned_to_player, Types::Bool
4020
4020
  attribute :readonly_url, Types::String
4021
4021
  attribute :decorations, Decorations
4022
- attribute :top_level_name, Types::String
4022
+ attribute :character_name, Types::String
4023
4023
  attribute :social_name, Types::Nil
4024
4024
  attribute :gender, Types::String.optional
4025
4025
  attribute :faith, Types::String.optional
@@ -4041,7 +4041,7 @@ module DdbRuby
4041
4041
  attribute :stats, Types.Array(Stat)
4042
4042
  attribute :bonus_stats, Types.Array(Stat)
4043
4043
  attribute :override_stats, Types.Array(Stat)
4044
- attribute :background, TopLevelBackground
4044
+ attribute :background, CharacterBackground
4045
4045
  attribute :race, Race.optional
4046
4046
  attribute :race_definition_id, Types::Nil
4047
4047
  attribute :race_definition_type_id, Types::Nil
@@ -4052,7 +4052,7 @@ module DdbRuby
4052
4052
  attribute :lifestyle, Types::Nil
4053
4053
  attribute :inventory, Types.Array(Inventory)
4054
4054
  attribute :currencies, Currencies
4055
- attribute :classes, Types.Array(TopLevelClass)
4055
+ attribute :classes, Types.Array(CharacterClass)
4056
4056
  attribute :feats, Types.Array(Feat)
4057
4057
  attribute :features, Types.Array(Types::Any)
4058
4058
  attribute :custom_defense_adjustments, Types.Array(Types::Any)
@@ -4061,14 +4061,14 @@ module DdbRuby
4061
4061
  attribute :custom_proficiencies, Types.Array(Types::Any)
4062
4062
  attribute :custom_actions, Types.Array(Types::Any)
4063
4063
  attribute :character_values, Types.Array(CharacterValue)
4064
- attribute :conditions, Types.Array(TopLevelCondition)
4064
+ attribute :conditions, Types.Array(CharacterCondition)
4065
4065
  attribute :death_saves, DeathSaves
4066
4066
  attribute :adjustment_xp, Types::Integer.optional
4067
4067
  attribute :spell_slots, Types.Array(PactMagic)
4068
4068
  attribute :pact_magic, Types.Array(PactMagic)
4069
4069
  attribute :active_source_categories, Types.Array(Types::Integer)
4070
4070
  attribute :spells, Spells
4071
- attribute :top_level_options, Options
4071
+ attribute :character_options, Options
4072
4072
  attribute :choices, Choices
4073
4073
  attribute :actions, Actions
4074
4074
  attribute :modifiers, Modifiers
@@ -4094,7 +4094,7 @@ module DdbRuby
4094
4094
  is_assigned_to_player: d.fetch("isAssignedToPlayer"),
4095
4095
  readonly_url: d.fetch("readonlyUrl"),
4096
4096
  decorations: Decorations.from_dynamic!(d.fetch("decorations")),
4097
- top_level_name: d.fetch("name"),
4097
+ character_name: d.fetch("name"),
4098
4098
  social_name: d.fetch("socialName"),
4099
4099
  gender: d.fetch("gender"),
4100
4100
  faith: d.fetch("faith"),
@@ -4116,7 +4116,7 @@ module DdbRuby
4116
4116
  stats: d.fetch("stats").map { |x| Stat.from_dynamic!(x) },
4117
4117
  bonus_stats: d.fetch("bonusStats").map { |x| Stat.from_dynamic!(x) },
4118
4118
  override_stats: d.fetch("overrideStats").map { |x| Stat.from_dynamic!(x) },
4119
- background: TopLevelBackground.from_dynamic!(d.fetch("background")),
4119
+ background: CharacterBackground.from_dynamic!(d.fetch("background")),
4120
4120
  race: d.fetch("race") ? Race.from_dynamic!(d.fetch("race")) : nil,
4121
4121
  race_definition_id: d.fetch("raceDefinitionId"),
4122
4122
  race_definition_type_id: d.fetch("raceDefinitionTypeId"),
@@ -4127,7 +4127,7 @@ module DdbRuby
4127
4127
  lifestyle: d.fetch("lifestyle"),
4128
4128
  inventory: d.fetch("inventory").map { |x| Inventory.from_dynamic!(x) },
4129
4129
  currencies: Currencies.from_dynamic!(d.fetch("currencies")),
4130
- classes: d.fetch("classes").map { |x| TopLevelClass.from_dynamic!(x) },
4130
+ classes: d.fetch("classes").map { |x| CharacterClass.from_dynamic!(x) },
4131
4131
  feats: d.fetch("feats").map { |x| Feat.from_dynamic!(x) },
4132
4132
  features: d.fetch("features"),
4133
4133
  custom_defense_adjustments: d.fetch("customDefenseAdjustments"),
@@ -4136,14 +4136,14 @@ module DdbRuby
4136
4136
  custom_proficiencies: d.fetch("customProficiencies"),
4137
4137
  custom_actions: d.fetch("customActions"),
4138
4138
  character_values: d.fetch("characterValues").map { |x| CharacterValue.from_dynamic!(x) },
4139
- conditions: d.fetch("conditions").map { |x| TopLevelCondition.from_dynamic!(x) },
4139
+ conditions: d.fetch("conditions").map { |x| CharacterCondition.from_dynamic!(x) },
4140
4140
  death_saves: DeathSaves.from_dynamic!(d.fetch("deathSaves")),
4141
4141
  adjustment_xp: d.fetch("adjustmentXp"),
4142
4142
  spell_slots: d.fetch("spellSlots").map { |x| PactMagic.from_dynamic!(x) },
4143
4143
  pact_magic: d.fetch("pactMagic").map { |x| PactMagic.from_dynamic!(x) },
4144
4144
  active_source_categories: d.fetch("activeSourceCategories"),
4145
4145
  spells: Spells.from_dynamic!(d.fetch("spells")),
4146
- top_level_options: Options.from_dynamic!(d.fetch("options")),
4146
+ character_options: Options.from_dynamic!(d.fetch("options")),
4147
4147
  choices: Choices.from_dynamic!(d.fetch("choices")),
4148
4148
  actions: Actions.from_dynamic!(d.fetch("actions")),
4149
4149
  modifiers: Modifiers.from_dynamic!(d.fetch("modifiers")),
@@ -4174,7 +4174,7 @@ module DdbRuby
4174
4174
  "isAssignedToPlayer" => is_assigned_to_player,
4175
4175
  "readonlyUrl" => readonly_url,
4176
4176
  "decorations" => decorations.to_dynamic,
4177
- "name" => top_level_name,
4177
+ "name" => character_name,
4178
4178
  "socialName" => social_name,
4179
4179
  "gender" => gender,
4180
4180
  "faith" => faith,
@@ -4223,7 +4223,7 @@ module DdbRuby
4223
4223
  "pactMagic" => pact_magic.map { |x| x.to_dynamic },
4224
4224
  "activeSourceCategories" => active_source_categories,
4225
4225
  "spells" => spells.to_dynamic,
4226
- "options" => top_level_options.to_dynamic,
4226
+ "options" => character_options.to_dynamic,
4227
4227
  "choices" => choices.to_dynamic,
4228
4228
  "actions" => actions.to_dynamic,
4229
4229
  "modifiers" => modifiers.to_dynamic,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DdbRuby
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddb_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron F Stanton