microdata_schema 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/microdata.rb +4 -0
- data/lib/microdata/schema.rb +121 -0
- data/lib/microdata/schema/data_type/boolean.rb +10 -0
- data/lib/microdata/schema/data_type/boolean/false.rb +6 -0
- data/lib/microdata/schema/data_type/boolean/true.rb +6 -0
- data/lib/microdata/schema/data_type/date.rb +10 -0
- data/lib/microdata/schema/data_type/date_time.rb +10 -0
- data/lib/microdata/schema/data_type/number.rb +6 -0
- data/lib/microdata/schema/data_type/number/float.rb +6 -0
- data/lib/microdata/schema/data_type/number/integer.rb +6 -0
- data/lib/microdata/schema/data_type/text.rb +6 -0
- data/lib/microdata/schema/data_type/text/url.rb +6 -0
- data/lib/microdata/schema/data_type/time.rb +6 -0
- data/lib/microdata/schema/list.rb +9 -0
- data/lib/microdata/schema/thing.rb +98 -0
- data/lib/microdata/schema/thing/action.rb +49 -0
- data/lib/microdata/schema/thing/action/achieve_action.rb +7 -0
- data/lib/microdata/schema/thing/action/achieve_action/lose_action.rb +12 -0
- data/lib/microdata/schema/thing/action/achieve_action/tie_action.rb +7 -0
- data/lib/microdata/schema/thing/action/achieve_action/win_action.rb +12 -0
- data/lib/microdata/schema/thing/action/assess_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/choose_action.rb +13 -0
- data/lib/microdata/schema/thing/action/assess_action/choose_action/vote_action.rb +12 -0
- data/lib/microdata/schema/thing/action/assess_action/ignore_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/agree_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/disagree_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/dislike_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/endorse_action.rb +14 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/like_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/react_action/want_action.rb +7 -0
- data/lib/microdata/schema/thing/action/assess_action/review_action.rb +12 -0
- data/lib/microdata/schema/thing/action/consume_action.rb +12 -0
- data/lib/microdata/schema/thing/action/consume_action/drink_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/eat_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/install_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/listen_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/read_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/use_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/use_action/wear_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/view_action.rb +7 -0
- data/lib/microdata/schema/thing/action/consume_action/watch_action.rb +7 -0
- data/lib/microdata/schema/thing/action/control_action.rb +7 -0
- data/lib/microdata/schema/thing/action/control_action/activate_action.rb +7 -0
- data/lib/microdata/schema/thing/action/control_action/deactivate_action.rb +7 -0
- data/lib/microdata/schema/thing/action/control_action/resume_action.rb +7 -0
- data/lib/microdata/schema/thing/action/control_action/suspend_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action/cook_action.rb +19 -0
- data/lib/microdata/schema/thing/action/create_action/draw_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action/film_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action/paint_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action/photograph_action.rb +7 -0
- data/lib/microdata/schema/thing/action/create_action/write_action.rb +13 -0
- data/lib/microdata/schema/thing/action/find_action.rb +7 -0
- data/lib/microdata/schema/thing/action/find_action/check_action.rb +7 -0
- data/lib/microdata/schema/thing/action/find_action/discover_action.rb +7 -0
- data/lib/microdata/schema/thing/action/find_action/track_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/befriend_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action.rb +18 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/ask_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/check_in_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/check_out_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/comment_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/inform_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/inform_action/confirm_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/inform_action/rsvp_action.rb +18 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/invite_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/reply_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/communicate_action/share_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/follow_action.rb +13 -0
- data/lib/microdata/schema/thing/action/interact_action/join_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/leave_action.rb +12 -0
- data/lib/microdata/schema/thing/action/interact_action/marry_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/register_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/subscribe_action.rb +7 -0
- data/lib/microdata/schema/thing/action/interact_action/un_register_action.rb +7 -0
- data/lib/microdata/schema/thing/action/move_action.rb +15 -0
- data/lib/microdata/schema/thing/action/move_action/arrive_action.rb +7 -0
- data/lib/microdata/schema/thing/action/move_action/depart_action.rb +7 -0
- data/lib/microdata/schema/thing/action/move_action/travel_action.rb +12 -0
- data/lib/microdata/schema/thing/action/organize_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/allocate_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/allocate_action/accept_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/allocate_action/assign_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/allocate_action/authorize_action.rb +14 -0
- data/lib/microdata/schema/thing/action/organize_action/allocate_action/reject_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/apply_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/bookmark_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/plan_action.rb +12 -0
- data/lib/microdata/schema/thing/action/organize_action/plan_action/cancel_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/plan_action/reserve_action.rb +7 -0
- data/lib/microdata/schema/thing/action/organize_action/plan_action/schedule_action.rb +7 -0
- data/lib/microdata/schema/thing/action/play_action.rb +15 -0
- data/lib/microdata/schema/thing/creative_work.rb +270 -0
- data/lib/microdata/schema/thing/creative_work/article.rb +29 -0
- data/lib/microdata/schema/thing/creative_work/article/tech_article.rb +15 -0
- data/lib/microdata/schema/thing/creative_work/software_source_code.rb +25 -0
- data/lib/microdata/schema/thing/creative_work/web_page.rb +35 -0
- data/lib/microdata/schema/thing/creative_work/web_page/about_page.rb +7 -0
- data/lib/microdata/schema/thing/creative_work/web_page/profile_page.rb +7 -0
- data/lib/microdata/schema/thing/creative_work/web_site.rb +7 -0
- data/lib/microdata/schema/thing/event.rb +171 -0
- data/lib/microdata/schema/thing/intangible.rb +7 -0
- data/lib/microdata/schema/thing/intangible/item_list.rb +23 -0
- data/lib/microdata/schema/thing/intangible/item_list/breadcrumb_list.rb +7 -0
- data/lib/microdata/schema/thing/intangible/list_item.rb +22 -0
- data/lib/microdata/schema/thing/organization.rb +150 -0
- data/lib/microdata/schema/thing/person.rb +175 -0
- data/lib/microdata/schema/thing/place.rb +84 -0
- data/lib/microdata/schema/thing/product.rb +117 -0
- data/lib/microdata_schema.rb +5 -0
- data/lib/microdata_schema/version.rb +3 -0
- data/microdata_schema.gemspec +26 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8896cf100b207165698b01958665fcdab98cf158
|
4
|
+
data.tar.gz: 1a7191e5223562b33e4daf9eac50cff5992adc9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d47e7abe26e14c2c7ae593b1004a852fb9c664692713b1f9a24589248ae5da679444f3799266397ea22144892e9f0878af331d0de670c8f1e39e1fb59d4c8326
|
7
|
+
data.tar.gz: 06bf38a029ee9fefe2a73a66d61cc6bbfbf7670d28e3d5529be76b5711aa47d2f8975e624813b2a178f3e40916d056268ab87147f3cbc0cb9aa348d3241cfb1e
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at source.coed.tech@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 co-ed
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# MicrodataSchema
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/microdata_schema`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'microdata_schema'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install microdata_schema
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/microdata_schema. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the MicrodataSchema project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/microdata_schema/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "microdata_schema"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/microdata.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
module Microdata
|
2
|
+
class Schema
|
3
|
+
attr_reader :assined_attributes
|
4
|
+
attr_writer :top_level
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
@top_level = true
|
8
|
+
@required_attributes_for_top_level_things = {
|
9
|
+
'@context' => "http://schema.org",
|
10
|
+
}
|
11
|
+
@required_attributes = {
|
12
|
+
'@type' => self.class.to_s.split(/::/).last
|
13
|
+
}
|
14
|
+
@assined_attributes = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_ld
|
18
|
+
end
|
19
|
+
|
20
|
+
autoload :List, 'microdata/schema/list'
|
21
|
+
autoload :Thing, 'microdata/schema/thing'
|
22
|
+
autoload :Action, 'microdata/schema/thing/action'
|
23
|
+
autoload :AchieveAction, 'microdata/schema/thing/action/achieve_action'
|
24
|
+
autoload :LoseAction, 'microdata/schema/thing/action/achieve_action/lose_action'
|
25
|
+
autoload :TieAction, 'microdata/schema/thing/action/achieve_action/tie_action'
|
26
|
+
autoload :WinAction, 'microdata/schema/thing/action/achieve_action/win_action'
|
27
|
+
autoload :AssessAction, 'microdata/schema/thing/action/assess_action'
|
28
|
+
autoload :ChooseAction, 'microdata/schema/thing/action/assess_action/choose_action'
|
29
|
+
autoload :VoteAction, 'microdata/schema/thing/action/assess_action/choose_action/vote_action'
|
30
|
+
autoload :IgnoreAction, 'microdata/schema/thing/action/assess_action/ignore_action'
|
31
|
+
autoload :ReactAction, 'microdata/schema/thing/action/assess_action/react_action'
|
32
|
+
autoload :AgreeAction, 'microdata/schema/thing/action/assess_action/react_action/agree_action'
|
33
|
+
autoload :DisagreeAction, 'microdata/schema/thing/action/assess_action/react_action/disagree_action'
|
34
|
+
autoload :DislikeAction, 'microdata/schema/thing/action/assess_action/react_action/dislike_action'
|
35
|
+
autoload :EndorseAction, 'microdata/schema/thing/action/assess_action/react_action/endorsee_action'
|
36
|
+
autoload :LikeAction, 'microdata/schema/thing/action/assess_action/react_action/like_action'
|
37
|
+
autoload :WantAction, 'microdata/schema/thing/action/assess_action/react_action/want_action'
|
38
|
+
autoload :ReviewAction, 'microdata/schema/thing/action/assess_action/review_action'
|
39
|
+
autoload :ConsumeAction, 'microdata/schema/thing/action/consume_action'
|
40
|
+
autoload :DrinkAction, 'microdata/schema/thing/action/consume_action/drink_action'
|
41
|
+
autoload :EatAction, 'microdata/schema/thing/action/consume_action/eat_action'
|
42
|
+
autoload :InstallAction, 'microdata/schema/thing/action/consume_action/install_action'
|
43
|
+
autoload :ListenAction, 'microdata/schema/thing/action/consume_action/listen_action'
|
44
|
+
autoload :ReadAction, 'microdata/schema/thing/action/consume_action/read_action'
|
45
|
+
autoload :UseAction, 'microdata/schema/thing/action/consume_action/use_action'
|
46
|
+
autoload :WearAction, 'microdata/schema/thing/action/consume_action/use_action/wear_action'
|
47
|
+
autoload :ViewAction, 'microdata/schema/thing/action/consume_action/view_action'
|
48
|
+
autoload :WatchAction, 'microdata/schema/thing/action/consume_action/watch_action'
|
49
|
+
autoload :ControlAction, 'microdata/schema/thing/action/control_action'
|
50
|
+
autoload :ActivateAction, 'microdata/schema/thing/action/control_action/activate_action'
|
51
|
+
autoload :DeactivateAction, 'microdata/schema/thing/action/control_action/deactivate_action'
|
52
|
+
autoload :ResumeAction, 'microdata/schema/thing/action/control_action/resume_action'
|
53
|
+
autoload :SuspendAction, 'microdata/schema/thing/action/control_action/suspend_action'
|
54
|
+
autoload :CreateAction, 'microdata/schema/thing/action/create_action'
|
55
|
+
autoload :CookAction, 'microdata/schema/thing/action/create_action/cook_action'
|
56
|
+
autoload :DrawAction, 'microdata/schema/thing/action/create_action/draw_action'
|
57
|
+
autoload :FilmAction, 'microdata/schema/thing/action/create_action/film_action'
|
58
|
+
autoload :PaintAction, 'microdata/schema/thing/action/create_action/paint_action'
|
59
|
+
autoload :PhotographAction, 'microdata/schema/thing/action/create_action/photograph_action'
|
60
|
+
autoload :WriteAction, 'microdata/schema/thing/action/create_action/write_action'
|
61
|
+
autoload :FindAction, 'microdata/schema/thing/action/find_action'
|
62
|
+
autoload :CheckAction, 'microdata/schema/thing/action/find_action/check_action'
|
63
|
+
autoload :DiscoverAction, 'microdata/schema/thing/action/find_action/discover_action'
|
64
|
+
autoload :TrackAction, 'microdata/schema/thing/action/find_action/track_action'
|
65
|
+
autoload :InteractAction, 'microdata/schema/thing/action/interact_action'
|
66
|
+
autoload :BefriendAction, 'microdata/schema/thing/action/interact_action/befriend_action'
|
67
|
+
autoload :CommunicateAction, 'microdata/schema/thing/action/interact_action/communicate_action'
|
68
|
+
autoload :AskAction, 'microdata/schema/thing/action/interact_action/communicate_action/ask_action'
|
69
|
+
autoload :CheckInAction, 'microdata/schema/thing/action/interact_action/communicate_action/check_in_action'
|
70
|
+
autoload :CheckOutAction, 'microdata/schema/thing/action/interact_action/communicate_action/check_out_action'
|
71
|
+
autoload :CommentAction, 'microdata/schema/thing/action/interact_action/communicate_action/comment_action'
|
72
|
+
autoload :InformAction, 'microdata/schema/thing/action/interact_action/communicate_action/inform_action'
|
73
|
+
autoload :ConfirmAction, 'microdata/schema/thing/action/interact_action/communicate_action/inform_action/confirm_action'
|
74
|
+
autoload :RsvpAction, 'microdata/schema/thing/action/interact_action/communicate_action/inform_action/rsvp_action'
|
75
|
+
autoload :InviteAction, 'microdata/schema/thing/action/interact_action/communicate_action/invite_action'
|
76
|
+
autoload :ReplyAction, 'microdata/schema/thing/action/interact_action/communicate_action/reply_action'
|
77
|
+
autoload :ShareAction, 'microdata/schema/thing/action/interact_action/communicate_action/share_action'
|
78
|
+
autoload :FollowAction, 'microdata/schema/thing/action/interact_action/follow_action'
|
79
|
+
autoload :JoinAction, 'microdata/schema/thing/action/interact_action/join_action'
|
80
|
+
autoload :LeaveAction, 'microdata/schema/thing/action/interact_action/leave_action'
|
81
|
+
autoload :MarryAction, 'microdata/schema/thing/action/interact_action/marry_action'
|
82
|
+
autoload :RegisterAction, 'microdata/schema/thing/action/interact_action/register_action'
|
83
|
+
autoload :SubscribeAction, 'microdata/schema/thing/action/interact_action/subscribe_action'
|
84
|
+
autoload :UnRegisterAction, 'microdata/schema/thing/action/interact_action/un_register_action'
|
85
|
+
autoload :MoveAction, 'microdata/schema/thing/action/move_action'
|
86
|
+
autoload :ArriveAction, 'microdata/schema/thing/action/move_action/arrive_action'
|
87
|
+
autoload :DepartAction, 'microdata/schema/thing/action/move_action/depart_action'
|
88
|
+
autoload :TravelAction, 'microdata/schema/thing/action/move_action/travel_action'
|
89
|
+
autoload :OrganizeAction, 'microdata/schema/thing/action/organize_action'
|
90
|
+
autoload :AllocateAction, 'microdata/schema/thing/action/organize_action/allocate_action'
|
91
|
+
autoload :AcceptAction, 'microdata/schema/thing/action/organize_action/allocate_action/accept_action'
|
92
|
+
autoload :AssignAction, 'microdata/schema/thing/action/organize_action/allocate_action/assign_action'
|
93
|
+
autoload :AuthorizeAction, 'microdata/schema/thing/action/organize_action/allocate_action/authorize_action'
|
94
|
+
autoload :RejectAction, 'microdata/schema/thing/action/organize_action/allocate_action/reject_action'
|
95
|
+
autoload :ApplyAction, 'microdata/schema/thing/action/organize_action/apply_action'
|
96
|
+
autoload :BookmarkAction, 'microdata/schema/thing/action/organize_action/bookmark_action'
|
97
|
+
autoload :PlanAction, 'microdata/schema/thing/action/organize_action/plan_action'
|
98
|
+
autoload :CancelAction, 'microdata/schema/thing/action/organize_action/plan_action/cancel_action'
|
99
|
+
autoload :ReserveAction, 'microdata/schema/thing/action/organize_action/plan_action/reserve_action'
|
100
|
+
autoload :ScheduleAction, 'microdata/schema/thing/action/organize_action/plan_action/schedule_action'
|
101
|
+
autoload :PlayAction, 'microdata/schema/thing/action/play_action'
|
102
|
+
|
103
|
+
autoload :CreativeWork, 'microdata/schema/thing/creative_work'
|
104
|
+
autoload :Article, 'microdata/schema/thing/creative_work/article'
|
105
|
+
autoload :TechArticle, 'microdata/schema/thing/creative_work/article/tech_article'
|
106
|
+
autoload :SoftwareSourceCode, 'microdata/schema/thing/creative_work/software_source_code'
|
107
|
+
autoload :WebPage, 'microdata/schema/thing/creative_work/web_page'
|
108
|
+
autoload :AboutPage, 'microdata/schema/thing/creative_work/web_page/about_page'
|
109
|
+
autoload :ProfilePage, 'microdata/schema/thing/creative_work/web_page/profile_page'
|
110
|
+
autoload :WebSite, 'microdata/schema/thing/creative_work/web_site'
|
111
|
+
autoload :Event, 'microdata/schema/thing/event'
|
112
|
+
autoload :Intangible, 'microdata/schema/thing/intangible'
|
113
|
+
autoload :ItemList, 'microdata/schema/thing/intangible/item_list'
|
114
|
+
autoload :BreadcrumbList, 'microdata/schema/thing/intangible/item_list/breadcrumb_list'
|
115
|
+
autoload :ListItem, 'microdata/schema/thing/intangible/list_item'
|
116
|
+
autoload :Organization, 'microdata/schema/thing/organization'
|
117
|
+
autoload :Person, 'microdata/schema/thing/person'
|
118
|
+
autoload :Place, 'microdata/schema/thing/place'
|
119
|
+
autoload :Product, 'microdata/schema/thing/product'
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Microdata
|
2
|
+
class Schema
|
3
|
+
class Thing < Schema
|
4
|
+
ATTRIBUTES = [:id, :additional_type, :alternate_name, :description, :disambiguating_description, :identifier, :image, :main_entity_of_page, :name, :potential_action, :same_as, :url].freeze
|
5
|
+
class_attribute :attributes
|
6
|
+
self.attributes = ATTRIBUTES
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
hash = args.first
|
10
|
+
return super if hash.nil?
|
11
|
+
raise "args needs Hash" if hash.class != Hash
|
12
|
+
super
|
13
|
+
hash.each do |key, value|
|
14
|
+
raise "key not found (#{key})" unless attributes.include?(key)
|
15
|
+
value.top_level = false if value.is_a? Thing
|
16
|
+
instance_variable_set("@#{key}", value)
|
17
|
+
@assined_attributes << key
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def as_json(options = nil)
|
22
|
+
hash = {}
|
23
|
+
assined_attributes.each do |attribute|
|
24
|
+
camelCase = to_camel_case(attribute.to_s)
|
25
|
+
camelCase = "@id" if camelCase == "id"
|
26
|
+
hash[camelCase] = instance_variable_get("@#{attribute}")
|
27
|
+
end
|
28
|
+
hash = @required_attributes.merge(hash)
|
29
|
+
if @top_level
|
30
|
+
@required_attributes_for_top_level_things.merge!(hash)
|
31
|
+
@required_attributes_for_top_level_things
|
32
|
+
else
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_json(options = nil)
|
38
|
+
as_json(options).to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_json_ld(options = nil)
|
42
|
+
"<script type=\"application/ld+json\">" + to_json(options) + "</script>"
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def to_camel_case(string)
|
48
|
+
_words = []
|
49
|
+
words = string.split("_")
|
50
|
+
_words << words.shift
|
51
|
+
words.each.with_index do |word|
|
52
|
+
word[0] = word[0].upcase
|
53
|
+
_words << word
|
54
|
+
end
|
55
|
+
_words.join
|
56
|
+
end
|
57
|
+
|
58
|
+
# - additional_type
|
59
|
+
# URL An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in. In RDFa syntax, it is better to use the native RDFa syntax - the 'typeof' attribute - for multiple types. Schema.org tools may have only weaker understanding of extra types, in particular those defined externally.
|
60
|
+
#
|
61
|
+
# - alternate_name
|
62
|
+
# Text An alias for the item.
|
63
|
+
#
|
64
|
+
# - description
|
65
|
+
# Text A description of the item.
|
66
|
+
#
|
67
|
+
# - disambiguating_description
|
68
|
+
# Text A sub property of description. A short description of the item used to disambiguate from other, similar items. Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation.
|
69
|
+
#
|
70
|
+
# - identifier
|
71
|
+
# PropertyValue or
|
72
|
+
# Text or
|
73
|
+
# URL The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details.
|
74
|
+
#
|
75
|
+
# - image
|
76
|
+
# ImageObject or
|
77
|
+
# URL An image of the item. This can be a URL or a fully described ImageObject.
|
78
|
+
#
|
79
|
+
# - main_entity_of_page
|
80
|
+
# CreativeWork or
|
81
|
+
# URL Indicates a page (or other CreativeWork) for which this thing is the main entity being described. See background notes for details.
|
82
|
+
# Inverse property: mainEntity.
|
83
|
+
#
|
84
|
+
# - name
|
85
|
+
# Text The name of the item.
|
86
|
+
#
|
87
|
+
# - potential_action
|
88
|
+
# Action Indicates a potential Action, which describes an idealized action in which this thing would play an 'object' role.
|
89
|
+
#
|
90
|
+
# - same_as
|
91
|
+
# URL URL of a reference Web page that unambiguously indicates the item's identity. E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website.
|
92
|
+
#
|
93
|
+
# - url
|
94
|
+
# URL URL of the item.
|
95
|
+
#
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|