atd 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b56849012d758725dd43a64adb95b444ccc1463
4
- data.tar.gz: 191e644b14b1e580d287fdf9bbf3f57ff575ed2d
3
+ metadata.gz: 58bc7fc139c91e5ac91f51cf29e1c8638484bef7
4
+ data.tar.gz: a2956310bdbe71f6abb96cc840fad813815e0d5a
5
5
  SHA512:
6
- metadata.gz: 88469bdf52fa8fdcab4991a76237ee5e60423140c22b59e633cfdced92d670e8c1a986ef6fb77b9a41a8d219e414431725e20ad2c4ba021687ed7c80cd508620
7
- data.tar.gz: ddd182383a818a671fcf998ae14d2f0f6d0b4db9021f52037798e416a6fd22be8273b5f27c581675d611b5dd785bc687fe6c8d016344b7b537b037a06fbbee51
6
+ metadata.gz: dce06c37ffcd1b2265052fc3b8149003f7a9e8e05e478f6e8a887496b34a3d0877d90c37040db783f226b3e3c28edd8b341b256e6022d188fbd173193588df17
7
+ data.tar.gz: d92f10cdc008a8f848178f36be680831786f738dfa759325d39bb24b4b7603cb5a64a5fb5072c2194304731cc3dddb132171c57cd925571f2e0c9482c8d48a84
data/.gitignore CHANGED
@@ -2,14 +2,12 @@
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
- /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
10
9
  .DS_Store
11
10
  /.idea/
12
- /doc/
13
- /.yardoc/
14
11
  coverage
