An open API service indexing awesome lists of open source software.

https://github.com/niku/skippa

A schema.rb parser with using ripper
https://github.com/niku/skippa

Last synced: 3 months ago
JSON representation

A schema.rb parser with using ripper

Awesome Lists containing this project

README

          

# Skippa

A `schema.rb` parser with using ripper.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'skippa'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install skippa

## Usage

```ruby
~/src/skippa $ bin/console
irb(main):001:0> require "pp"
=> true
irb(main):002:0> doc = <<__EOD__
irb(main):003:0" ActiveRecord::Schema.define(version: 20180522032741) do
irb(main):004:0" enable_extension "plpgsql"
irb(main):005:0" enable_extension "hstore"
irb(main):006:0"
irb(main):007:0" create_table "access_log", id: false, force: :cascade do |t|
irb(main):008:0" t.integer "user_id"
irb(main):009:0" t.datetime "timestamp", limit: 8
irb(main):010:0" end
irb(main):011:0"
irb(main):012:0" create_table "users", force: :cascade do |t|
irb(main):013:0" t.string "email", limit: 255, default: "", null: false
irb(main):014:0" t.string "password", limit: 255, default: "", null: false
irb(main):015:0" end
irb(main):016:0"
irb(main):017:0" add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
irb(main):018:0" end
irb(main):019:0" __EOD__
=> "ActiveRecord::Schema.define(version: 20180522032741) do\n enable_extension \"plpgsql\"\n enable_extension \"hstore\"\n\n create_table \"access_log\", id: false, force: :cascade do |t|\n t.integer \"user_id\"\n t.datetime \"timestamp\", limit: 8\n end\n\n create_table \"users\", force: :cascade do |t|\n t.string \"email\", limit: 255, default: \"\", null: false\n t.string \"password\", limit: 255, default: \"\", null: false\n end\n\n add_index \"users\", [\"email\"], name: \"index_users_on_email\", unique: true, using: :btree\nend\n"
irb(main):020:0> result = Skippa.parse(doc)
=> #"20180522032741"}, extentions=[#, #], tables=[#"false", "force"=>"cascade"}, columns=[#, #"8"}>]>, #"cascade"}, columns=[#"255", "default"=>"", "null"=>"false"}>, #"255", "default"=>"", "null"=>"false"}>]>], indexes=[#"index_users_on_email", "unique"=>"true", "using"=>"btree"}>]>
irb(main):021:0> result.info
=> {"version"=>"20180522032741"}
irb(main):022:0> result.extentions
=> [#, #]
irb(main):023:0> pp result
#"20180522032741"},
extentions=[
#,
#,
],
tables=[
#"false", "force"=>"cascade"},
columns=[
#,
#"8"},
>,
],
>,
#"cascade"},
columns=[
#"255", "default"=>"", "null"=>"false"},
>,
#"255", "default"=>"", "null"=>"false"},
>,
],
>,
],
indexes=[
#"index_users_on_email",
"unique"=>"true",
"using"=>"btree"},
>,
],
>
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

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).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/niku/skippa. 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.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the Skippa project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/niku/skippa/blob/master/CODE_OF_CONDUCT.md).