Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iboard/rappgem
A ruby base application architecture (a conceptional example)
https://github.com/iboard/rappgem
Last synced: 16 days ago
JSON representation
A ruby base application architecture (a conceptional example)
- Host: GitHub
- URL: https://github.com/iboard/rappgem
- Owner: iboard
- License: mit
- Created: 2014-05-11T13:46:19.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-17T09:13:08.000Z (over 10 years ago)
- Last Synced: 2024-12-12T10:48:47.735Z (22 days ago)
- Language: Ruby
- Size: 352 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rappgem – Ruby Application Gem
The gem gives you a clean application-structure for any ruby
application. You may use it for a gem, a command-line-app, a
sinatra-app, and even for your rails-app.## Installation
Add this line to your application's Gemfile:
gem 'rappgem'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rappgem
## Usage
### Examples
#### Simple
class MyApp < BaseApplication
def run *_opts
puts "Hello World" if has_arg?("-v")
end
endapp = ApplicationFactory.app( MyApp.intance, "-v" )
app.run #=> "Hello World"#### Complete with individual Usecase
# implementing your own usecases
class MyUsecase < Usecase
def response
# do something with @request
Response.new(message:"...build your response...")
end
end# instantiate the application
app = ApplicationFactory.app( BaseApplication.instance )# build the request
request = app.build_request( self, :command_name, params)# and handle the request with your usecase
response = app.handle_request( req ) do
MyUsecase.new( req )
endresponse.message # => "...build your response..."
See `spec/app/application_factory_spec.rb` and any other spec-file for
details.## Sinatra Example
There is an example of a basic Sinatra-applicaton using Rappgem.
You can run the test-suite of this app byrake sinatra
To run the application
cd examples/sinatra
ruby app.rbVisit "http://0.0.0.0:4567" while the app is running.
Press Ctrl+C to stop the server-app.## TODO
This gem has not been finished yet. Next steps are:
* Implement a command-queue for BaseApplication and TerminalApplication
* Implement a Terminal-Example
* Implement a RAILS-Example### Use Terminal Application with _irb_
$ irb -Ilib
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
irb(main):001:0> require "rappgem"
true
irb(main):002:0> include Rappgem
Object
irb(main):003:0> app = ApplicationFactory.app( TerminalApplication.instance )
#
irb(main):004:0> app.run
>ping pong
pong
>date
2014-05-13 21:56:48 +0200
>quit
Rappgem::Application::TerminalApplication::<2160395960> Args: []
nil### Draft how a TerminalApplication could work
![Image 1: Terminal Application - Draft](http://dav.iboard.cc/container/rappgem/Img001-terminal-application.jpg)
### The idea behind
[Jim Weirich Talk](http://www.youtube.com/embed/tg5RFeSfBM4)
## Development
### rake – TDD
run `rake` to run all tests. The output of the tests will give
you a glue what `Rappgem` is doing.### YARD – documentation
run `yard && open doc/index.html` to generate and open the documentation
in your browser.## Contributing
1. Fork it ( https://github.com/[my-github-username]/rappgem/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request