hobby 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cbd33582464fb0f4abb35050547d8aab1e8b55ca
4
- data.tar.gz: 25e21f5fdc989cdae29cac8bf6666ed9dcc04add
2
+ SHA256:
3
+ metadata.gz: 4ee5ec3efe7fcffdb34c286c5184bcd6be173c4c4566dfcd9a1b94f2f04c999b
4
+ data.tar.gz: 24a4f9f6d5ffb7749d5c361c9bdc401e42dc24d6ea17eefccc5802f3d151c21f
5
5
  SHA512:
6
- metadata.gz: cca58be4bf771c560092b6171b2882f68249bc9361ea3a4ef943f3003e6efdb415d0e850ef07412f29f098fa19c59ede7eaa7095d6c738b293fca47d20d6bdc9
7
- data.tar.gz: 6a56b251d310c6b42df0e0dc5142ec3a50ee2184375ac27230d801fd87ac370c45e2fc5093cdd960895d097365045d7d2946dfd2ac192fd851e3bcf3d75034fe
6
+ metadata.gz: 217cf5434c618bd03e3e9e5f7e202146b343e68fa03304fc034abeed46176ac6ef2fb67fa0ce8a51d1778d9571535c84714df6fb250b80f5fa8ab457e27359af
7
+ data.tar.gz: cf4fa9beaa6efd0193e102c48b59530f86664fbdf59421dc290fd16f809fe0d11dc8d7268eedf048bc8148cbce503c8433517c2717ab39b3381da0c3efeaee5d
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.5
4
5
  - 2.4
5
6
  - 2.3
6
7
  script: bundle exec rspec
@@ -4,10 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'hobby'
7
- spec.version = '0.1.1'
7
+ spec.version = '0.1.2'
8
8
  spec.authors = ['Anatoly Chernow']
9
9
  spec.email = ['chertoly@gmail.com']
10
- spec.summary = %q{A minimal DSL over rack}
10
+ spec.summary = %q{A professional way to create Rack applications.}
11
11
  spec.homepage = 'https://github.com/ch1c0t/hobby'
12
12
  spec.license = 'MIT'
13
13
 
@@ -42,5 +42,9 @@ module Hobby
42
42
  def status status
43
43
  response.status = status
44
44
  end
45
+
46
+ def script_name
47
+ env['SCRIPT_NAME']
48
+ end
45
49
  end
46
50
  end
@@ -40,9 +40,9 @@ require 'hobby'
40
40
  class C
41
41
  include Hobby
42
42
 
43
- get("/hello") {
43
+ get "/hello" do
44
44
  "Hello, world."
45
- }
45
+ end
46
46
  end
47
47
  ----
48
48
 
@@ -74,9 +74,9 @@ class C
74
74
  @name = name
75
75
  end
76
76
 
77
- get("/hello") {
77
+ get "/hello" do
78
78
  "Hello, #{@name}."
79
- }
79
+ end
80
80
  end
81
81
  ----
82
82
 
@@ -95,9 +95,9 @@ class C
95
95
  @name.upcase
96
96
  end
97
97
 
98
- get("/hello") {
98
+ get "/hello" do
99
99
  "Hello, #{name}."
100
- }
100
+ end
101
101
  end
102
102
  ----
103
103
 
