GithubHelp home page GithubHelp logo

pliny's Introduction

Pliny

Gem version Github Actions CI

Pliny helps Ruby developers write and maintain excellent APIs.

It bundles the best patterns, libraries and practices we've seen after writing a lot of APIs.

Resources

Getting started

Install gem:

$ gem install pliny

And initialize your new API app:

$ pliny-new myapp
$ cd myapp && bin/setup

Pliny bundles generators to help you get started:

$ bundle exec pliny-generate model artist
created model file ./lib/models/artist.rb
created migration ./db/migrate/1408995997_create_artists.rb
created test ./spec/models/artist_spec.rb

$ bundle exec pliny-generate mediator artists/creator
created mediator file ./lib/mediators/artists/creator.rb
created test ./spec/mediators/artists/creator_spec.rb

$ bundle exec pliny-generate endpoint artists
created endpoint file ./lib/endpoints/artists.rb
add the following to lib/routes.rb:
  mount Endpoints::Artists
created test ./spec/endpoints/artists_spec.rb
created test ./spec/acceptance/artists_spec.rb

$ bundle exec pliny-generate migration fix_something
created migration ./db/migrate/1395873228_fix_something.rb

$ bundle exec pliny-generate schema artists
created schema file ./schema/schemata/artist.yaml
rebuilt ./schema/schema.json

To test your application:

$ bundle exec rake

Or to run a single test suite:

$ bundle exec rspec spec/acceptance/artists_spec.rb

Generators

$ bundle exec pliny-generate
Commands:
  pliny-generate endpoint NAME    # Generates an endpoint
  pliny-generate help [COMMAND]   # Describe available commands or one specific command
  pliny-generate mediator NAME    # Generates a mediator
  pliny-generate migration NAME   # Generates a migration
  pliny-generate model NAME       # Generates a model
  pliny-generate scaffold NAME    # Generates a scaffold of endpoint, model, schema and serializer
  pliny-generate schema NAME      # Generates a schema
  pliny-generate serializer NAME  # Generates a serializer

Rake tasks

Pliny adds common Rake tasks to help maintain your app:

rake db:create        # Create the database
rake db:drop          # Drop the database
rake db:migrate       # Run database migrations
rake db:rollback      # Rollback last database migration
rake db:schema:dump   # Dump the database schema
rake db:schema:load   # Load the database schema
rake db:schema:merge  # Merges migrations into schema and removes them
rake db:seed          # Seed the database with data
rake db:setup         # Setup the database
rake schema           # Rebuild schema.json

Commands

And provides the following commands:

$ foreman start                             # Starts server
$ foreman run bin/console                   # IRB/Pry console
$ foreman run bin/run 'puts "hello world"'  # Run automated code

