smooth 2.0.1 → 2.0.2
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 +4 -4
- data/.gitignore +7 -0
- data/Gemfile +1 -2
- data/README.md +150 -5
- data/Rakefile +16 -0
- data/app/assets/javascripts/smooth/index.js +5152 -0
- data/bin/smooth +9 -0
- data/{app/assets/javascripts/smooth → developer-tools}/.keep +0 -0
- data/developer-tools/bower.json +8 -0
- data/developer-tools/config.ru +3 -0
- data/developer-tools/dist/08d606864d3ad3f0b98660d391f5a1c2.gif +0 -0
- data/developer-tools/dist/2d66bcdc27cd89f71068e98a7a929712.gif +0 -0
- data/developer-tools/dist/3e9816417b11485d454f9b3662b06e7b.eot +0 -0
- data/developer-tools/dist/47de617fd1d745ad120ccb9e2924b98c.gif +0 -0
- data/developer-tools/dist/5ae23ad29b67289a1375d2043e289c52.eot +0 -0
- data/developer-tools/dist/60c2a8500e63bf211b7df9608f7613ea.svg +450 -0
- data/developer-tools/dist/645f50ba6c1e56f078fa018855d97eb0.gif +0 -0
- data/developer-tools/dist/71ab514d1cedda303417ad7a06472fea.ttf +0 -0
- data/developer-tools/dist/8cca2f02b0af2da365ff4d1755f29146.ttf +0 -0
- data/developer-tools/dist/939cf252f0eb4efbd2d170c974411c49.gif +0 -0
- data/developer-tools/dist/9af25aaeb6ca6d08d213b04841813eb5.gif +0 -0
- data/developer-tools/dist/b683029bafe0305ac2234038a03e1541.woff +0 -0
- data/developer-tools/dist/c9dec22105ad9330c811599b8b6464f8.woff +0 -0
- data/developer-tools/dist/ca279c55a51ab2641c4712a333633581.gif +0 -0
- data/developer-tools/dist/client.js +5152 -0
- data/developer-tools/dist/f5b27137d3f5e9b1d91b16b37386dd03.gif +0 -0
- data/developer-tools/dist/f99a231ed57ee113b50b1c3e9f9fcdc3.svg +399 -0
- data/developer-tools/dist/index.html +18 -0
- data/developer-tools/dist/inspector.js +38432 -0
- data/developer-tools/dist/jquery.min.js +9190 -0
- data/developer-tools/package.json +39 -0
- data/developer-tools/server.js +14 -0
- data/developer-tools/src/client.coffee +21 -0
- data/developer-tools/src/client/collection.coffee +14 -0
- data/developer-tools/src/client/model.coffee +11 -0
- data/developer-tools/src/client/resource.coffee +132 -0
- data/{app/controllers/.keep → developer-tools/src/client/runner.coffee} +0 -0
- data/developer-tools/src/dependencies.coffee +7 -0
- data/developer-tools/src/inspector.cjsx +49 -0
- data/developer-tools/src/inspector/models/interface_collection.coffee +31 -0
- data/developer-tools/src/inspector/pages/index.cjsx +31 -0
- data/developer-tools/src/inspector/pages/resources.cjsx +5 -0
- data/developer-tools/src/inspector/views/grid_sort.cjsx +23 -0
- data/developer-tools/src/inspector/views/icon_heading.cjsx +15 -0
- data/developer-tools/src/inspector/views/resource_card.cjsx +34 -0
- data/developer-tools/src/inspector/views/sidebar.cjsx +12 -0
- data/developer-tools/src/inspector/views/toolbar.cjsx +17 -0
- data/developer-tools/src/styles/index.scss +136 -0
- data/developer-tools/src/styles/views.scss +13 -0
- data/developer-tools/src/util.coffee +48 -0
- data/developer-tools/webpack.config.js +56 -0
- data/developer-tools/webpack.hot.config.js +65 -0
- data/lib/smooth.rb +209 -28
- data/lib/smooth/active_record/adapter.rb +24 -0
- data/lib/smooth/api.rb +272 -18
- data/lib/smooth/api/policy.rb +2 -2
- data/lib/smooth/api/tracking.rb +4 -4
- data/lib/smooth/application.rb +66 -0
- data/lib/smooth/cache.rb +1 -1
- data/lib/smooth/command.rb +267 -18
- data/lib/smooth/command/async_worker.rb +27 -0
- data/lib/smooth/command/instrumented.rb +6 -4
- data/lib/smooth/command/run_proxy.rb +21 -0
- data/lib/smooth/configuration.rb +63 -8
- data/lib/smooth/documentation.rb +3 -6
- data/lib/smooth/dsl.rb +1 -36
- data/lib/smooth/dsl_adapter.rb +34 -0
- data/lib/smooth/event.rb +8 -4
- data/lib/smooth/event/proxy.rb +9 -0
- data/lib/smooth/event/relay.rb +38 -0
- data/lib/smooth/example.rb +1 -1
- data/lib/smooth/ext/core.rb +16 -0
- data/lib/smooth/model_adapter.rb +31 -0
- data/lib/smooth/query.rb +143 -13
- data/lib/smooth/resource.rb +227 -52
- data/lib/smooth/resource/router.rb +217 -0
- data/lib/smooth/resource/templating.rb +62 -0
- data/lib/smooth/resource/tracking.rb +1 -1
- data/lib/smooth/response.rb +73 -0
- data/lib/smooth/serializer.rb +102 -11
- data/lib/smooth/user_adapter.rb +83 -0
- data/lib/smooth/util.rb +17 -0
- data/lib/smooth/version.rb +1 -1
- data/smooth.gemspec +6 -2
- data/spec/acceptance/books_routes_spec.rb +50 -0
- data/spec/acceptance/embedded_relationships_spec.rb +26 -0
- data/spec/dummy/app/apis/application_api.rb +8 -3
- data/spec/dummy/app/commands/create_book.rb +5 -0
- data/spec/dummy/app/models/book.rb +1 -0
- data/spec/dummy/app/models/library.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/queries/book_query.rb +13 -0
- data/spec/dummy/app/resources/{books.rb → books_definition.rb} +37 -12
- data/spec/dummy/db/migrate/20140824215902_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20140826193259_create_libraries.rb +10 -0
- data/spec/dummy/db/schema.rb +8 -1
- data/spec/lib/smooth/api/async_spec.rb +21 -0
- data/spec/lib/smooth/api_spec.rb +8 -0
- data/spec/lib/smooth/command_spec.rb +87 -6
- data/spec/lib/smooth/configuration_spec.rb +4 -0
- data/spec/lib/smooth/event/relay_spec.rb +33 -0
- data/spec/lib/smooth/event_spec.rb +5 -8
- data/spec/lib/smooth/query_spec.rb +42 -0
- data/spec/lib/smooth/resource/router_spec.rb +14 -0
- data/spec/lib/smooth/resource_spec.rb +33 -1
- data/spec/lib/smooth/serializer_spec.rb +20 -0
- data/spec/lib/smooth/templating_spec.rb +23 -0
- data/spec/lib/smooth/util_spec.rb +22 -0
- data/spec/spec_helper.rb +1 -1
- metadata +151 -17
- data/app/helpers/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/views/.keep +0 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe "The Smooth Command" do
|
|
4
|
-
let(:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
expect(command.input_descriptions[:like]).not_to be_blank
|
|
8
|
-
expect(command.input_descriptions[:left_out]).to be_blank
|
|
9
|
-
end
|
|
4
|
+
let(:books) { Smooth.current_api.resource("Books") }
|
|
5
|
+
let(:command) { books.fetch(:command, :like) }
|
|
6
|
+
let(:create_command) { books.fetch(:command, :create) }
|
|
10
7
|
|
|
11
8
|
it "should know the resource name" do
|
|
12
9
|
expect(command.resource_name).to eq("Books")
|
|
13
10
|
end
|
|
14
11
|
|
|
12
|
+
it "should reference the parent resource" do
|
|
13
|
+
expect(command.parent_resource).to equal(books)
|
|
14
|
+
end
|
|
15
|
+
|
|
15
16
|
it "should know the command action" do
|
|
16
17
|
expect(command.command_action).to eq("like")
|
|
17
18
|
end
|
|
@@ -20,6 +21,86 @@ describe "The Smooth Command" do
|
|
|
20
21
|
expect(command.event_namespace).to eq("like.book")
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
it "should know the model class" do
|
|
25
|
+
expect(command.model_class).to equal(Book)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should know its object path" do
|
|
29
|
+
expect(books.api.lookup(command.object_path)).to eq(LikeBook)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "Execution Patterns" do
|
|
33
|
+
it "should follow common execution patterns if specified" do
|
|
34
|
+
cmd = books.fetch(:command, :update)
|
|
35
|
+
expect(cmd.get_execution_pattern(:update)).to respond_to(:call)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "Interface Documentation" do
|
|
40
|
+
it "should document the interface" do
|
|
41
|
+
expect(command.interface_documentation).not_to be_empty
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should allow me to supply faker templates for example data" do
|
|
45
|
+
example = create_command.interface_documentation.filters.title.example
|
|
46
|
+
expect(example).not_to be_nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should allow for descriptions of the filters" do
|
|
50
|
+
expected = "You can manually pass true or false. If you leave it off, it will toggle the liking status"
|
|
51
|
+
expect(command.input_descriptions[:like]).to eq(expected)
|
|
52
|
+
|
|
53
|
+
# we didn't document this so it should be blank
|
|
54
|
+
expect(command.input_descriptions[:left_out]).to be_blank
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "Automatic model scoping" do
|
|
59
|
+
it "should provide a reference to the model scope" do
|
|
60
|
+
class Book < ActiveRecord::Base
|
|
61
|
+
scope :published_after, ->(year) { where(year_published: year) }
|
|
62
|
+
scope :no_args, -> {all}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
k = Class.new(Smooth::Command) do
|
|
66
|
+
self.model_class = Book
|
|
67
|
+
|
|
68
|
+
scope(:published_after)
|
|
69
|
+
|
|
70
|
+
required do
|
|
71
|
+
string :title
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def execute
|
|
75
|
+
scope.where(title: title).first_or_create
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# This is just laziness since i don't have a user model yet.
|
|
80
|
+
# I am just making sure that this value makes it to the scope anyway
|
|
81
|
+
book = k.as(2001).run(title:"sup").result
|
|
82
|
+
|
|
83
|
+
expect(book.year_published).to eq(2001)
|
|
84
|
+
expect(book.title).to eq("sup")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "Current user awareness" do
|
|
89
|
+
it "should be aware of who is running the command" do
|
|
90
|
+
k = Class.new(Smooth::Command) do
|
|
91
|
+
required do
|
|
92
|
+
integer :argument
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def execute
|
|
96
|
+
argument + current_user
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
expect(k.as(1).run(argument: 2).result).to eq(3)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
23
104
|
describe "Event Tracking Integration" do
|
|
24
105
|
it "should track events" do
|
|
25
106
|
bucket = []
|
|
@@ -13,4 +13,8 @@ describe "Smooth Configuration" do
|
|
|
13
13
|
it "should enable event tracking by default" do
|
|
14
14
|
expect(Smooth.config.enable_event_tracking?).to eq(true)
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
it "should enable loading app folders by default" do
|
|
18
|
+
expect(Smooth.config.eager_load_app_folders?).to eq(true)
|
|
19
|
+
end
|
|
16
20
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
class EventRelayTester < Smooth::Event::Relay
|
|
4
|
+
class_attribute :bucket
|
|
5
|
+
|
|
6
|
+
self.bucket = []
|
|
7
|
+
|
|
8
|
+
def relay event, event_name=nil
|
|
9
|
+
self.class.bucket << {event: event, event_name: event_name}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def process event, event_name=nil
|
|
13
|
+
[event, "processed:#{event_name}"]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "The Smooth Event Relay" do
|
|
18
|
+
let(:events) { relay.system }
|
|
19
|
+
let(:relay) { EventRelayTester.new('relayed.event') }
|
|
20
|
+
|
|
21
|
+
it "should relay events" do
|
|
22
|
+
bucket = relay.class.bucket
|
|
23
|
+
events.track_event("relayed.event", val: "sup")
|
|
24
|
+
expect(bucket).not_to be_empty
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should process the event before it relays it" do
|
|
28
|
+
bucket = relay.class.bucket
|
|
29
|
+
events.track_event("relayed.event", val: "sup")
|
|
30
|
+
success = bucket.map {|h| h[:event_name] }.any? {|s| s == 'processed:relayed.event' }
|
|
31
|
+
expect(success).to eq(true)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -3,17 +3,14 @@ require "spec_helper"
|
|
|
3
3
|
describe "The Smooth Event Tracking API" do
|
|
4
4
|
let(:events) { Smooth::Event }
|
|
5
5
|
|
|
6
|
-
it "should use the instrumentation system to implement a little pub sub" do
|
|
7
|
-
|
|
6
|
+
it "should use the instrumentation system to implement a little pub sub dsl" do
|
|
7
|
+
needle = rand(46**8).to_s(36)
|
|
8
8
|
|
|
9
|
-
events.subscribe_to "test.smooth"
|
|
10
|
-
bucket << event
|
|
11
|
-
end
|
|
9
|
+
events.subscribe_to "test.smooth", (bucket=[])
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
events.track_event 'test.smooth', line: "what up #{ needle }?"
|
|
11
|
+
events.track_event 'test.smooth', val: needle
|
|
15
12
|
|
|
16
|
-
got_event = bucket.any? {|e| e.payload.
|
|
13
|
+
got_event = bucket.any? {|e| e.payload.val.include?(needle) }
|
|
17
14
|
|
|
18
15
|
expect(got_event).to equal(true)
|
|
19
16
|
end
|
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe "The Smooth Query" do
|
|
4
|
+
let(:query) { BookQuery }
|
|
5
|
+
let(:user) { User.where(email:"jon@chicago.com",role:"user").first_or_create }
|
|
6
|
+
let(:books) { Smooth("Books") }
|
|
4
7
|
|
|
8
|
+
before(:each) do
|
|
9
|
+
Book.delete_all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should work when the class is defined directly, as well as when it is defined via the dsl" do
|
|
13
|
+
expect(BookQuery.developer_defined_method).to eq(true)
|
|
14
|
+
expect(BookQuery.new.inline_dsl_method).to eq(true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should return some books" do
|
|
18
|
+
Book.where(title:"Animal Farm").first_or_create()
|
|
19
|
+
expect(query.run(title: "Animal Farm").result.count).to eq(1)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should query the books resource" do
|
|
23
|
+
Book.where(title:"Animal Farm").first_or_create()
|
|
24
|
+
expect(query.run(title: "Animal").result.count).to eq(1)
|
|
25
|
+
expect(query.run(title: "1984").result.count).to eq(0)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should tell me info about the query interface" do
|
|
29
|
+
description = query.interface_description.filters.year_published.description
|
|
30
|
+
expect(description).to include('published')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should track query events" do
|
|
34
|
+
bucket = []
|
|
35
|
+
Smooth.events.on("query.book", bucket)
|
|
36
|
+
query.as(user).run()
|
|
37
|
+
expect(bucket).not_to be_empty
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should belong to the book resource" do
|
|
41
|
+
expect(BookQuery.parent_resource).to equal(books)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should belong to the api" do
|
|
45
|
+
expect(query.parent_api).to eq(books.api)
|
|
46
|
+
end
|
|
5
47
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe "The Smooth Router" do
|
|
4
|
+
let(:books) { Smooth("Books") }
|
|
5
|
+
let(:router) { books.router }
|
|
6
|
+
|
|
7
|
+
it "should have descriptions of the routes" do
|
|
8
|
+
expect(router.descriptions).not_to be_empty
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should apply the routes to a sinatra app" do
|
|
12
|
+
expect(router.methods_table).to be_present
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -4,6 +4,22 @@ describe "The Smooth Resource" do
|
|
|
4
4
|
let(:api) { Smooth.current_api }
|
|
5
5
|
let(:books) { api.resource("Books") }
|
|
6
6
|
|
|
7
|
+
it "should do" do
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should define scopes on its model" do
|
|
11
|
+
api.resource("Books") do
|
|
12
|
+
model do
|
|
13
|
+
scope :model_defined_scope, -> { where("id is whatup") }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
scope :resource_defined_scope, -> { where("id is you know") }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
expect(Book).to respond_to(:model_defined_scope)
|
|
20
|
+
expect(Book).to respond_to(:resource_defined_scope)
|
|
21
|
+
end
|
|
22
|
+
|
|
7
23
|
it "should reference its parent api" do
|
|
8
24
|
expect(books.api).to be_present
|
|
9
25
|
end
|
|
@@ -12,7 +28,15 @@ describe "The Smooth Resource" do
|
|
|
12
28
|
expect(books.name).to eq("Books")
|
|
13
29
|
end
|
|
14
30
|
|
|
15
|
-
it "should have a
|
|
31
|
+
it "should have a route table" do
|
|
32
|
+
expect(books.route_table).not_to be_empty
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should expand the route table with actual values" do
|
|
36
|
+
expect(books.expand_routes(id:1).values).to include("/books/1/like", "/books/1")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should have an arbitrary defined command class" do
|
|
16
40
|
command = books.fetch(:command, :like)
|
|
17
41
|
expect(command).to respond_to(:run)
|
|
18
42
|
end
|
|
@@ -27,6 +51,14 @@ describe "The Smooth Resource" do
|
|
|
27
51
|
expect(command).to respond_to(:run)
|
|
28
52
|
end
|
|
29
53
|
|
|
54
|
+
it "should return a reference to the serializer class" do
|
|
55
|
+
expect(books.serializer_class).to equal(BookSerializer)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should return a reference to the query class" do
|
|
59
|
+
expect(books.query_class).to equal(BookQuery)
|
|
60
|
+
end
|
|
61
|
+
|
|
30
62
|
it "should generate a default serializer" do
|
|
31
63
|
expect(BookSerializer < Smooth::Serializer).to equal(true)
|
|
32
64
|
end
|
|
@@ -10,6 +10,15 @@ describe "The Smooth Serializer" do
|
|
|
10
10
|
|
|
11
11
|
it "should relate to the book model" do
|
|
12
12
|
expect(Book.active_model_serializer).to equal(serializer)
|
|
13
|
+
expect(serializer.model_class).to equal(Book)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should relate to the books resource" do
|
|
17
|
+
expect(serializer.parent_resource).to equal(books)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should relate to the api" do
|
|
21
|
+
expect(serializer.parent_api).to equal(books.api)
|
|
13
22
|
end
|
|
14
23
|
|
|
15
24
|
it "should have documentation for its attributes" do
|
|
@@ -23,4 +32,15 @@ describe "The Smooth Serializer" do
|
|
|
23
32
|
it "should have documentation for its computed properties" do
|
|
24
33
|
expect(serializer.documentation_for_attribute(:computed_property).description).not_to be_blank
|
|
25
34
|
end
|
|
35
|
+
|
|
36
|
+
it "should have documentation for its computed properties" do
|
|
37
|
+
expect(serializer.documentation_for_attribute(:another_computed_property).description).not_to be_blank
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should serialize the object properly" do
|
|
41
|
+
book = Book.create(title:"Serialize This Man")
|
|
42
|
+
serialized = serializer.new(book).as_json
|
|
43
|
+
expect(serialized[:book]).not_to be_empty
|
|
44
|
+
expect(serialized[:book][:another_computed_property]).not_to be_nil
|
|
45
|
+
end
|
|
26
46
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe "Resource Object Templates" do
|
|
4
|
+
let(:books) { Smooth("Books") }
|
|
5
|
+
|
|
6
|
+
it "should let me build templated book objects" do
|
|
7
|
+
expect(books.build_from_template().title).to be_present
|
|
8
|
+
expect(books.build_from_template(title:"Shit Homie").title).to eq("Shit Homie")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should let me create templated book objects" do
|
|
12
|
+
expect(books.create_from_template().title).to be_present
|
|
13
|
+
expect(books.create_from_template(title:"Shit Homie").title).to eq("Shit Homie")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should let me define custom templates" do
|
|
17
|
+
expect(books.build_from_template(:ancient).year_published).to eq(1776)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should know if a template has been registered" do
|
|
21
|
+
expect(books.template_registered?).to eq(true)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe "The Smooth Utils" do
|
|
4
|
+
it "should build a uri template parser" do
|
|
5
|
+
expect(Smooth.util.uri_template("/api/:version/:resource_name")).to respond_to(:extract)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should extract vars from a url template" do
|
|
9
|
+
template = Smooth.util.uri_template("/api/:version/:resource_name")
|
|
10
|
+
vars = Smooth.util.extract_url_vars(template, "/api/v1/books")
|
|
11
|
+
|
|
12
|
+
expect(vars[:version]).to eq("v1")
|
|
13
|
+
expect(vars[:resource_name]).to eq("books")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should expand a uri template" do
|
|
17
|
+
template = Smooth.util.uri_template("/api/:version/:resource_name")
|
|
18
|
+
expanded = Smooth.util.expand_url_template(template, version: "v1", resource_name: "books")
|
|
19
|
+
|
|
20
|
+
expect(expanded).to eq("/api/v1/books")
|
|
21
|
+
end
|
|
22
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smooth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Soeder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-03-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hashie
|
|
@@ -54,6 +54,20 @@ dependencies:
|
|
|
54
54
|
version: 4.0.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: active_model_serializers
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.8.0
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.8.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: ffaker
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
73
|
- - ">="
|
|
@@ -67,7 +81,7 @@ dependencies:
|
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
82
|
version: '0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
84
|
+
name: factory_girl
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
87
|
- - ">="
|
|
@@ -94,6 +108,48 @@ dependencies:
|
|
|
94
108
|
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: sinatra
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: escape_utils
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: uri_template
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
97
153
|
- !ruby/object:Gem::Dependency
|
|
98
154
|
name: bundler
|
|
99
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -209,7 +265,8 @@ dependencies:
|
|
|
209
265
|
description: Smooth provides a simple DSL building powerful JSON APIs on top of ActiveRecord.
|
|
210
266
|
email:
|
|
211
267
|
- jonathan.soeder@gmail.com
|
|
212
|
-
executables:
|
|
268
|
+
executables:
|
|
269
|
+
- smooth
|
|
213
270
|
extensions: []
|
|
214
271
|
extra_rdoc_files: []
|
|
215
272
|
files:
|
|
@@ -219,39 +276,96 @@ files:
|
|
|
219
276
|
- README.md
|
|
220
277
|
- Rakefile
|
|
221
278
|
- app/assets/images/smooth/.keep
|
|
222
|
-
- app/assets/javascripts/smooth
|
|
223
|
-
-
|
|
224
|
-
- app/helpers/.keep
|
|
225
|
-
- app/mailers/.keep
|
|
226
|
-
- app/models/.keep
|
|
227
|
-
- app/views/.keep
|
|
279
|
+
- app/assets/javascripts/smooth/index.js
|
|
280
|
+
- bin/smooth
|
|
228
281
|
- config/routes.rb
|
|
282
|
+
- developer-tools/.keep
|
|
283
|
+
- developer-tools/bower.json
|
|
284
|
+
- developer-tools/config.ru
|
|
285
|
+
- developer-tools/dist/08d606864d3ad3f0b98660d391f5a1c2.gif
|
|
286
|
+
- developer-tools/dist/2d66bcdc27cd89f71068e98a7a929712.gif
|
|
287
|
+
- developer-tools/dist/3e9816417b11485d454f9b3662b06e7b.eot
|
|
288
|
+
- developer-tools/dist/47de617fd1d745ad120ccb9e2924b98c.gif
|
|
289
|
+
- developer-tools/dist/5ae23ad29b67289a1375d2043e289c52.eot
|
|
290
|
+
- developer-tools/dist/60c2a8500e63bf211b7df9608f7613ea.svg
|
|
291
|
+
- developer-tools/dist/645f50ba6c1e56f078fa018855d97eb0.gif
|
|
292
|
+
- developer-tools/dist/71ab514d1cedda303417ad7a06472fea.ttf
|
|
293
|
+
- developer-tools/dist/8cca2f02b0af2da365ff4d1755f29146.ttf
|
|
294
|
+
- developer-tools/dist/939cf252f0eb4efbd2d170c974411c49.gif
|
|
295
|
+
- developer-tools/dist/9af25aaeb6ca6d08d213b04841813eb5.gif
|
|
296
|
+
- developer-tools/dist/b683029bafe0305ac2234038a03e1541.woff
|
|
297
|
+
- developer-tools/dist/c9dec22105ad9330c811599b8b6464f8.woff
|
|
298
|
+
- developer-tools/dist/ca279c55a51ab2641c4712a333633581.gif
|
|
299
|
+
- developer-tools/dist/client.js
|
|
300
|
+
- developer-tools/dist/f5b27137d3f5e9b1d91b16b37386dd03.gif
|
|
301
|
+
- developer-tools/dist/f99a231ed57ee113b50b1c3e9f9fcdc3.svg
|
|
302
|
+
- developer-tools/dist/index.html
|
|
303
|
+
- developer-tools/dist/inspector.js
|
|
304
|
+
- developer-tools/dist/jquery.min.js
|
|
305
|
+
- developer-tools/package.json
|
|
306
|
+
- developer-tools/server.js
|
|
307
|
+
- developer-tools/src/client.coffee
|
|
308
|
+
- developer-tools/src/client/collection.coffee
|
|
309
|
+
- developer-tools/src/client/model.coffee
|
|
310
|
+
- developer-tools/src/client/resource.coffee
|
|
311
|
+
- developer-tools/src/client/runner.coffee
|
|
312
|
+
- developer-tools/src/dependencies.coffee
|
|
313
|
+
- developer-tools/src/inspector.cjsx
|
|
314
|
+
- developer-tools/src/inspector/models/interface_collection.coffee
|
|
315
|
+
- developer-tools/src/inspector/pages/index.cjsx
|
|
316
|
+
- developer-tools/src/inspector/pages/resources.cjsx
|
|
317
|
+
- developer-tools/src/inspector/views/grid_sort.cjsx
|
|
318
|
+
- developer-tools/src/inspector/views/icon_heading.cjsx
|
|
319
|
+
- developer-tools/src/inspector/views/resource_card.cjsx
|
|
320
|
+
- developer-tools/src/inspector/views/sidebar.cjsx
|
|
321
|
+
- developer-tools/src/inspector/views/toolbar.cjsx
|
|
322
|
+
- developer-tools/src/styles/index.scss
|
|
323
|
+
- developer-tools/src/styles/views.scss
|
|
324
|
+
- developer-tools/src/util.coffee
|
|
325
|
+
- developer-tools/webpack.config.js
|
|
326
|
+
- developer-tools/webpack.hot.config.js
|
|
229
327
|
- lib/smooth.rb
|
|
328
|
+
- lib/smooth/active_record/adapter.rb
|
|
230
329
|
- lib/smooth/api.rb
|
|
231
330
|
- lib/smooth/api/policy.rb
|
|
232
331
|
- lib/smooth/api/tracking.rb
|
|
332
|
+
- lib/smooth/application.rb
|
|
233
333
|
- lib/smooth/cache.rb
|
|
234
334
|
- lib/smooth/command.rb
|
|
335
|
+
- lib/smooth/command/async_worker.rb
|
|
235
336
|
- lib/smooth/command/instrumented.rb
|
|
337
|
+
- lib/smooth/command/run_proxy.rb
|
|
236
338
|
- lib/smooth/configuration.rb
|
|
237
339
|
- lib/smooth/documentation.rb
|
|
238
340
|
- lib/smooth/dsl.rb
|
|
341
|
+
- lib/smooth/dsl_adapter.rb
|
|
239
342
|
- lib/smooth/event.rb
|
|
343
|
+
- lib/smooth/event/proxy.rb
|
|
344
|
+
- lib/smooth/event/relay.rb
|
|
240
345
|
- lib/smooth/example.rb
|
|
241
346
|
- lib/smooth/ext/core.rb
|
|
242
347
|
- lib/smooth/ext/mutations.rb
|
|
348
|
+
- lib/smooth/model_adapter.rb
|
|
243
349
|
- lib/smooth/query.rb
|
|
244
350
|
- lib/smooth/resource.rb
|
|
351
|
+
- lib/smooth/resource/router.rb
|
|
352
|
+
- lib/smooth/resource/templating.rb
|
|
245
353
|
- lib/smooth/resource/tracking.rb
|
|
354
|
+
- lib/smooth/response.rb
|
|
246
355
|
- lib/smooth/serializer.rb
|
|
356
|
+
- lib/smooth/user_adapter.rb
|
|
357
|
+
- lib/smooth/util.rb
|
|
247
358
|
- lib/smooth/version.rb
|
|
248
359
|
- smooth.gemspec
|
|
360
|
+
- spec/acceptance/books_routes_spec.rb
|
|
361
|
+
- spec/acceptance/embedded_relationships_spec.rb
|
|
249
362
|
- spec/dummy/README.rdoc
|
|
250
363
|
- spec/dummy/Rakefile
|
|
251
364
|
- spec/dummy/app/apis/application_api.rb
|
|
252
365
|
- spec/dummy/app/assets/images/.keep
|
|
253
366
|
- spec/dummy/app/assets/javascripts/application.js
|
|
254
367
|
- spec/dummy/app/assets/stylesheets/application.css
|
|
368
|
+
- spec/dummy/app/commands/create_book.rb
|
|
255
369
|
- spec/dummy/app/controllers/application_controller.rb
|
|
256
370
|
- spec/dummy/app/controllers/concerns/.keep
|
|
257
371
|
- spec/dummy/app/helpers/application_helper.rb
|
|
@@ -260,7 +374,10 @@ files:
|
|
|
260
374
|
- spec/dummy/app/models/author.rb
|
|
261
375
|
- spec/dummy/app/models/book.rb
|
|
262
376
|
- spec/dummy/app/models/concerns/.keep
|
|
263
|
-
- spec/dummy/app/
|
|
377
|
+
- spec/dummy/app/models/library.rb
|
|
378
|
+
- spec/dummy/app/models/user.rb
|
|
379
|
+
- spec/dummy/app/queries/book_query.rb
|
|
380
|
+
- spec/dummy/app/resources/books_definition.rb
|
|
264
381
|
- spec/dummy/app/views/layouts/application.html.erb
|
|
265
382
|
- spec/dummy/bin/bundle
|
|
266
383
|
- spec/dummy/bin/rails
|
|
@@ -284,27 +401,32 @@ files:
|
|
|
284
401
|
- spec/dummy/config/locales/en.yml
|
|
285
402
|
- spec/dummy/config/routes.rb
|
|
286
403
|
- spec/dummy/config/secrets.yml
|
|
287
|
-
- spec/dummy/db/development.sqlite3
|
|
288
404
|
- spec/dummy/db/migrate/20140822065900_create_books.rb
|
|
289
405
|
- spec/dummy/db/migrate/20140822065916_create_authors.rb
|
|
406
|
+
- spec/dummy/db/migrate/20140824215902_create_users.rb
|
|
407
|
+
- spec/dummy/db/migrate/20140826193259_create_libraries.rb
|
|
290
408
|
- spec/dummy/db/schema.rb
|
|
291
|
-
- spec/dummy/db/test.sqlite3
|
|
292
409
|
- spec/dummy/lib/assets/.keep
|
|
293
410
|
- spec/dummy/log/.keep
|
|
294
411
|
- spec/dummy/public/404.html
|
|
295
412
|
- spec/dummy/public/422.html
|
|
296
413
|
- spec/dummy/public/500.html
|
|
297
414
|
- spec/dummy/public/favicon.ico
|
|
415
|
+
- spec/lib/smooth/api/async_spec.rb
|
|
298
416
|
- spec/lib/smooth/api/policy_spec.rb
|
|
299
417
|
- spec/lib/smooth/api_spec.rb
|
|
300
418
|
- spec/lib/smooth/cache_spec.rb
|
|
301
419
|
- spec/lib/smooth/command_spec.rb
|
|
302
420
|
- spec/lib/smooth/configuration_spec.rb
|
|
421
|
+
- spec/lib/smooth/event/relay_spec.rb
|
|
303
422
|
- spec/lib/smooth/event_spec.rb
|
|
304
423
|
- spec/lib/smooth/example_spec.rb
|
|
305
424
|
- spec/lib/smooth/query_spec.rb
|
|
425
|
+
- spec/lib/smooth/resource/router_spec.rb
|
|
306
426
|
- spec/lib/smooth/resource_spec.rb
|
|
307
427
|
- spec/lib/smooth/serializer_spec.rb
|
|
428
|
+
- spec/lib/smooth/templating_spec.rb
|
|
429
|
+
- spec/lib/smooth/util_spec.rb
|
|
308
430
|
- spec/spec_helper.rb
|
|
309
431
|
homepage: http://smooth.io
|
|
310
432
|
licenses:
|
|
@@ -326,18 +448,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
326
448
|
version: '0'
|
|
327
449
|
requirements: []
|
|
328
450
|
rubyforge_project:
|
|
329
|
-
rubygems_version: 2.
|
|
451
|
+
rubygems_version: 2.2.2
|
|
330
452
|
signing_key:
|
|
331
453
|
specification_version: 4
|
|
332
454
|
summary: Smooth provides a DSL for creating self-testing, self-documenting, highly
|
|
333
455
|
inspectable API endpoints which are able to generate extendable client libraries.
|
|
334
456
|
test_files:
|
|
457
|
+
- spec/acceptance/books_routes_spec.rb
|
|
458
|
+
- spec/acceptance/embedded_relationships_spec.rb
|
|
335
459
|
- spec/dummy/README.rdoc
|
|
336
460
|
- spec/dummy/Rakefile
|
|
337
461
|
- spec/dummy/app/apis/application_api.rb
|
|
338
462
|
- spec/dummy/app/assets/images/.keep
|
|
339
463
|
- spec/dummy/app/assets/javascripts/application.js
|
|
340
464
|
- spec/dummy/app/assets/stylesheets/application.css
|
|
465
|
+
- spec/dummy/app/commands/create_book.rb
|
|
341
466
|
- spec/dummy/app/controllers/application_controller.rb
|
|
342
467
|
- spec/dummy/app/controllers/concerns/.keep
|
|
343
468
|
- spec/dummy/app/helpers/application_helper.rb
|
|
@@ -346,7 +471,10 @@ test_files:
|
|
|
346
471
|
- spec/dummy/app/models/author.rb
|
|
347
472
|
- spec/dummy/app/models/book.rb
|
|
348
473
|
- spec/dummy/app/models/concerns/.keep
|
|
349
|
-
- spec/dummy/app/
|
|
474
|
+
- spec/dummy/app/models/library.rb
|
|
475
|
+
- spec/dummy/app/models/user.rb
|
|
476
|
+
- spec/dummy/app/queries/book_query.rb
|
|
477
|
+
- spec/dummy/app/resources/books_definition.rb
|
|
350
478
|
- spec/dummy/app/views/layouts/application.html.erb
|
|
351
479
|
- spec/dummy/bin/bundle
|
|
352
480
|
- spec/dummy/bin/rails
|
|
@@ -370,25 +498,31 @@ test_files:
|
|
|
370
498
|
- spec/dummy/config/locales/en.yml
|
|
371
499
|
- spec/dummy/config/routes.rb
|
|
372
500
|
- spec/dummy/config/secrets.yml
|
|
373
|
-
- spec/dummy/db/development.sqlite3
|
|
374
501
|
- spec/dummy/db/migrate/20140822065900_create_books.rb
|
|
375
502
|
- spec/dummy/db/migrate/20140822065916_create_authors.rb
|
|
503
|
+
- spec/dummy/db/migrate/20140824215902_create_users.rb
|
|
504
|
+
- spec/dummy/db/migrate/20140826193259_create_libraries.rb
|
|
376
505
|
- spec/dummy/db/schema.rb
|
|
377
|
-
- spec/dummy/db/test.sqlite3
|
|
378
506
|
- spec/dummy/lib/assets/.keep
|
|
379
507
|
- spec/dummy/log/.keep
|
|
380
508
|
- spec/dummy/public/404.html
|
|
381
509
|
- spec/dummy/public/422.html
|
|
382
510
|
- spec/dummy/public/500.html
|
|
383
511
|
- spec/dummy/public/favicon.ico
|
|
512
|
+
- spec/lib/smooth/api/async_spec.rb
|
|
384
513
|
- spec/lib/smooth/api/policy_spec.rb
|
|
385
514
|
- spec/lib/smooth/api_spec.rb
|
|
386
515
|
- spec/lib/smooth/cache_spec.rb
|
|
387
516
|
- spec/lib/smooth/command_spec.rb
|
|
388
517
|
- spec/lib/smooth/configuration_spec.rb
|
|
518
|
+
- spec/lib/smooth/event/relay_spec.rb
|
|
389
519
|
- spec/lib/smooth/event_spec.rb
|
|
390
520
|
- spec/lib/smooth/example_spec.rb
|
|
391
521
|
- spec/lib/smooth/query_spec.rb
|
|
522
|
+
- spec/lib/smooth/resource/router_spec.rb
|
|
392
523
|
- spec/lib/smooth/resource_spec.rb
|
|
393
524
|
- spec/lib/smooth/serializer_spec.rb
|
|
525
|
+
- spec/lib/smooth/templating_spec.rb
|
|
526
|
+
- spec/lib/smooth/util_spec.rb
|
|
394
527
|
- spec/spec_helper.rb
|
|
528
|
+
has_rdoc:
|