@@ -133,29 +133,12 @@ For common HTTP verbs, Hobby provides the route definers(methods named according
133
133
  class App
134
134
  include Hobby
135
135
 
136
- get '/' do
137
- # ...
138
- end
139
-
140
- post '/' do
141
- # ...
142
- end
143
-
144
- put '/' do
145
- # ...
146
- end
147
-
148
- patch '/' do
149
- # ...
150
- end
151
-
152
- delete '/' do
153
- # ...
154
- end
155
-
156
- options '/' do
157
- # ...
158
- end
136
+ get { 'Some string.' }
137
+ post { 'Some string.' }
138
+ put { 'Some string.' }
139
+ patch { 'Some string.' }
140
+ delete { 'Some string.' }
141
+ # TODO: find a good example for `options`
159
142
  end
160
143
  ----
161
144
 
@@ -272,5 +272,15 @@ describe Hobby::App do
272
272
  assert { last_response.content_type == 'application/html' }
273
273
  end
274
274
  end
275
+
276
+ describe ScriptName do
277
+ it do
278
+ get '/'
279
+ assert { last_response.body == '' }
280
+
281
+ get '/some/path'
282
+ assert { last_response.body = '/mounted' }
283
+ end
284
+ end
275
285
  end
276
286
  end
@@ -0,0 +1,12 @@
1
+ get do
2
+ script_name
3
+ end
4
+
5
+ app = Class.new do
6
+ include Hobby
7
+ get do
8
+ script_name
9
+ end
10
+ end
11
+
12
+ map '/some/path', app.new
@@ -1,38 +1,12 @@
1
1
  require 'devtools/spec_helper'
2
2
 
3
3
  require 'hobby'
4
+ require_relative 'mutant_patches' if defined? Mutant
4
5
 
5
6
  require 'minitest'
6
7
  require 'minitest-power_assert'
7
8
  Minitest::Assertions.prepend Minitest::PowerAssert::Assertions
8
9
 
9
- if defined? Mutant
10
- class Mutant::Selector::Expression
11
- def call _subject
12
- integration.all_tests
13
- end
14
- end
15
-
16
- class Mutant::Isolation::Fork
17
- def result
18
- yield
19
- end
20
- end
21
-
22
- class Mutant::Loader
23
- def call
24
- source = Unparser.unparse node
25
-
26
- puts <<~S
27
- Current mutantion:
28
- #{source}
29
- S
30
-
31
- kernel.eval source, binding, subject.source_path.to_s, subject.source_line
32
- end
33
- end
34
- end
35
-
36
10
  module EnvFor
37
11
  def env_for path, verb = 'GET'
38
12
  {'REQUEST_METHOD' => verb, 'PATH_INFO' => path }
@@ -0,0 +1,27 @@
1
+ # Run all the specs for any subject.
2
+ class Mutant::Selector::Expression
3
+ def call _subject
4
+ integration.all_tests
5
+ end
6
+ end
7
+
8
+ # Do not silence stdout and stderr of the running mutation.
9
+ class Mutant::Isolation::Fork
10
+ def result
11
+ yield
12
+ end
13
+ end
14
+
15
+ # Print the source of the current mutation.
16
+ class Mutant::Loader
17
+ def call
18
+ source = Unparser.unparse node
19
+
20
+ puts <<~S
21
+ Current mutation:
22
+ #{source}
23
+ S
24
+
25
+ kernel.eval source, binding, subject.source_path.to_s, subject.source_line
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -53,6 +53,7 @@ files:
53
53
  - spec/apps/MapInsideInitialize.rb
54
54
  - spec/apps/Nested.rb
55
55
  - spec/apps/OneRouteRouter.rb
56
+ - spec/apps/ScriptName.rb
56
57
  - spec/apps/Status.rb
57
58
  - spec/apps/UnshareableRouterMaps.rb
58
59
  - spec/apps/UnshareableRouterUses.rb
@@ -60,6 +61,7 @@ files:
60
61
  - spec/apps/UseInsideInitialize.rb
61
62
  - spec/apps/WithoutPath.rb
62
63
  - spec/helper.rb
64
+ - spec/mutant_patches.rb
63
65
  - spec/router_matchers.rb
64
66
  - spec/router_spec.rb
65
67
  homepage: https://github.com/ch1c0t/hobby
@@ -82,10 +84,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  version: '0'
83
85
  requirements: []
84
86
  rubyforge_project:
85
- rubygems_version: 2.6.13
87
+ rubygems_version: 2.7.6
86
88
  signing_key:
87
89
  specification_version: 4
88
- summary: A minimal DSL over rack
90
+ summary: A professional way to create Rack applications.
89
91
  test_files:
90
92
  - spec/app_spec.rb
91
93
  - spec/apps/ContentType.rb
@@ -97,6 +99,7 @@ test_files:
97
99
  - spec/apps/MapInsideInitialize.rb
98
100
  - spec/apps/Nested.rb
99
101
  - spec/apps/OneRouteRouter.rb
102
+ - spec/apps/ScriptName.rb
100
103
  - spec/apps/Status.rb
101
104
  - spec/apps/UnshareableRouterMaps.rb
102
105
  - spec/apps/UnshareableRouterUses.rb
@@ -104,5 +107,6 @@ test_files:
104
107
  - spec/apps/UseInsideInitialize.rb
105
108
  - spec/apps/WithoutPath.rb
106
109
  - spec/helper.rb
110
+ - spec/mutant_patches.rb
107
111
  - spec/router_matchers.rb
108
112
  - spec/router_spec.rb