her 0.5.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +1 -1
- data/README.md +78 -63
- data/UPGRADE.md +21 -0
- data/lib/her/model.rb +2 -1
- data/lib/her/model/associations.rb +17 -54
- data/lib/her/model/associations/association.rb +46 -0
- data/lib/her/model/associations/belongs_to_association.rb +34 -0
- data/lib/her/model/associations/has_many_association.rb +43 -0
- data/lib/her/model/associations/has_one_association.rb +33 -0
- data/lib/her/model/attributes.rb +19 -19
- data/lib/her/model/base.rb +5 -0
- data/lib/her/model/http.rb +17 -21
- data/lib/her/model/orm.rb +11 -35
- data/lib/her/model/parse.rb +4 -12
- data/lib/her/model/paths.rb +3 -2
- data/lib/her/model/relation.rb +113 -0
- data/lib/her/version.rb +1 -1
- data/spec/model/associations_spec.rb +48 -4
- data/spec/model/introspection_spec.rb +1 -1
- data/spec/model/orm_spec.rb +21 -102
- data/spec/model/parse_spec.rb +36 -7
- data/spec/model/paths_spec.rb +3 -3
- data/spec/model/relation_spec.rb +89 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/macros/her_macros.rb +17 -0
- data/spec/support/macros/request_macros.rb +19 -0
- metadata +13 -37
- data/examples/grape-and-her/.env.default +0 -3
- data/examples/grape-and-her/Procfile +0 -2
- data/examples/grape-and-her/README.md +0 -27
- data/examples/grape-and-her/api/Gemfile +0 -11
- data/examples/grape-and-her/api/Rakefile +0 -14
- data/examples/grape-and-her/api/app/api.rb +0 -49
- data/examples/grape-and-her/api/app/models/organization.rb +0 -7
- data/examples/grape-and-her/api/app/models/user.rb +0 -9
- data/examples/grape-and-her/api/app/views/organizations/_base.rabl +0 -2
- data/examples/grape-and-her/api/app/views/organizations/index.rabl +0 -3
- data/examples/grape-and-her/api/app/views/organizations/show.rabl +0 -3
- data/examples/grape-and-her/api/app/views/users/_base.rabl +0 -8
- data/examples/grape-and-her/api/app/views/users/index.rabl +0 -3
- data/examples/grape-and-her/api/app/views/users/show.rabl +0 -3
- data/examples/grape-and-her/api/config.ru +0 -5
- data/examples/grape-and-her/api/config/boot.rb +0 -17
- data/examples/grape-and-her/api/config/unicorn.rb +0 -7
- data/examples/grape-and-her/api/db/migrations/001_create_users.rb +0 -11
- data/examples/grape-and-her/api/db/migrations/002_create_organizations.rb +0 -8
- data/examples/grape-and-her/consumer/Gemfile +0 -23
- data/examples/grape-and-her/consumer/app/assets/stylesheets/application.scss +0 -190
- data/examples/grape-and-her/consumer/app/assets/stylesheets/reset.scss +0 -53
- data/examples/grape-and-her/consumer/app/consumer.rb +0 -74
- data/examples/grape-and-her/consumer/app/models/organization.rb +0 -13
- data/examples/grape-and-her/consumer/app/models/user.rb +0 -13
- data/examples/grape-and-her/consumer/app/views/index.haml +0 -9
- data/examples/grape-and-her/consumer/app/views/layout.haml +0 -20
- data/examples/grape-and-her/consumer/app/views/organizations/index.haml +0 -25
- data/examples/grape-and-her/consumer/app/views/organizations/show.haml +0 -11
- data/examples/grape-and-her/consumer/app/views/users/index.haml +0 -33
- data/examples/grape-and-her/consumer/app/views/users/show.haml +0 -9
- data/examples/grape-and-her/consumer/config.ru +0 -20
- data/examples/grape-and-her/consumer/config/boot.rb +0 -30
- data/examples/grape-and-her/consumer/config/unicorn.rb +0 -7
- data/examples/grape-and-her/consumer/lib/response_logger.rb +0 -18
@@ -1,25 +0,0 @@
|
|
1
|
-
%h2 Create new organization
|
2
|
-
|
3
|
-
%form{ url: "/organizations", method: 'post' }
|
4
|
-
- if @organization.response_errors.any?
|
5
|
-
%ul.errors
|
6
|
-
%p The organization could not be created:
|
7
|
-
%ul
|
8
|
-
- @organization.response_errors.each do |error|
|
9
|
-
%li= error
|
10
|
-
|
11
|
-
%p
|
12
|
-
%label{ for: 'name' } Name
|
13
|
-
%input{ type: 'text', name: 'organization[name]', value: @organization.name, id: 'name' }
|
14
|
-
%p
|
15
|
-
%button{ type: 'submit' } Create
|
16
|
-
|
17
|
-
%hr
|
18
|
-
%h3 Current organizations
|
19
|
-
- if @organizations.any?
|
20
|
-
%ul.records
|
21
|
-
- @organizations.each do |organization|
|
22
|
-
%li
|
23
|
-
%a{ href: "/organizations/#{organization.id}" }= organization.name
|
24
|
-
- else
|
25
|
-
%p.no-records There are currently no organizations.
|
@@ -1,33 +0,0 @@
|
|
1
|
-
%h2 Create new user
|
2
|
-
|
3
|
-
%form{ url: "/users", method: 'post' }
|
4
|
-
- if @user.response_errors.any?
|
5
|
-
.errors
|
6
|
-
%p The user could not be created:
|
7
|
-
%ul
|
8
|
-
- @user.response_errors.each do |error|
|
9
|
-
%li= error
|
10
|
-
|
11
|
-
%p
|
12
|
-
%label{ for: 'email' } Email
|
13
|
-
%input{ type: 'email', name: 'user[email]', value: @user.email, id: 'email' }
|
14
|
-
%p
|
15
|
-
%label{ for: 'fullname' } Full Name
|
16
|
-
%input{ type: 'text', name: 'user[fullname]', value: @user.fullname, id: 'fullname' }
|
17
|
-
%p
|
18
|
-
%label{ for: 'organization_id' } Organization
|
19
|
-
%select{ name: 'user[organization_id]', id: 'organization_id' }
|
20
|
-
- Organization.all.each do |organization|
|
21
|
-
%option{ value: organization.id }= organization.name
|
22
|
-
%p
|
23
|
-
%button{ type: 'submit' } Create
|
24
|
-
|
25
|
-
%hr
|
26
|
-
%h3 Current users
|
27
|
-
- if @users.any?
|
28
|
-
%ul.records
|
29
|
-
- @users.each do |user|
|
30
|
-
%li
|
31
|
-
%a{ href: "/users/#{user.id}" }= user.fullname
|
32
|
-
- else
|
33
|
-
%p.no-records There are currently no users.
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('../config/boot', __FILE__)
|
2
|
-
|
3
|
-
map "/assets" do
|
4
|
-
sprockets = Sprockets::Environment.new.tap do |s|
|
5
|
-
s.append_path File.join(File.dirname(__FILE__), 'app', 'assets', 'stylesheets')
|
6
|
-
s.append_path File.join(File.dirname(__FILE__), 'app', 'assets', 'images')
|
7
|
-
|
8
|
-
Sprockets::Helpers.configure do |config|
|
9
|
-
config.environment = s
|
10
|
-
config.prefix = "/assets"
|
11
|
-
config.digest = true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
run sprockets
|
16
|
-
end
|
17
|
-
|
18
|
-
map "/" do
|
19
|
-
run Consumer
|
20
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Bundler setup
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
3
|
-
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
4
|
-
Bundler.require(:default, ENV['RACK_ENV']) if defined? Bundler
|
5
|
-
|
6
|
-
# Require libraries
|
7
|
-
Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each do |file|
|
8
|
-
dirname = File.dirname(file)
|
9
|
-
file_basename = File.basename(file, File.extname(file))
|
10
|
-
require "#{dirname}/#{file_basename}"
|
11
|
-
end
|
12
|
-
|
13
|
-
# Configure Her
|
14
|
-
Her::API.setup :url => "http://0.0.0.0:3100" do |c|
|
15
|
-
c.use Faraday::Request::UrlEncoded
|
16
|
-
c.use Her::Middleware::DefaultParseJSON
|
17
|
-
c.use ResponseBodyLogger, $logger
|
18
|
-
c.use Faraday::Response::Logger, $logger
|
19
|
-
c.use Faraday::Adapter::NetHttp
|
20
|
-
end
|
21
|
-
|
22
|
-
# Require models
|
23
|
-
Dir[File.expand_path('../../app/models/**/*.rb', __FILE__)].each do |file|
|
24
|
-
dirname = File.dirname(file)
|
25
|
-
file_basename = File.basename(file, File.extname(file))
|
26
|
-
require "#{dirname}/#{file_basename}"
|
27
|
-
end
|
28
|
-
|
29
|
-
# Application setup
|
30
|
-
require File.expand_path('../../app/consumer', __FILE__)
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
class ResponseBodyLogger < Faraday::Response::Middleware
|
5
|
-
def initialize(app, logger)
|
6
|
-
@app = app
|
7
|
-
@logger = logger
|
8
|
-
end
|
9
|
-
|
10
|
-
def on_complete(env)
|
11
|
-
@logger.info ""
|
12
|
-
@logger.info env[:body]
|
13
|
-
@logger.info "\n"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
$strio = StringIO.new
|
18
|
-
$logger = Logger.new($strio).tap { |logger| logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" } }
|