(hint: don't forget foreman run in development)

Updating

Use pliny-update to update the Pliny app in the current directory.

This not only bumps the version dependency, but also applies any changes that happened in the template app (for instance: new initializer, tweaks in the base endpoint, etc).

Development

Run tests:

$ bundle install
$ createdb pliny-gem-test
$ rake

Meta

Created by Brandur Leach and Pedro Belo.

MIT licensed.

pliny's People

Contributors

adriacidre avatar appleton avatar beanieboi avatar bensymonds avatar brandur avatar csquared avatar cyberdelia avatar danp avatar dmathieu avatar dyegocosta avatar fdr avatar geemus avatar gudmundur avatar hayduke19us avatar jabrown85 avatar joshwlewis avatar mathias avatar mfine avatar msakrejda avatar nzoschke avatar paulelliott avatar rwz avatar soulim avatar stevenharman avatar tmaier avatar tomclose avatar treznick avatar tt avatar will avatar ys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pliny's Issues

Mediators and Serializers are classes

I was assuming Mediators and Serializers are module namespaces. Turns out they're both classes.

¯_(ツ)_/¯

Is there a reason for this? Is user supposed to be able to instantiate them?

Puma IO Error

I'm seeing this across a few Pliny codebases on shutdown:

web    | D, [2014-07-17T13:16:06.324808 #78227] DEBUG -- : Terminating 3 actors...
web    | D, [2014-07-17T13:16:06.325204 #78228] DEBUG -- : Terminating 3 actors...
web    | D, [2014-07-17T13:16:06.325435 #78229] DEBUG -- : Terminating 3 actors...
web    | /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `write'
web    | : closed stream (
web    | IOError)
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `<<'
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `block in worker'
web    | /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `write'
web    | : closed stream (IOError)
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `<<'
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `block in worker'
web    | /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `write'
web    | : closed stream (IOError)
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `<<'
web    |    from /Users/neil/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:213:in `block in worker'

No idea what this is right now, but logging it so it's logged. This may be a pliny-template config problem more than anything.

Access to log context

Would be nice if the Pliny log helper offered an easy way to add context to the log. It can be done indirectly by stashing variables in the RequestStore, but making the log_context method not private would be a step up.

An alternative might be to offer a context method like the one in scrolls which define block context.

Error response bodies swallowed somewhere

I was having this issue in another app and decided to try to reproduce a minimal test case. I generated a new app and added a test endpoint, changing its get /tests handler to the following:

      get do
        raise Pliny::Errors::Conflict, "my error message"
      end

If I call this endpoint, I get the expected error, but no body:

maciek@gamera:~$ curl -i http://localhost:5000/tests
HTTP/1.1 409 Conflict
Content-Type: application/json
X-Content-Type-Options: nosniff
Vary: Accept-Encoding
Request-Id: 4b97f2b9-cfc9-4ad5-8fd5-6aa257ec96a8
Content-Length: 0

/cc @brandur -- no rush, but this is the issue I was running into on Friday--looks like it is something in pliny after all. I tried to repro it in a test in #53, but that test is bogus and fixing it failed to reproduce the problem.

Unable to load application: NameError: uninitialized constant Rollbar::Middleware

A newly generated app doesn't want to start because of NameError exception in lib/routes.rb file.
When I explicitly require rollbar/middleware/sinatra everything runs perfectly.

So my lib/routes.rb looks like this:

require 'rollbar/middleware/sinatra'

Routes = Rack::Builder.new do
  use Rollbar::Middleware::Sinatra
  use Pliny::Middleware::RescueErrors, raise: Config.raise_errors?
  use Pliny::Middleware::CORS
  use Pliny::Middleware::RequestID
  use Pliny::Middleware::RequestStore, store: Pliny::RequestStore
  use Pliny::Middleware::Timeout, timeout: Config.timeout if Config.timeout > 0
  use Pliny::Middleware::Versioning,
      default: Config.versioning_default,
      app_name: Config.versioning_app_name if Config.versioning?
  use Rack::Deflater
  use Rack::MethodOverride
  use Rack::SSL if Config.force_ssl?

  use Pliny::Router do
    # mount all endpoints here
  end

  # root app; but will also handle some defaults like 404
  run Endpoints::Root
end

Would you allow a pull request with this tiny fix? Or maybe there's a better place where I should require Rollbar middleware. I just started playing with Pliny and might miss something.

Foreman dependency

Hey guys!

Thank you a lot for the awesome project! Could you tell me why foreman gem isn't mentioned in Gemfile as a development dependency? Is that your internal convention and foreman is some kind of default tool like bundler? I mean this Gemfile https://github.com/interagent/pliny/blob/master/lib/template/Gemfile.

I guess it would be nice to automatically install foreman with other gems when you run bin/setup.

Remove versioning middleware output cruft from tests

Might be a problem with stubbing out Pliny's log method.

$ rake
Run options: --seed 40226

# Running:

..........................middleware=versioning at=start
middleware=versioning at=finish elapsed=0.003
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.000
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.001
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.001
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.001
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.001
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.000
.middleware=versioning at=start
middleware=versioning at=finish elapsed=0.001
................................

Finished in 3.822104s, 17.0063 runs/s, 22.5007 assertions/s.

65 runs, 86 assertions, 0 failures, 0 errors, 0 skips

JRuby support

Is there any plan to support jruby? As far as I can see, the only change required is to remove the pg dependency.

ruby 2.2.0 error

Tried updating to 2.2.0, and got this:

➤ bundle exec rspec spec                                                                                                                  git:master*
/Users/will/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pliny-0.5.0/lib/pliny/config_helpers.rb:86:in `remove_const': constant Object::Config not defined (NameError)
    from /Users/will/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/pliny-0.5.0/lib/pliny/config_helpers.rb:86:in `<top (required)>'
    from /Users/will/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require'
    from /Users/will/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /Users/will/code/heroku/telex/config/config.rb:1:in `<top (required)>'

Too many request-ids

Right now platform apps are getting request-id header automatically coming from hermes. Then Pliny adds it's own request id in the request-id middleware. That means that the minimum amount of request ids per single request for a platform app is now two.

What do you think about making pliny add a new request id only if there're no request ids already? That will make it reuse hermes request id when running on the platform and actually generate one when running standalone.

I can send a PR.

db:dump should dump data

https://github.com/interagent/pliny/blob/master/lib/pliny/tasks/db.rake#L89

When one has a some seed data added via migrations over time, it conflicts poorly with the schema-only dump done here. That's because one is obliged to add them to seeds.rb or schema.sql by hand and then make idempotent migrations foreverafter, or risk losing them the next time the schema is compacted (one is free to speculate how many errors are going to creep in from having to update seeds.rb and complicate migrations for any seed rows, I think it's unnecessarily many)

It would be better if a fresh database were prepared, migrated, and then dumped with data. This would also avoid the special code here to keep track of migrations specially.

Requires trust permissions on localhost

The current configuration requires trust permissions on localhost for setting up and destroying the database because of the DATABASE_URL used in this task. Does postgres:///postgres work on OS X? In most drivers (at least on Ubuntu), this will use Unix domain sockets instead of localhost, and allows ident authentication, which is a much more sensible security model (you need to have permissions on the socket file). It also works with the default pghba.conf configuration if you create a Postgres superuser account for your Unix user.

Schema Path Wrong On Scaffold

Looks like the wrong schema path is used on scaffold. It uses /docs/schema.json instead of /schema/schema.json

To reproduce I ran:

#!/usr/bin/env bash

set -e
pliny-new 'test-pliny'
cd 'test-pliny'
sed -i 's|gem "rollbar"| gem "rollbar", require: "rollbar/middleware/sinatra"|' Gemfile
./bin/setup
pliny-generate scaffold chicken
sed -i 's|\(# mount all endpoints here\)|\1\nmount Endpoints::Chickens|' lib/routes.rb
bundle exec rake db:migrate
bundle exec rake

If I do add

sed -i 's|/docs/schema.json|/schema/schema.json|' spec/acceptance/chickens_spec.rb

I then get a "Content-Type" response header must be set to "application/json"

After that if I add

sed -i "s|content_type :json, charset: 'utf-8'|content_type :json|" lib/endpoints/chickens.rb

everything works as expected

These are probably different parts all not playing nice together. I know the last one comes from committee some how and I don't think we want to drop the utf-8 from the content type.

Support for MySQL

I would like to add support for MySQL in Pliny. But before jumping into working on this, I'd like to get some feedback whether this would be a beneficial addition.

0.6 pliny-new broken

$ pliny-new pliny-getting-started
/usr/local/lib/ruby/gems/2.1.0/gems/pliny-0.6.0/lib/pliny/commands/creator.rb:5:in `<top (required)>': uninitialized constant Pliny (NameError)
    from /usr/local/lib/ruby/gems/2.1.0/gems/pliny-0.6.0/bin/pliny-new:4:in `require_relative'
    from /usr/local/lib/ruby/gems/2.1.0/gems/pliny-0.6.0/bin/pliny-new:4:in `<top (required)>'
    from /usr/local/bin/pliny-new:23:in `load'
    from /usr/local/bin/pliny-new:23:in `<main>'

Filter incoming params

We currently don't have any way of filtering incoming parameters, which ends up in several apps not doing so at all, and a potential for security issues.
This issue is here to discuss a parameters filtering middleware that would allow solving that problem.

My idea -heavily inspired by how rails' StrongParameters works would be to have the middleware entirely replace the params object to be a Pliny::FilteredParams.
That object would behave like a hash, but wouldn't return any non-allowed keys.

eg:

Pliny::FilteredParams.new({hello: 'world'}).keys #=> []
Pliny::FilteredParams.new({hello: 'world'}).allow!(:hello).keys #=> [:hello]

Subhashes would have to be handled properly too.

params = Pliny::FilteredParams.new({hello: {bonjour: 'monde'}})
params[:hello].class #=> Pliny::FilteredParams

What do you think of this proposal? Any better ideas/objections?

Use grouping in specs template

Related to #18.

I would prefer a bit more verbose specs

  describe 'GET <%= url_path %>' do
    subject { get '<%= url_path %>' }

    it 'returns correct status code' do
      subject
      last_response.status.should eq(200)
    end

    it 'conforms to schema' do
      subject
      assert_schema_conform
    end
  end

If we use subject or not is not important for me. Only the grouping.

Order in Initializer.run

Current order in Initializer.run is:

  def self.run
    require_config
    initialize_database
    require_lib
    require_initializers
  end

If you have an initializer, like config/initializers/sequel.rb with, for example

Sequel::Database.extension(:pg_array)
Sequel::Database.extension(:pg_hstore)
Sequel::Database.extension(:current_datetime_timestamp)
Sequel::Model.plugin(:auto_validations)
Sequel::Model.plugin(:constraint_validations)

it would run to late to modify the model (require_lib required all models) and much to late to load the database extensions (initialize_database built already the db connection).

Pliny exceptions getting logged to Rollbar

Rollbar is injecting its Rack::Builder middleware in a way that it's getting precedence over Pliny::Middleware::RescueErrors. This means that internal Pliny exceptions like Unauthorized are getting logged before we rescue and convert them into a proper http response.

.env file is ignored in development

When I create a blank app and run bin/setup to create .env and databases, running an application through rackup or executing commands fail due to DATABASE_URL missing, even though the variable is defined in .env.

Looking closer at the source, it seems that .env is not being actually parsed anywhere, except for .env.test within Rake tasks and the spec_helper.

How do you handle .env file? Do you use something like Direnv to manage environment variables externally?

Anyway, I think there should be a mention in the README and/or the template app should have an initializer to load .env automatically.

Problems with sidekiq

This should work within routes.rb:

...
  use Pliny::Router do
    version '1' do
      mount Endpoints::V1::Blah
      mount Sidekiq::Web => '/sidekiq'
    end
  end

  run Endpoints::Root

However, sidekiq just 404's. What are missing here?

Timeout middleware should not exist or at least not be used by default

Because timing out a thread at any random point is inherently unsafe… e.g. causing state corruption in non-atomic changes.

Cf. rack-timeout's readme and this detailed explanation by Charles Nutter.

So timing out dangerously should be an active choice by the developer, and in that case, using rack-timeout is a better option as at least it provides some useful logging (plus special handling for router wait time and post requests, although it can all be disabled if you want simple.)

DB-independent version of pliny - any interest?

Hello,

I really like pliny's template, but lately I often find myself working on either non-DB-backed APIs, or on APIs using different DBs and approaches (say, with Redis in the background). I forked and build my own version of pliny, that doesn't have any db dependencies in it, but I wonder if there's any interest from you in including this kind of functionality in pliny itself.

I understand that pliny opinionated, so Postgres dependency could qualify as one of the dependencies - in which case I'll just go with supporting my own fork for a while, or I could put some effort to expose certain options to make DB dependency configurable.

Could you share your thoughts on this topic?

Thank you.

Migration wiki page

_Can we use the text bellow for the Migration wiki page? Any suggestion to improve it?_

You can use use the migration generator to create a new Sequel migration to modify your database schema.

Create a new migration like:

$ pliny-generate migration "add phone to artists"
created migration ./db/migrate/1438776880_add_phone_to_artists.rb

It will create an empty migration:

Sequel.migration do
  up do
  end

  down do
  end
end

You can edit the migration to suit your needs and then run it with:

$ rake db:migrate

Further reading:

Object::Config is not defined in MRI 2.2.0

config_helpers file attempts to remove the Config constant due to a deprecation warning in earlier versions of MRI. In MRI 2.2.0 the constant is finally removed, but this breaks Pliny under 2.2.0 with NameError (constant Object::Config not defined).

The line should check whether the constant is actually defined on Object and only then remove it, e.g.:

Object.send :remove_const, :Config if Object.const_defined? :Config

PG::ConnectionBad: could not connect to server

I'm trying to get pliny to run with the boxen-installed postgres instance on my macbook. I've updated the DATABASE_URL in .env and .env.test to match the BOXEN_POSTGRESQL_URL:

DATABASE_URL=postgres://127.0.0.1:15432/testapp-test

However, when I run bin/setup I get the following error at the rake db:setup stage:

rake aborted!
Sequel::DatabaseConnectionError: PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Tasks: TOP => db:setup => db:drop
(See full trace by running task with --trace)

Support for MongoDB

Is it the plan of pliny to allow the use of mongodb as optional resource?
If so, I'm changing some items to use on my current project and open a PR for it.

Thanks so much. 🍻

Remove hard dependencies on pg/sequel

Pliny generates a template with pg and sequel gems by default and that's totally fine. However you can't completely remove these gems from your dependencies because pliny gem itself has them in its runtime dependencies. I don't see a reason for that.

User should be able to remove unused DB code from the app.

Bad file descriptor @ fptr_finalize

I was getting the above error when running foreman start. It was fixed by running

bundle update backports

as described here.

Full error for reference:

$ foreman start
10:00:22 web.1  | started with pid 99636
10:00:23 web.1  | [99636] Puma starting in cluster mode...
10:00:23 web.1  | [99636] * Version 2.8.2 (ruby 2.1.4-p265), codename: Sir Edmund Percival Hillary
10:00:23 web.1  | [99636] * Min threads: 1, max threads: 16
10:00:23 web.1  | [99636] * Environment: development
10:00:23 web.1  | [99636] * Process workers: 3
10:00:23 web.1  | [99636] * Preloading application
10:00:24 web.1  | [99636] ! Unable to load application
10:00:24 web.1  | /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb:2:in `close': Bad file descriptor @ fptr_finalize - /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb (Errno::EBADF)
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb:2:in `open'
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb:2:in `<top (required)>'
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require'
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require_with_backports'
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/tools.rb:22:in `block in require_relative_dir'
10:00:24 web.1  |   from /opt/boxen/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/backports-3.6.0/lib/backports/tools.rb:21:in `each'

Thor required arguments don't seem to be required.

$ pliny-generate serializer
created serializer file ./lib/serializers/.rb
created test ./spec/serializers/_spec.rb

These commands are Thor actions, which indicates that the name should be required at the Thor level: https://github.com/erikhuda/thor/wiki/Getting-Started#task-parameters

I'm hesitant to add logic here if Thor is supposed to fail the task for us. Thoughts? Could it be because we're not inheriting from Thor correctly? Looking at the Thor docs, it seems correct, but we aren't taking advantage of Thor::Actions in the generators class. Doesn't seem like we need it, though.

PG::UndefinedFunction: ERROR: function uuid_generate_v4() does not exist

When running db:migrate I get this error

PG::UndefinedFunction: ERROR:  function uuid_generate_v4() does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Maybe this should be added to the first migration?

    self.execute <<-EOF
      CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
    EOF

Lets merge the template back here?

Hey folks,

Time to come full circle: how about we just keep the template on this repo instead of the submodule?

I think things are a bit confusing now – it's hard to know where to open issues, changes constantly need two matching pull requests, releases tag two repos, etc.

Scaffold generates schema with NAME definition but don't generate that attribute on migrations/serializers

The main purpose here is discuss if a name definition should be really presumed to exist on migrations/serializers/schema template.

Today, when we use scaffold to generate an endpoint/model/schema/serializer its schema presumes that an attribute name should be serialized, but that attribute is not included on the migration neither on the serializer.
So, when we run the acceptance test, an InvalidResponse error is raised with the message #: failed schema #/definitions/[schema_name]: "name" wasn't supplied.

The first question is: should a name attribute really be expected by the schema?

The second question is: if the schema expect the existence of a name attribute, why it is not included on the template for migrations and serializer?

Support app namespace module

I decided that I wanted my app code namespaced in a module, but the pliny generator commands don't support this. I end up wrapping things in module Foo ... end manually, and I inevitably miss something and things break. Could the generator support this out of the box, perhaps optionally?

No convenient way to reload!

I'm spending a bunch of time in console while getting code working.

Right now there is no obvious way to reload everything in the existing session, i.e like Rails's reload!.

seed.rb comment is misleading

A Sequel database connection can be obtained via Sequel::Model.db

If you're running rake db:seeds against multiple database, Sequel::Model.db will point to the first database it connect to, resulting in running SQL against the same database against. A workaround is to use db = Sequel::DATABASES.last.

Prmd dependency

Are there any reasons for the explicit dependency on prmd 0.6.1?

rake db:rollback not working

Appears to be a regression in the latest version (0.8) when running rake db:rollback.

The migration doesn't actually run for some reason.

I'm trying to get to the bottom of why.

Updating the rack-timeout gem break pliny

Using rack-timeout 0.3.1

$ rake
rake aborted!
LoadError: cannot load such file -- rack/timeout
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/pliny-0.11.1/lib/pliny.rb:2:in `require'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/pliny-0.11.1/lib/pliny.rb:2:in `<top (required)>'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/dyego/code/dyego-app/spec/spec_helper.rb:11:in `<top (required)>'
/Users/dyego/code/dyego-app/spec/acceptance/artists_spec.rb:1:in `<top (required)>'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
/Users/dyego/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
/Users/dyego/code/dyego-app/lib/tasks/spec.rake:6:in `block in <top (required)>'
Tasks: TOP => default => spec
(See full trace by running task with --trace)

Also any new app generated from pliny-new will be initially broken since the rack-timeout isn't lock on a compatible version.

Weird casing behaviour

pliny-generate model Artist

results in:

created model file ./lib/models/Artist.rb
created migration ./db/migrate/1402522750_create_artists.rb
created test ./spec/models/Artist_spec.rb
created serializer file ./lib/serializers/Artist_serializer.rb
created test ./spec/serializers/Artist_serializer_spec.rb

which isn't great (note the Atist casing). I went to fix this and noticed that #name in Pliny::Commands::Generator is already down-casing so unsure what's happening here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.