New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simple-annotations

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-annotations

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Simple Annotations 4 Ruby

Simple method annotations like in java or Python methods decorators

GitHub

Documentation GitHub issues GitHub tag (latest by date) GitHub top language GitHub milestones

Gem Gem Version Twitter Follow GitHub Org's stars GitHub watchers

Donate using Liberapay

Installation

Install it yourself as:

$ gem install carioca

Usage

Adding annotations to a class

require 'rubygems'
require 'simple-annotations'

class A
  using AnnotationRefinement

  annotate!

  §test 'string'
  def method
    return annotations(__callee__)
  end

end

anA = A.new
pp anA.method

Display

{:test=>"string"}

Getting fields

require 'rubygems'
require 'simple-annotations'

class A
  using AnnotationRefinement
  annotate!

  §foobar {:color => 'cyan' }   # Hash
  §test 1234                    # Numeric
  §foobar color: 'cyan'         # Hash by double splat, like keyword
  §testbar 10, {}, [], 'string' # Hybrid by splat
  §barfoo                       # Boolean set true
  §footest 'string'             # String                    
  def method
      [...]
  end

end

pp A.annotations[:method]

Display

{:test=>1234, :foobar=>{:color=>"cyan"}, :testbar=>[10, {}, [], "string"], :barfoo=>true, :footest=>"string"}

Defining Hooks

Supporting 2 Hooks :

  • §after
  • §before

Like :

require 'rubygems'
require 'simple-annotations'

class A
  using AnnotationRefinement

  annotate!

  
  §after -> { puts 'after' }
  §before -> { puts 'before' }
  def m1
    puts 'test'
  end

  
end



anA = A.new
anA.m1

Display

before
test
after

FAQs

Package last updated on 30 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc