From 6ae43acde6cd43c6383cd47e00f978ed339ea991 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 7 Oct 2012 15:06:16 +0200 Subject: added basic documentation --- DEVELOP.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 DEVELOP.md (limited to 'DEVELOP.md') diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 0000000..6a65285 --- /dev/null +++ b/DEVELOP.md @@ -0,0 +1,93 @@ +# Development # + + +## Engines ## + +Leap Web consists of different Engines. They live in their own subdirectory and are included through bundler via their path. This way changes to the engines immediately affect the server as if they were in the main '''app''' directory. + +Currently Leap Web consists of 4 Engines: + +* [core](https://github.com/leapcode/leap_web/blob/master/core) - ships some dependencies that are used accross all engines. This might be removed at some point. +* [users](https://github.com/leapcode/leap_web/blob/master/users) - user registration and authorization +* [certs](https://github.com/leapcode/leap_web/blob/master/certs) - Cert distribution for the EIP client +* [help](https://github.com/leapcode/leap_web/blob/master/help)- Help ticket management + +## Creating a new engine ## + +### Rails plugin new ### + +Create the basic tree structure for an engine using + +rails plugin new ENGINE_NAME -O --full + + +'''-O''' will skip active record and not add a dev dependency on sqlite. +'''-full''' will create a directory structure with config/routes and app and a basic engine file. + +See http://guides.rubyonrails.org/engines.html for more general info about engines. + +### Require Leap Web Core ### + +You need to add leap_web_core to your .gemspec: + + Gem::Specification.new do |s| + ... + s.add_dependency "rails" ... + s.add_dependency "leap_web_core", "~> 0.0.1" + end + + +You also need to require it before you define your engine in lib/my_engine/engine.rb: + +require "leap_web_core" + +module MyEngine + class Engine < ::Rails::Engine + ... + end +end + + +### Require UI Gems ### + +Leap Web Core provides a basic set of UI gems that should be used accross the engines. These include haml, sass, coffeescript, uglifier, bootstrap-sass, jquery and simple_form. + +Do you want to add views, javascript and the like to your engine? Then you should use the common gems. In order to do so you need to add them to your gemspec: + + + require "my_engine/version" + require "leap_web_core/dependencies" + + ... + + Gem::Specification.new do |s| + ... + s.add_dependency "rails" ... + s.add_dependency "leap_web_core", "~> 0.0.1" + + LeapWebCore::Dependencies.add_ui_gems_to_spec(s) + end + + +You also need to require them before you define your engine in lib/my_engine/engine.rb: + +require "leap_web_core" +LeapWebCore::Dependencies.require_ui_gems + +module MyEngine + class Engine < ::Rails::Engine + ... + end +end + + + +## Creating Models ## + +You can use the normal rails generators to create models. Since you required the leap_web_core gem you will be using CouchRest::Model. So your models inherit from CouchRest::Model::Base. +http://www.couchrest.info/model/definition.html has some good first steps for setting up the model. +CouchRest Model behaved strangely when using a model without a design block. So make sure to define an initial view: http://www.couchrest.info/model/view_objects.html . + +From that point on you should be able to use the standart persistance and querying methods such as create, find, destroy and so on. + + -- cgit v1.2.3 From c882d882a6506039bf0f2e4c3a673eb30ae9e58d Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 8 Oct 2012 09:18:35 +0200 Subject: minor: markdown improvements --- DEVELOP.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'DEVELOP.md') diff --git a/DEVELOP.md b/DEVELOP.md index 6a65285..a483fb7 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -1,52 +1,51 @@ -# Development # - +# Development # ## Engines ## -Leap Web consists of different Engines. They live in their own subdirectory and are included through bundler via their path. This way changes to the engines immediately affect the server as if they were in the main '''app''' directory. +Leap Web consists of different Engines. They live in their own subdirectory and are included through bundler via their path. This way changes to the engines immediately affect the server as if they were in the main `app` directory. Currently Leap Web consists of 4 Engines: * [core](https://github.com/leapcode/leap_web/blob/master/core) - ships some dependencies that are used accross all engines. This might be removed at some point. * [users](https://github.com/leapcode/leap_web/blob/master/users) - user registration and authorization * [certs](https://github.com/leapcode/leap_web/blob/master/certs) - Cert distribution for the EIP client -* [help](https://github.com/leapcode/leap_web/blob/master/help)- Help ticket management +* [help](https://github.com/leapcode/leap_web/blob/master/help) - Help ticket management ## Creating a new engine ## ### Rails plugin new ### Create the basic tree structure for an engine using - +``` rails plugin new ENGINE_NAME -O --full - +``` -'''-O''' will skip active record and not add a dev dependency on sqlite. -'''-full''' will create a directory structure with config/routes and app and a basic engine file. +`-O` will skip active record and not add a dev dependency on sqlite. +`-full` will create a directory structure with config/routes and app and a basic engine file. See http://guides.rubyonrails.org/engines.html for more general info about engines. ### Require Leap Web Core ### You need to add leap_web_core to your .gemspec: - +```ruby Gem::Specification.new do |s| - ... - s.add_dependency "rails" ... + # ... + s.add_dependency "rails" s.add_dependency "leap_web_core", "~> 0.0.1" end - +``` You also need to require it before you define your engine in lib/my_engine/engine.rb: - +```ruby require "leap_web_core" module MyEngine class Engine < ::Rails::Engine - ... + # ... end end - +``` ### Require UI Gems ### @@ -54,32 +53,33 @@ Leap Web Core provides a basic set of UI gems that should be used accross the en Do you want to add views, javascript and the like to your engine? Then you should use the common gems. In order to do so you need to add them to your gemspec: - +```ruby require "my_engine/version" require "leap_web_core/dependencies" - ... + # ... Gem::Specification.new do |s| - ... - s.add_dependency "rails" ... + # ... + s.add_dependency "rails" s.add_dependency "leap_web_core", "~> 0.0.1" LeapWebCore::Dependencies.add_ui_gems_to_spec(s) end - +``` You also need to require them before you define your engine in lib/my_engine/engine.rb: - + +```ruby require "leap_web_core" LeapWebCore::Dependencies.require_ui_gems module MyEngine class Engine < ::Rails::Engine - ... + # ... end end - +``` ## Creating Models ## -- cgit v1.2.3 From bd17dee3ae5650e8ff1c7700fa0e83adf386b91b Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 11 Oct 2012 10:43:57 +0200 Subject: tried to make the documentation more clear --- DEVELOP.md | 49 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'DEVELOP.md') diff --git a/DEVELOP.md b/DEVELOP.md index a483fb7..9548774 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -25,20 +25,28 @@ rails plugin new ENGINE_NAME -O --full See http://guides.rubyonrails.org/engines.html for more general info about engines. -### Require Leap Web Core ### +### Require Leap Web Core and dependencies ### -You need to add leap_web_core to your .gemspec: +Leap Web Core provides a common set of dependencies for the engines with CouchRest Model etc. +It also comes with an optional set of UI gems like haml, sass, coffeescript, uglifier, bootstrap-sass, jquery and simple_form. + +In order to use the core dependencies you need to add leap_web_core to your .gemspec: ```ruby +# make sure LeapWeb::VERSION is available +require File.expand_path('../../lib/leap_web/version.rb', __FILE__) +# ... Gem::Specification.new do |s| # ... s.add_dependency "rails" - s.add_dependency "leap_web_core", "~> 0.0.1" + s.add_dependency "leap_web_core", LeapWeb::Version end ``` You also need to require it before you define your engine in lib/my_engine/engine.rb: ```ruby require "leap_web_core" +# uncomment if you want the ui gems: +# require "leap_web_core/ui_dependencies" module MyEngine class Engine < ::Rails::Engine @@ -47,41 +55,14 @@ module MyEngine end ``` -### Require UI Gems ### - -Leap Web Core provides a basic set of UI gems that should be used accross the engines. These include haml, sass, coffeescript, uglifier, bootstrap-sass, jquery and simple_form. - -Do you want to add views, javascript and the like to your engine? Then you should use the common gems. In order to do so you need to add them to your gemspec: +Some development and UI dependencies can not be loaded via leap_web_core. To make them available add the following lines to your engines Gemfile ```ruby - require "my_engine/version" - require "leap_web_core/dependencies" - - # ... - - Gem::Specification.new do |s| - # ... - s.add_dependency "rails" - s.add_dependency "leap_web_core", "~> 0.0.1" - - LeapWebCore::Dependencies.add_ui_gems_to_spec(s) - end + eval(File.read(File.dirname(__FILE__) + '/../common_dependencies.rb')) + # uncomment if you want the ui gems: + # eval(File.read(File.dirname(__FILE__) + '/../ui_dependencies.rb')) ``` -You also need to require them before you define your engine in lib/my_engine/engine.rb: - -```ruby -require "leap_web_core" -LeapWebCore::Dependencies.require_ui_gems - -module MyEngine - class Engine < ::Rails::Engine - # ... - end -end -``` - - ## Creating Models ## You can use the normal rails generators to create models. Since you required the leap_web_core gem you will be using CouchRest::Model. So your models inherit from CouchRest::Model::Base. -- cgit v1.2.3