{"id":17003823,"url":"https://github.com/cldwalker/has_machine_tags","last_synced_at":"2025-09-12T03:12:02.443Z","repository":{"id":498824,"uuid":"125716","full_name":"cldwalker/has_machine_tags","owner":"cldwalker","description":"A rails tagging gem implementing flickr's machine tags + maybe more (semantic tags)","archived":false,"fork":false,"pushed_at":"2013-05-01T21:37:00.000Z","size":246,"stargazers_count":44,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-11T06:46:50.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://tagaholic.me/has_machine_tags/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cldwalker.png","metadata":{"files":{"readme":"README.rdoc","changelog":"CHANGELOG.rdoc","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-02-10T11:07:14.000Z","updated_at":"2020-05-31T04:06:31.000Z","dependencies_parsed_at":"2022-07-04T20:01:56.711Z","dependency_job_id":null,"html_url":"https://github.com/cldwalker/has_machine_tags","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldwalker%2Fhas_machine_tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldwalker%2Fhas_machine_tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldwalker%2Fhas_machine_tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldwalker%2Fhas_machine_tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cldwalker","download_url":"https://codeload.github.com/cldwalker/has_machine_tags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858929,"owners_count":20359260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T04:32:48.685Z","updated_at":"2025-03-17T09:30:59.034Z","avatar_url":"https://github.com/cldwalker.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"== Description\n\nThis plugin implements Flickr's machine tags as explained\nhere[http://www.flickr.com/groups/api/discuss/72157594497877875]\nwhile still maintaining standard tagging behavior.\n\nBasically, a machine tag has a namespace, a predicate and a value in the format\n    [namespace]:[predicate]=[value] \n\nThis allows for more precise tagging as tags can have unlimited contexts provided\nby combinations of namespaces and predicates. These unlimited contexts also make\nmachine tags ripe for modeling relationships between objects. Read the HasMachineTags::TagMethods class\ndocumentation for a more thorough explanation.\n\nA demo app using this plugin is {here}[http://github.com/cldwalker/tag-tree].\nThis gem should run on all major Ruby versions and work with Rails 2.3.x and up.\n\n== Install\n\nInstall as a gem\n\n    $ gem install has_machine_tags\n\n    # with bundler: add in Gemfile\n    gem 'has_machine_tags'\n\n    # without bundler: add in config/environment.rb\n    config.gem \"has_machine_tags\"\n\nOr as a plugin\n\n    $ script/plugin install git://github.com/cldwalker/has_machine_tags.git\n\n\nMigrate your database from Rails root:\n  \n    $ script/generate has_machine_tags_migration\n    $ rake db:migrate\n\n== Usage\n\nSetup a model to use has_machine_tags\n\n  class Url \u003c ActiveRecord::Base\n    has_machine_tags\n  end\n\nLet's create some urls with machine tags!\n\n    url = Url.create(:name=\u003e\"http://github.com/cldwalker/has_machine_tags\",\n      :tag_list=\u003e'gem:type=tagging,flickr')\n\n    url2 = Url.create(:name=\u003e\"http://github.com/giraffesoft/is_taggable\",\n      :tag_list=\u003e'gem:type=tagging, gem:user=giraffesoft')\n\n    url3 = Url.create(:name=\u003e\"http://github.com/datamapper/data_mapper\",\n      :tag_list=\u003e'gem:type=orm')\n\n    url.tag_list # =\u003e [\"gem:type=tagging\", \"flickr\"]\n    \n    url.tags # =\u003e [\u003cTag name:\"gem:type=tagging\"\u003e, \u003cTag name:\"flickr\"\u003e]\n\nLet's query them:\n\n    # Query urls tagged as a gem having type tagging\n    Url.tagged_with 'gem:type=tagging'  # =\u003e [url, url2] from above\n\n    # Non-machine tags work of course\n    Url.tagged_with 'flickr'  # =\u003e [url] from above\n\n    # tagged_with() is a named_scope so do your sweet chaining\n    Url.tagged_with('flickr').yet_another_finder(:sweet).paginate(:per_page=\u003e30)\n\nNothing interesting so far. We could've done the same with normal tagging.\n\nBut when we start with wildcard machine tag syntax, machine tags become more valuable:\n\n    # Query urls tagged as gems (namespace = 'gem')\n    Url.tagged_with 'gem:'  # =\u003e [url, url2, url3] from above\n\n    # Query urls tagged as having a user, regardless of namespace and value (predicate = 'user')\n    Url.tagged_with 'user='  # =\u003e [url2] from above\n\n    # Query urls tagged as gems having a user ( namespace ='gem' AND predicate = 'user')\n    Url.tagged_with 'gem:user'  # =\u003e [url2] from above\n\n    # Query urls tagged as having a tagging value, regardless of namespace and predicate (value = 'tagging')\n    Url.tagged_with '=tagging'  # =\u003e [url, url2] from above\n\nMore details on machine tag syntax can be found in the Tag class.\n\n=== More Usage\n\nThe wildcard machine tag syntax can also be used to fetch tags:\n\n    # Tags that are gems\n    Tag.machine_tags 'gem:' # =\u003e [\u003cTag name:\"gem:type=tagging\"\u003e, \u003cTag name:\"gem:user=giraffesoft\"\u003e]\n\n    # Tags that have a user predicate\n    Tag.machine_tags 'user=' # =\u003e [\u003cTag name:\"gem:user=giraffesoft\"\u003e]\n\nOf course you can do the standard tag_list manipulation:\n\n    url.tag_list = \"comma, delimited\"\n    url.save\n    url.tag_list # =\u003e['comma', 'delimited']\n\n    url.tag_list = ['or', 'an', 'array']\n    url.save\n    url.tag_list # =\u003e['or', 'an' 'array']\n\n    #Add a tag\n    url.tag_list \u003c\u003c 'another_tag' \n    url.save\n    url.tag_list # =\u003e [\"gem:type=tagging\", \"flickr\", \"another_tag']\n\n    #Delete a tag\n    url.tag_list.delete('another_tag')\n    url.save\n    url.tag_list # =\u003e [\"gem:type=tagging\", \"flickr\"]\n\n\n== Caveats\n\nThis is an experiment in progress so the api is subject to change.\n\nSince machine tags require special characters to implement its goodness,\nthese characters are off limit unless used in the machine tag context:\n\n  '.', ':' , '*' , '=' , ','\n\n== Todo\n\n* Add a match_all option to tagged_with().\n* More helper methods ie for showing relations between namespaces, predicates + values\n* Possible add support for other ORM's ie DataMapper.\n* Play friendly with other tagging plugins as needed.\n\n== Bugs/Issues\nPlease report them {on github}[http://github.com/cldwalker/has_machine_tags/issues].\n\n== Credits\n\nThanks goes to Flickr for popularizing this tagging model.\nThanks also goes to the {acts-as-taggable-on plugin}[http://github.com/mbleigh/acts-as-taggable-on]\nfor their finder code and the {is_taggable plugin}[http://github.com/giraffesoft/is_taggable]\nfor demonstrating sane testing for a Rails plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcldwalker%2Fhas_machine_tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcldwalker%2Fhas_machine_tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcldwalker%2Fhas_machine_tags/lists"}