schema_dot_org 1.0.1 → 1.2.0
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/Gemfile.lock +1 -1
 - data/README.md +1 -0
 - data/lib/schema_dot_org.rb +18 -0
 - data/lib/schema_dot_org/organization.rb +1 -2
 - data/lib/schema_dot_org/person.rb +1 -2
 - data/lib/schema_dot_org/place.rb +1 -2
 - data/lib/schema_dot_org/version.rb +1 -1
 - data/lib/schema_dot_org/web_site.rb +22 -0
 - data/test-script.rb +8 -1
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 05e64a986c95f51a4c09c880b9fc922c5e78c63bd238ad886934a82da85b82a3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9271738e29bfb17acba96dc538f21e8fa867c35ff91f4b717c37b84452ae5872
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2042feb05893352d1b10dd12d059e026bf175730beaf5b176f49cb2e8a6f5d88fd2b2b9eafa2e9e0d5ad13699bd8dad1b58e878bc6af5f153a99a825506f1513
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6645f5d6361ebeda245d33446e519050e7131b0cbc55e432e490c9fc952afd9681833e904b4cab69971d8ceb485f6337f3114b060b602c3fd7bcce4605e6eca4
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    
    
        data/lib/schema_dot_org.rb
    CHANGED
    
    | 
         @@ -30,5 +30,23 @@ module SchemaDotOrg 
     | 
|
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # Use the class name to create the "@type" attribute.
         
     | 
| 
      
 35 
     | 
    
         
            +
                # @return a hash structure representing json.
         
     | 
| 
      
 36 
     | 
    
         
            +
                def to_json_struct
         
     | 
| 
      
 37 
     | 
    
         
            +
                  { "@type" => un_namespaced_classname }.merge( _to_json_struct )
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                def _to_json_struct
         
     | 
| 
      
 42 
     | 
    
         
            +
                  raise "For subclasses to implement"
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                # @return the classname without the module namespace.
         
     | 
| 
      
 47 
     | 
    
         
            +
                def un_namespaced_classname
         
     | 
| 
      
 48 
     | 
    
         
            +
                  self.class.name =~ /([^:]+)$/
         
     | 
| 
      
 49 
     | 
    
         
            +
                  $1
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
       33 
51 
     | 
    
         
             
              end
         
     | 
| 
       34 
52 
     | 
    
         
             
            end
         
     | 
    
        data/lib/schema_dot_org/place.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'schema_dot_org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module SchemaDotOrg
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Model the Schema.org `Thing > CreativeWork > WebSite`.  
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @See http://schema.org/WebSite
         
     | 
| 
      
 7 
     | 
    
         
            +
              class WebSite < SchemaType
         
     | 
| 
      
 8 
     | 
    
         
            +
                attr_accessor :name
         
     | 
| 
      
 9 
     | 
    
         
            +
                validates :name, type: String, presence: true
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                attr_accessor :url
         
     | 
| 
      
 12 
     | 
    
         
            +
                validates :url, type: String, presence: true
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def _to_json_struct
         
     | 
| 
      
 15 
     | 
    
         
            +
                  {
         
     | 
| 
      
 16 
     | 
    
         
            +
                    name: self.name,
         
     | 
| 
      
 17 
     | 
    
         
            +
                    url:  self.url
         
     | 
| 
      
 18 
     | 
    
         
            +
                  }
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
    
        data/test-script.rb
    CHANGED
    
    | 
         @@ -3,6 +3,7 @@ require 'date' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'schema_dot_org/person'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'schema_dot_org/place'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'schema_dot_org/organization'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'schema_dot_org/web_site'
         
     | 
| 
       6 
7 
     | 
    
         
             
            include SchemaDotOrg
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
9 
     | 
    
         | 
| 
         @@ -20,4 +21,10 @@ public_law = Organization.new do |org| 
     | 
|
| 
       20 
21 
     | 
    
         
             
              end
         
     | 
| 
       21 
22 
     | 
    
         
             
            end
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
            site_info = WebSite.new do |website|
         
     | 
| 
      
 25 
     | 
    
         
            +
              website.name = 'Texas Public Law'
         
     | 
| 
      
 26 
     | 
    
         
            +
              website.url  = 'https://texas.public.law'
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            puts site_info
         
     | 
| 
      
 30 
     | 
    
         
            +
            puts public_law
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: schema_dot_org
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Robb Shecter
         
     | 
| 
         @@ -89,6 +89,7 @@ files: 
     | 
|
| 
       89 
89 
     | 
    
         
             
            - lib/schema_dot_org/person.rb
         
     | 
| 
       90 
90 
     | 
    
         
             
            - lib/schema_dot_org/place.rb
         
     | 
| 
       91 
91 
     | 
    
         
             
            - lib/schema_dot_org/version.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/schema_dot_org/web_site.rb
         
     | 
| 
       92 
93 
     | 
    
         
             
            - schema_dot_org.gemspec
         
     | 
| 
       93 
94 
     | 
    
         
             
            - test-script.rb
         
     | 
| 
       94 
95 
     | 
    
         
             
            homepage: https://github.com/dogweather/schema-dot-org
         
     |