15
- /*.gem
12
+ /*.gem
13
+ /updated_README.md
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.3.2:
2
+ - Really began using Gitlab issues
3
+ - Synchronized development branch with master
4
+ - Dealt with edge cases in route creation
5
+
1
6
  v0.3.1:
2
7
  - Skipped bugfix version because v0.3.0 was yanked.
3
8
  - Added controller structure
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![build status][build status badge]][build status link] [![coverage report][coverage report badge]][coverage report link] [![gem version][gem version badge]][gem version link] [![documentation coverage][documentation coverage badge]][documentation coverage link]
2
2
 
3
- [documentation coverage badge]: https://img.shields.io/badge/YARD%20coverage-93.02%-green.svg?style=flat-square
3
+ [documentation coverage badge]: https://img.shields.io/badge/YARD%20coverage-93.18%-green.svg?style=flat-square
4
4
  [documentation coverage link]: http://izwick-schachter.gitlab.io/atd/YARD/coverage
5
5
 
6
6
  [build status badge]: https://gitlab.com/izwick-schachter/atd/badges/master/build.svg?style=flat-square
@@ -19,21 +19,24 @@
19
19
  - [Setup](#setup)
20
20
  - [Routing](#routing)
21
21
  - [Basic Routing](#basic-routing)
22
+ - [Serving Files](#serving-files)
22
23
  - [Advanced Routing](#advanced-routing)
23
24
  - [DefaultApp](#defaultapp)
24
25
  - [Inheritance](#inheritance)
26
+ - [Blocks](#blocks)
25
27
  - [@http](#http)
28
+ - [Controllers](#controllers)
26
29
  - [Apps](#apps)
27
30
  - [App Creation](#app-creation)
28
31
  - [Starting the App](#starting-the-app)
29
32
  - [App Routing](#app-routing)
30
33
  - [Logging](#logging)
31
34
  - [Compilation](#compilation)
35
+ - [Design Paradigms](#design-paradigms)
32
36
  - [Documentation](#documentation)
33
37
  - [Development](#development)
34
38
  - [Contributing](#contributing)
35
39
 
36
-
37
40
  # ATD
38
41
 
39
42
  ATD is a new web development backend framework for Ruby. It is built on top of rack, and is meant to be small easy and light. That is why it provides a very minimalist way of writing your backend. It treats a request as a request, without splitting it based on the HTTP method.
@@ -64,9 +67,7 @@ Or install it from the repository with:
64
67
 
65
68
  This will also allow you to use the current development version (USE WITH CAUTION), and to use that you can `git checkout development` and then `bundle exec rake install`.
66
69
 
67
- ## Usage
68
-
69
- ### Setup
70
+ ## Setup
70
71
 
71
72
  Setup is as easy as `require "atd"` at the top of whatever file you need it in
72
73
 
@@ -124,11 +125,21 @@ Or, a simpler way would be with `:ignore`:
124
125
  request "/", "Hello World", ignore: :delete
125
126
  ```
126
127
 
128
+ #### Serving Files
129
+
130
+ All files that you want to serve must be in the `assets` directory if they are, then it is simple to just create a route, and put the filename as the output. For example this will serve `assets/index.html`:
131
+
132
+ ```ruby
133
+ request "/", "index.html"
134
+ ```
135
+
136
+ There are certain modifications which can be made to files between the route being requested and the files being served. That information can be found in the [compilation section](#compilation).
137
+
127
138
  ### Advanced Routing
128
139
 
129
140
  #### DefaultApp
130
141
 
131
- `DefaultApp` is just another app which extends `ATD::App`, it is the app which doesn't have to be written to in `class DefaultApp`, any routes that are created in `main` will be added to `DefaultApp`, well... by default!
142
+ `DefaultApp` is just another app which extends `ATD::App`, it is the app which doesn't have to be written to in `class DefaultApp`, any routes that are created in `main` will be added to `DefaultApp`, well... by default! To find out more about Apps, you can go to the [Apps section](#apps).
132
143
 
133
144
  #### Inheritance
134
145
 
@@ -197,6 +208,20 @@ The `@http` instance variable can be used to work with the http request the the
197
208
 
198
209
  While you can use `@http[:status_code]` to change the status code, you can also set a status code with `r "/", status_code: 200`. That status code must be >= 100, as per the Rack Specification.
199
210
 
211
+ #### Controllers
212
+
213
+ ATD also had the capabilities to use controllers. A controller is an object which responds to controller methods, usually a module with `extend self`. Here is an example of an app using controllers:
214
+
215
+ ```ruby
216
+ module MyController
217
+ def test_route
218
+ return "You've reached test_route"
219
+ end
220
+ end
221
+
222
+ request "/", "MyController#test_route" #=> "You've reached test_route"
223
+ ```
224
+
200
225
  ### Apps
201
226
 
202
227
  ATD also allows you to use different "apps". Each app is independent of the others and lives is a class with the same name as the app. A file can have any number of apps, each of which can have it's own settings, files, and routes. By default, adding routes to `main` will make them a part of the app `DefaultApp`, which will work fine if you only need one app.
@@ -268,6 +293,10 @@ end
268
293
 
269
294
  The compilation works by going through the file extensions from last to first and running the compilations for each extension in that order. For example `file.html.erb` will first be compiled by the ERB compiler, then the output of the ERB compiler will be compiled by the HTML compiler.
270
295
 
296
+ ## Design Paradigms
297
+
298
+ ATD is designed to fit into many different design paradigms, and to allow each person to adopt their own styles while leaving code readable to everyone. Do do this, the code was left fairly unstructured, but [here are a few examples from well known frameworks](https://gitlab.com/izwick-schachter/atd-examples.git).
299
+
271
300
  ## Documentation
272
301
 
273
302
  You can find the YARD docs at http://izwick-schachter.gitlab.io/atd/YARD/.
data/lib/atd.rb CHANGED
@@ -24,9 +24,8 @@ module ATD
24
24
 
25
25
  # The first two arguments must me the path and the output.
26
26
  def initialize(*args, &block)
27
- args -= [nil]
28
- args.reject! { |arg| arg.is_a?(File) ? false : arg.empty? } # File doesn't respond to empty
29
- @method = (args.last.is_a?(Hash) && !args.last[:methods].nil? ? args.last[:methods] : [:get, :post, :put, :patch, :delete])
27
+ @method = [:get, :post, :put, :patch, :delete]
28
+ @method = [] if args.last.is_a?(Hash) && !(args.last[:respond_to].nil? || args.last[:ignore].nil?)
30
29
  @app = :DefaultApp
31
30
  parse_args(*args, &block)
32
31
  end
@@ -69,7 +68,6 @@ module ATD
69
68
  define_method(method) do |*args, &block|
70
69
  @method = [method] if @method.length == 5
71
70
  @method += [method]
72
- @method += args.last[:respond_to] if args.last.is_a?(Hash) && !args.last[:respond_to].nil?
73
71
  @method.uniq!
74
72
  parse_args(*args, &block)
75
73
  end
@@ -95,15 +93,19 @@ module ATD
95
93
 
96
94
  # This should also manage @message at some point
97
95
  def parse_args(*args, &block)
96
+ args.compact!
97
+ args.flatten!
98
+ args.reject! { |arg| arg.is_a?(File) ? false : arg.empty? } # File doesn't respond to empty
98
99
  @block = block
99
- @path = args.shift if @path.nil?
100
- @output = args.shift if @output.nil?
101
- @args = Array(@args).concat(args) - [nil] unless args.nil?
100
+ @path ||= args.shift
101
+ @output ||= args.shift
102
+ @args = Array(@args).concat(args) unless args.nil?
102
103
  if @output =~ /^\w*#\w*$/ # Check if @path is a controller#action combo
103
104
  controller, action = @output.split("#")
104
105
  @action = Object.const_get(controller.to_sym).method(action.to_sym)
105
106
  @output = @action.call
106
107
  end
108
+ @method += Array(args.last[:respond_to]) if args.last.is_a?(Hash) && !args.last[:respond_to].nil?
107
109
  @method -= Array(args.last[:ignore]) if args.last.is_a?(Hash) && !args.last[:ignore].nil?
108
110
  self
109
111
  end
data/lib/atd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ATD
2
- VERSION = "0.3.1".freeze # The current version number of {ATD}.
2
+ VERSION = "0.3.2".freeze # The current version number of {ATD}.
3
3
  end
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACecretMaster
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: webrick
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '5.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest-reporters
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.9'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.9'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack-test
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0.6'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.6'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0.12'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.12'
153
153
  description:
@@ -157,9 +157,9 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - .gitignore
161
- - .gitlab-ci.yml
162
- - .rubocop.yml
160
+ - ".gitignore"
161
+ - ".gitlab-ci.yml"
162
+ - ".rubocop.yml"
163
163
  - CHANGELOG
164
164
  - CODE_OF_CONDUCT.md
165
165
  - Gemfile
@@ -185,17 +185,17 @@ require_paths:
185
185
  - lib
186
186
  required_ruby_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
- - - '>='
188
+ - - ">="
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - '>='
193
+ - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.0.14.1
198
+ rubygems_version: 2.5.1
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: The assistant technical director of your website. It does the dirty work