alno-app_generators 0.0.1

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Alexey Noskov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = app_generators
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Alexey Noskov. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "app_generators"
8
+ gem.summary = "Different subsystem generators for Ruby on Rails applications"
9
+ gem.description = "Different subsystem generators for Ruby on Rails applications"
10
+ gem.email = "alexey.noskov@gmail.com"
11
+ gem.homepage = "http://github.com/alno/app_generators"
12
+ gem.authors = ["Alexey Noskov"]
13
+ gem.add_development_dependency "rspec"
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
+ end
30
+
31
+ task :spec => :check_dependencies
32
+
33
+ task :default => :spec
34
+
35
+ require 'rake/rdoctask'
36
+ Rake::RDocTask.new do |rdoc|
37
+ if File.exist?('VERSION')
38
+ version = File.read('VERSION')
39
+ else
40
+ version = ""
41
+ end
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "app_generators #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,54 @@
1
+ class AppAccountsGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+
6
+ # Controllers
7
+ m.file 'controllers/accounts_controller.rb', 'app/controllers/accounts_controller.rb'
8
+ m.file 'controllers/sessions_controller.rb', 'app/controllers/sessions_controller.rb'
9
+
10
+ # Views
11
+ m.file 'views/sessions/new.html.haml', 'app/views/sessions/new.html.haml'
12
+
13
+ m.file 'views/accounts/new.html.haml', 'app/views/accounts/new.html.haml'
14
+ m.file 'views/accounts/show.html.haml', 'app/views/accounts/show.html.haml'
15
+ m.file 'views/accounts/edit.html.haml', 'app/views/accounts/edit.html.haml'
16
+
17
+ # Routes
18
+ m.gsub_file 'config/routes.rb', /#{Regexp.quote 'ActionController::Routing::Routes.draw do |map|'}/mi do |match|
19
+ <<-END.gsub(/^ {8}/, '')
20
+ #{match}
21
+
22
+ map.resource :session
23
+ map.resource :account
24
+
25
+ END
26
+ end
27
+
28
+ # Features
29
+ m.file 'features/accounts.feature', 'features/accounts.feature'
30
+
31
+ m.file 'features/step_definitions/accounts_steps.rb', 'features/step_definitions/accounts_steps.rb'
32
+
33
+ m.gsub_file 'features/support/paths.rb', /#{Regexp.quote 'case page_name'}/mi do |match|
34
+ <<-END.gsub(/^ {8}/, '')
35
+ #{match}
36
+
37
+ when /the homepage/
38
+ '/'
39
+ when /the login page/
40
+ '/login'
41
+ when /the account page/
42
+ '/account'
43
+ when /the edit account page/
44
+ '/account/edit'
45
+ END
46
+ end
47
+
48
+ # Locales
49
+ m.file 'locales/ru.accounts.yml', 'config/locales/ru.accounts.yml'
50
+
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,38 @@
1
+ class AccountsController < ApplicationController
2
+
3
+ #before_filter :require_no_user, :only => [:new, :create]
4
+ #before_filter :require_user, :only => [:show, :edit, :update]
5
+
6
+ def new
7
+ @user = User.new
8
+ end
9
+
10
+ def create
11
+ @user = User.new(params[:account])
12
+ if captcha_valid( @user ) && @user.save
13
+ flash[:notice] = "Registration successful."
14
+ redirect_back_or_default root_url
15
+ else
16
+ render :action => 'new'
17
+ end
18
+ end
19
+
20
+ def edit
21
+ @user = current_user
22
+ end
23
+
24
+ def update
25
+ @user = current_user
26
+ if @user.update_attributes(params[:account])
27
+ flash[:notice] = "Successlfuly updated user."
28
+ redirect_to users_url
29
+ else
30
+ render :action => 'edit'
31
+ end
32
+ end
33
+
34
+ def show
35
+ @user = current_user
36
+ end
37
+
38
+ end
@@ -0,0 +1,30 @@
1
+ class SessionsController < ApplicationController
2
+
3
+ before_filter :require_no_user, :only => [:new, :create]
4
+ before_filter :require_user, :only => :destroy
5
+
6
+ def new
7
+ @user_session = UserSession.new
8
+ @user = User.new
9
+ end
10
+
11
+ def create
12
+ @user_session = UserSession.new(params[:session])
13
+ if @user_session.save
14
+ flash[:notice] = I18n.t 'notices.session.created'
15
+ redirect_back_or_default root_url
16
+ else
17
+ render :action => 'new'
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ @user_session = UserSession.find
23
+ @user_session.destroy
24
+
25
+ flash[:notice] = I18n.t 'notices.session.destroyed'
26
+
27
+ redirect_back_or_default root_url
28
+ end
29
+
30
+ end
@@ -0,0 +1,43 @@
1
+ Feature: Account
2
+
3
+ Scenario: Login
4
+ Given I am registered in as "tester" with "mypass"
5
+
6
+ When I go to the login page
7
+ And I fill in "session[login]" with "tester"
8
+ And I fill in "session[password]" with "mypass"
9
+ And I press "Войти"
10
+
11
+ Then I should see "Вы успешно вошли"
12
+
13
+ Scenario: Logout
14
+ Given I am logged in as "tester"
15
+
16
+ When I go to the homepage
17
+ Then I should see "Выйти"
18
+ And I should not see "Войти"
19
+
20
+ When I follow "Выйти"
21
+ Then I should see "Войти"
22
+ And I should not see "Выйти"
23
+
24
+ Scenario: Registration
25
+ Given I am on the homepage
26
+
27
+ When I follow "Зарегистрироваться"
28
+ And I fill in "account[login]" with "testuser"
29
+ And I fill in "account[password]" with "mypass"
30
+ And I fill in "account[password_confirmation]" with "mypass"
31
+ And I press "Зарегистрироваться"
32
+
33
+ Then I should be able to login as "testuser" with "mypass"
34
+
35
+ Scenario: Edit account
36
+ Given I am logged in as "tester" with "mypass"
37
+
38
+ When I go to the account page
39
+ Then I should see "Редактировать аккаунт"
40
+
41
+ When I follow "Редактировать аккаунт"
42
+ Then I should be on the edit account page
43
+ And I should see "Редактирование аккаунта"
@@ -0,0 +1,45 @@
1
+
2
+ Given /^I am logged in as "([^\"]*)"$/ do |login|
3
+ @current_user = User.create!(
4
+ :login => login,
5
+ :password => 'generic',
6
+ :password_confirmation => 'generic'
7
+ )
8
+
9
+ visit '/login'
10
+ fill_in("session[login]", :with => @current_user.login)
11
+ fill_in("session[password]", :with => @current_user.password)
12
+ click_button("Войти")
13
+ end
14
+
15
+ Given /^I am logged in as "([^\"]*)" with "([^\"]*)"$/ do |login,password|
16
+ @current_user = User.create!(
17
+ :login => login,
18
+ :password => password,
19
+ :password_confirmation => password
20
+ )
21
+
22
+ visit '/login'
23
+ fill_in("session[login]", :with => @current_user.login)
24
+ fill_in("session[password]", :with => @current_user.password)
25
+ click_button("Войти")
26
+ end
27
+
28
+ Given /^I am registered in as "([^\"]*)" with "([^\"]*)"$/ do |login,password|
29
+ @current_user = User.create!(
30
+ :login => login,
31
+ :password => password,
32
+ :password_confirmation => password
33
+ )
34
+ end
35
+
36
+ Then /^I should be able to login as "([^\"]*)" with "([^\"]*)"$/ do |login, password|
37
+ visit '/logout'
38
+ visit '/login'
39
+ fill_in("session[login]", :with => login)
40
+ fill_in("session[password]", :with => password)
41
+ click_button("Войти")
42
+
43
+ response.body.should =~ /вошли/m
44
+ end
45
+
@@ -0,0 +1,37 @@
1
+ ru:
2
+
3
+ notices:
4
+ session:
5
+ created: Вы успешно вошли в сервис.
6
+ destroyed: Вы успешно вышли из сервиса.
7
+
8
+ titles:
9
+ session:
10
+ new: Вход в сервис
11
+ account:
12
+ new: Регистрация нового пользователя
13
+ show: Ваш аккаунт
14
+ edit: Редактирование аккаунта
15
+
16
+ actions:
17
+ session:
18
+ new: Войти
19
+ create: Войти
20
+ account:
21
+ new: Зарегистрироваться
22
+ create: Зарегистрироваться
23
+ show: Перейти к аккаунту
24
+ edit: Редактировать аккаунт
25
+
26
+ activerecord:
27
+ attributes:
28
+ account:
29
+ login: Логин
30
+ password: Пароль
31
+ password_confirmation: Повторите пароль
32
+ captcha: Докажите, что вы не робот
33
+ session:
34
+ login: Логин
35
+ password: Пароль
36
+ remember_me: Запомнить меня
37
+
@@ -0,0 +1,4 @@
1
+ %p
2
+ = link_to "Show", @user
3
+ |
4
+ = link_to "View All", users_path
@@ -0,0 +1,11 @@
1
+ - labelling_form_for :account, @user, :url => account_path do |f|
2
+ = f.error_messages
3
+
4
+ = f.text_field :login
5
+ = f.password_field :password
6
+ = f.password_field :password_confirmation
7
+
8
+ = f.smart_label :captcha
9
+ = recaptcha_tags
10
+
11
+ = f.submit_create
@@ -0,0 +1 @@
1
+ = link_to t( 'actions.account.edit' ), edit_account_path
@@ -0,0 +1,6 @@
1
+ - labelling_form_for :session, @user_session, :url => session_path do |f|
2
+ = f.text_field :login
3
+ = f.password_field :password
4
+ = f.check_box :remember_me
5
+
6
+ = f.submit_create
File without changes
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "AppGenerators" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'app_generators'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alno-app_generators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexey Noskov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-12 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Different subsystem generators for Ruby on Rails applications
26
+ email: alexey.noskov@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - generators/app_accounts/app_accounts_generator.rb
42
+ - generators/app_accounts/templates/controllers/accounts_controller.rb
43
+ - generators/app_accounts/templates/controllers/sessions_controller.rb
44
+ - generators/app_accounts/templates/features/accounts.feature
45
+ - generators/app_accounts/templates/features/step_definitions/accounts_steps.rb
46
+ - generators/app_accounts/templates/locales/ru.accounts.yml
47
+ - generators/app_accounts/templates/views/accounts/edit.html.haml
48
+ - generators/app_accounts/templates/views/accounts/new.html.haml
49
+ - generators/app_accounts/templates/views/accounts/show.html.haml
50
+ - generators/app_accounts/templates/views/sessions/new.html.haml
51
+ - lib/app_generators.rb
52
+ - spec/app_generators_spec.rb
53
+ - spec/spec_helper.rb
54
+ has_rdoc: false
55
+ homepage: http://github.com/alno/app_generators
56
+ licenses:
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.5
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Different subsystem generators for Ruby on Rails applications
81
+ test_files:
82
+ - spec/spec_helper.rb
83
+ - spec/app_generators_spec.rb