agilib 0.1.2.beta1 → 0.1.2.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/app/.DS_Store +0 -0
  4. data/app/controllers/agilib/devices_controller.rb +5 -1
  5. data/app/controllers/agilib/tokens_controller.rb +10 -4
  6. data/app/controllers/agilib/welcome_controller.rb +14 -0
  7. data/app/views/agilib/devices/_form.html.erb +22 -0
  8. data/app/views/agilib/devices/edit.html.erb +6 -0
  9. data/app/views/agilib/devices/index.html.erb +0 -0
  10. data/app/views/agilib/devices/new.html.erb +5 -0
  11. data/app/views/agilib/devices/show.html.erb +25 -0
  12. data/app/views/agilib/welcome/index.html +42 -0
  13. data/app/views/agilib/welcome/index.html.erb +47 -0
  14. data/lib/.DS_Store +0 -0
  15. data/lib/agilib/composer/command.rb +8 -3
  16. data/lib/agilib/composer/composer.rb +8 -0
  17. data/lib/agilib/composer/templater.rb +7 -30
  18. data/lib/agilib/composer/templates/recipes/better_errors.rb +8 -0
  19. data/lib/agilib/composer/templates/recipes/cancan.rb +6 -0
  20. data/lib/agilib/composer/templates/recipes/default.rb +6 -0
  21. data/lib/agilib/composer/templates/recipes/devise.rb +35 -0
  22. data/lib/agilib/composer/templates/recipes/gems.rb +7 -1
  23. data/lib/agilib/composer/templates/recipes/push.rb +46 -0
  24. data/lib/agilib/composer/templates/recipes/responders.rb +6 -0
  25. data/lib/agilib/composer/templates/recipes/rspec.rb +125 -0
  26. data/lib/agilib/composer/templates/recipes/simple_form.rb +6 -0
  27. data/lib/agilib/composer/templates/recipes/token.rb +5 -6
  28. data/lib/agilib/composer/templates/runner.rb +3 -2
  29. data/lib/agilib/composer/templates/snippets/rspec/user_model_spec.rb +103 -0
  30. data/lib/agilib/push_notification/push_notification.rb +0 -1
  31. data/lib/agilib/routing.rb +39 -0
  32. data/lib/agilib/token_authenticatable/token_authentication.rb +0 -1
  33. data/lib/agilib/version.rb +1 -1
  34. data/lib/agilib.rb +1 -0
  35. data/lib/generators/agilib/install/install_generator.rb +4 -0
  36. data/lib/generators/agilib/install/templates/config/initializers/agilib.rb +0 -53
  37. data/lib/generators/agilib/push/push_generator.rb +3 -1
  38. data/lib/generators/agilib/token/token_generator.rb +4 -1
  39. data/spec/agilib-rails_spec.rb +3 -2
  40. metadata +18 -4
  41. data/lib/agilib/push_notification/routing.rb +0 -15
  42. data/lib/agilib/token_authenticatable/routing.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33797d428f00b886350c5b81942a6674f7eb2f2f
4
- data.tar.gz: 00e9d128a61d62d1b31ab9f7c96ce4d698d1b389
3
+ metadata.gz: 453f80e7bcf6135ec21713190c439c6fbafe010e
4
+ data.tar.gz: 3d6e0e5c0cdc63fe3b4078733f202e7bc23d9e58
5
5
  SHA512:
6
- metadata.gz: 9d62fb42c351a935e8b285b19738beb65ac96b470c502b621505b11be920a0c00957f26afba3566ecdc96020667eb351ed569ec9a87f3bf0e99089a4ac047461
7
- data.tar.gz: aed7f18663a4d0a422c56d6c06ebafebee0ef47a51ae08b91a2ba31ae05ec6ca3655c826944cde3f730603cdf56775895477d94d8db9ebcd8f97ef98bf073c09
6
+ metadata.gz: d38ac3f38cbdaf2bfc6b0fc3142bb7d9c64356b6aa256aa55a91d5c180a46b4e51297f5dfb4c9521b0431935d80b3ae19c73f891b398c7e35bc26b1df28a64a9
7
+ data.tar.gz: 2addc32eb908cd682a0233faa2e24c928d48b30fdb59eca060de6f7cb5549c5fcf13da9d6fc0fef49826b56cd7d0f07a01c6448307614b8ebd7e7f36e9ee55a2
data/.DS_Store CHANGED
Binary file
data/app/.DS_Store CHANGED
Binary file
@@ -1,6 +1,10 @@
1
1
  module Agilib
2
2
  class DevicesController < ApplicationController
3
- before_filter :get_devices
3
+ if Agilib.rails4?
4
+ before_action :get_devices
5
+ else
6
+ before_filter :get_devices
7
+ end
4
8
 
5
9
  def index
6
10
  @devices = @get_devices.all
@@ -1,6 +1,11 @@
1
1
  module Agilib
2
2
  class TokensController < Devise::SessionsController
3
- skip_before_filter :verify_authenticity_token
3
+ if Agilib.rails4?
4
+ skip_before_action :verify_authenticity_token
5
+ else
6
+ skip_before_filter :verify_authenticity_token
7
+ end
8
+
4
9
  respond_to :json
5
10
 
6
11
  def create
@@ -40,11 +45,12 @@ module Agilib
40
45
  end
41
46
 
42
47
  def destroy
48
+ token = params[Agilib::TokenAuthenticatable.auth_params[:user_token]]
43
49
 
44
50
  if User.respond_to? "find_by"
45
- @user = User.find_by(authentication_token: login.downcase)
51
+ @user = User.find_by(authentication_token: token)
46
52
  elsif User.respond_to? "find_by_authentication_token"
47
- @user = User.find_by_authentication_token(login.downcase)
53
+ @user = User.find_by_authentication_token(token)
48
54
  end
49
55
 
50
56
  if @user.nil?
@@ -55,7 +61,7 @@ module Agilib
55
61
 
56
62
  sign_out @user
57
63
 
58
- render :status => 200, :json=>{:user=> @user, :token=>params[:id]}
64
+ render :status => 200, :json=>{:user=> @user, :token=>params[:token]}
59
65
 
60
66
  end
61
67
  end
@@ -0,0 +1,14 @@
1
+ module Agilib
2
+ class WelcomeController < ApplicationController
3
+
4
+ if Agilib.rails4?
5
+ skip_before_action :authenticate_user!
6
+ else
7
+ skip_before_filter :authenticate_user!
8
+ end
9
+
10
+ def index
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ <ul class="nav nav-tabs clear-nav-tab steps">
2
+ <li class="active"><a href="#coreData"><aside>Dados Principais</aside></a></li>
3
+ </ul>
4
+
5
+ <%= simple_form_for @device, :remote => true, :validate => false, :html => { :id => 'form_devices', :class => 'form-horizontal', 'data-type'=>'json' } do |f| %>
6
+ <div id="tab-content-device" class="tab-content">
7
+
8
+ <!-- TAB DADOS PRINCIPAIS -->
9
+ <div class="tab-pane active" id="coreData">
10
+ <%= f.association :user %>
11
+ <%= f.input :platform %>
12
+ <%= f.input :register %>
13
+ <%= f.input :deleted_at %>
14
+ </div>
15
+
16
+ </div>
17
+
18
+ </div>
19
+ <div class="modal-footer">
20
+ <%= f.button :submit, :class => 'btn btn-primary' %>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing device</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @device %> |
6
+ <%= link_to 'Back', devices_path %>
File without changes
@@ -0,0 +1,5 @@
1
+ <h1>New device</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', devices_path %>
@@ -0,0 +1,25 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>User:</b>
5
+ <%= @device.user %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Platform:</b>
10
+ <%= @device.platform %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Register:</b>
15
+ <%= @device.register %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Deleted at:</b>
20
+ <%= @device.deleted_at %>
21
+ </p>
22
+
23
+
24
+ <%= link_to 'Edit', edit_device_path(@device) %> |
25
+ <%= link_to 'Back', devices_path %>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>Agilib</title>
7
+
8
+ <style>
9
+ body {
10
+ background-color: #ffffff
11
+ }
12
+
13
+ #logo {
14
+ position: absolute;
15
+ width: 161px;
16
+ height: 64px;
17
+ left: 50%;
18
+ top: 30%;
19
+ margin-left: -80.5px;
20
+ margin-top: 32px;
21
+ }
22
+
23
+ .content {
24
+ font-family: helvetica;
25
+ position: absolute;
26
+ width: 161px;
27
+ height: 64px;
28
+ left: 50%;
29
+ top: 39%;
30
+ margin-left: -80.5px;
31
+ margin-top: 32px;
32
+ text-align: center;
33
+ color: #0085a6;
34
+ font-size: 10px;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <img id="logo" src="http://agivis.com.br/assets/logo_agivis-af5e30b64fe8cc778c0b0010b613e88c.jpg" alt="Agivis">
40
+ <div class="content"><span><strong>agilib-rails v1.1.1</strong></span></div>
41
+ </body>
42
+ </html>
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>Agilib</title>
7
+
8
+ <style>
9
+ body {
10
+ background-color: #ffffff
11
+ }
12
+
13
+ #logo {
14
+ position: absolute;
15
+ width: 161px;
16
+ height: 64px;
17
+ left: 50%;
18
+ top: 30%;
19
+ margin-left: -80.5px;
20
+ margin-top: 32px;
21
+ }
22
+
23
+ .content {
24
+ font-family: helvetica;
25
+ position: absolute;
26
+ width: 161px;
27
+ height: 64px;
28
+ left: 50%;
29
+ top: 39%;
30
+ margin-left: -80.5px;
31
+ margin-top: 32px;
32
+ text-align: center;
33
+ color: #0085a6;
34
+ font-size: 10px;
35
+ }
36
+
37
+ .logout{
38
+ color: red;
39
+ }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <img id="logo" src="http://agivis.com.br/assets/logo_agivis-af5e30b64fe8cc778c0b0010b613e88c.jpg" alt="Agivis">
44
+ <div class="content"><span><strong>agilib-rails v<%= Agilib::Version::STRING %></strong></span><% if current_user %>
45
+ <br/>Logado como: <%= current_user.name %> (<%= link_to "sair", destroy_user_session_path, :method => :delete, :class => "logout" %>)<% end %></div>
46
+ </body>
47
+ </html>
data/lib/.DS_Store CHANGED
Binary file
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'agilib'
2
4
  require 'thor'
3
5
 
@@ -6,11 +8,14 @@ module Agilib
6
8
  class Command < Thor
7
9
  include Thor::Actions
8
10
 
9
- desc "new APP_NAME", "create a new Rails app"
11
+ desc "composer APP_NAME", "Cria uma nova aplicação Rails nos padrões da Agivis"
12
+
13
+ method_option :all, :type => :boolean, :aliases => "-a", :default => false
14
+ def composer(name)
15
+ Agilib::Composer.options = options
10
16
 
11
- def new(name)
12
17
  # Instala uma aplicação Rails
13
- system("rails new #{name} --skip-bundle -d mysql -m #{Agilib::Composer.template_runner}")
18
+ system("rails new #{name} --skip-bundle --skip-test-unit -d mysql -m #{Agilib::Composer.template_runner}")
14
19
  end
15
20
  end
16
21
  end
@@ -13,5 +13,13 @@ module Agilib
13
13
  File.join(File.dirname(__FILE__), 'templates', 'runner.rb')
14
14
  end
15
15
 
16
+ def options=(opt)
17
+ @_options = opt
18
+ end
19
+
20
+ def options
21
+ @_options || Hash.new
22
+ end
23
+
16
24
  end
17
25
  end
@@ -9,22 +9,6 @@ module Agilib
9
9
  @template_framework_path = File.join(File.dirname(__FILE__), 'templates')
10
10
  end
11
11
 
12
- # def fixture_replacement
13
- # @fixture_replacement ||= FixtureReplacement.new
14
- # end
15
-
16
- # def orm
17
- # @orm ||= Orm.new
18
- # end
19
-
20
- # def javascript_framework
21
- # @javascript_framework ||= JavaScriptFramework.new
22
- # end
23
-
24
- # def template_engine
25
- # @template_engine ||= TemplateEngine.new
26
- # end
27
-
28
12
  def post_bundler(&block)
29
13
  @post_bundler_strategies << block
30
14
  end
@@ -33,22 +17,15 @@ module Agilib
33
17
  File.expand_path("recipes/#{name}.rb", @template_framework_path)
34
18
  end
35
19
 
36
- # ['snippet', 'template'].each do |type|
37
-
38
- # define_method "#{type}_path" do |group|
39
- # File.expand_path("#{type}s/#{group}", @template_framework_path)
40
- # end
41
-
42
- # define_method "load_#{type}" do |name, group|
43
- # group_path = send("#{type}_path".to_sym, group)
44
- # File.read File.expand_path(name, group_path)
45
- # end
20
+ def snippet_path(group)
21
+ File.expand_path("snippets/#{group}", @template_framework_path)
22
+ end
46
23
 
47
- # end
24
+ def load_snippet(name, group)
25
+ group_path = snippet_path(group)
26
+ File.read File.expand_path("#{name}.rb", group_path)
27
+ end
48
28
 
49
- # def testing_framework
50
- # @testing_framework ||= TestingFramework.new
51
- # end
52
29
  end
53
30
 
54
31
  end
@@ -0,0 +1,8 @@
1
+ gem 'meta_request', :group => [:development]
2
+ gem 'better_errors', :group => [:development]
3
+ gem 'binding_of_caller', :group => [:development]
4
+ gem 'sprockets_better_errors', :group => [:development]
5
+
6
+ templater.post_bundler do
7
+ inject_into_file "config/environments/development.rb", "\n\nconfig.assets.raise_production_errors = true", :after => "Dna::Application.configure do"
8
+ end
@@ -0,0 +1,6 @@
1
+ gem 'cancan'
2
+
3
+ templater.post_bundler do
4
+ generate 'cancan:ability'
5
+
6
+ end
@@ -4,3 +4,9 @@ if defined? app_name
4
4
  elsif defined? application_name
5
5
  create_file '.ruby-gemset', application_name
6
6
  end
7
+
8
+ templater.post_bundler do
9
+ rake 'db:create'
10
+
11
+ generate 'agilib:install'
12
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ gem 'devise'
3
+
4
+ templater.post_bundler do
5
+ generate 'devise:install'
6
+ generate 'devise', "user name"
7
+ rake 'db:migrate'
8
+ generate 'devise:views'
9
+
10
+
11
+ devise_form_config = <<-TEXT
12
+ <%= f.input :name, :required => true, :autofocus => true %>
13
+ TEXT
14
+
15
+ inject_into_file "app/views/devise/registrations/new.html.erb", devise_form_config, :before => "<%= f.input :email, :required => true, :autofocus => true %>"
16
+ gsub_file "app/views/devise/registrations/new.html.erb", '<%= f.input :email, :required => true, :autofocus => true %>', '<%= f.input :email, :required => true %>'
17
+
18
+ inject_into_file "app/views/devise/registrations/edit.html.erb", devise_form_config, :before => "<%= f.input :email, :required => true, :autofocus => true %>"
19
+ gsub_file "app/views/devise/registrations/edit.html.erb", '<%= f.input :email, :required => true, :autofocus => true %>', '<%= f.input :email, :required => true %>'
20
+
21
+
22
+ devise_filter_config = <<-TEXT
23
+
24
+
25
+ protected
26
+ def configure_permitted_parameters
27
+ devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmation, :full_name, :phone) }
28
+ end
29
+
30
+ TEXT
31
+
32
+ inject_into_file "app/controllers/application_controller.rb", devise_filter_config, :after => "protect_from_forgery with: :exception"
33
+ inject_into_file "app/controllers/application_controller.rb", "\n\nbefore_filter :configure_permitted_parameters, if: :devise_controller?", :after => "class ApplicationController < ActionController::Base"
34
+
35
+ end
@@ -1 +1,7 @@
1
- gem "agilib", "~> #{Agilib::Version::STRING}"
1
+ gem "agilib", "~> #{Agilib::Version::STRING}"
2
+
3
+ gem 'will_paginate', '~> 3.0'
4
+ gem 'will_paginate-bootstrap'
5
+
6
+ gem 'geocoder'
7
+ gem "paperclip", "~> 3.0"
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ templater.post_bundler do
3
+
4
+ if Agilib::Composer.options[:all] || yes?("\nO projeto deverá ter Notificação por Push? [yes,no]", :green)
5
+
6
+ do_configure = yes?("\nDeseja configurar agora? [yes,no]", :green)
7
+
8
+ generate 'agilib:push'
9
+ rake 'db:migrate'
10
+
11
+ if do_configure
12
+ say("\nIniciando configuração do módulo Push Notification... ", :yellow)
13
+
14
+ google_api = ask("\nInforme o Google API_KEY:") || ""
15
+ apple_pem = ask("\nInforme o caminho do Apple Certificate ( .pem )") || ""
16
+
17
+ agilib_config_path = 'config/initializers/agilib.rb'
18
+
19
+
20
+ agilib_push_config_text = <<-RUBY
21
+
22
+
23
+ config.use :push_notification do |options|
24
+
25
+ options.device_route = "/devices"
26
+
27
+ options.platform :ios do |ios|
28
+ ios.pem = "#{google_api}"
29
+ end
30
+
31
+ options.platform :android do |android|
32
+ android.api_key = "#{apple_pem}"
33
+ end
34
+
35
+ end
36
+
37
+ RUBY
38
+
39
+ inject_into_file agilib_config_path, agilib_push_config_text, :after => "Agilib.setup do |config|"
40
+
41
+ say("\nConfiguração finalizada... ", :green)
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ gem 'responders'
3
+
4
+ templater.post_bundler do
5
+ generate 'responders:install'
6
+ end
@@ -0,0 +1,125 @@
1
+ gem 'rspec-rails', :group => [:development, :test]
2
+ gem 'factory_girl_rails', :group => [:development, :test]
3
+ gem "database_cleaner", :group => :test
4
+ gem "email_spec", :group => :test
5
+ gem 'simplecov', :require => false, :group => :test
6
+
7
+ templater.post_bundler do
8
+
9
+ spec_helper_path = 'spec/spec_helper.rb'
10
+
11
+ ## ===============================================================
12
+ ## RSPEC
13
+ ## ===============================================================
14
+
15
+ say("\nIniciando configuração da Suíte de Testes... \n", :yellow)
16
+
17
+ say("\nConfigurando RSpec...\n", :green)
18
+
19
+ generate 'rspec:install'
20
+
21
+ generators_config = <<-RUBY
22
+
23
+
24
+ config.generators do |g|
25
+ g.test_framework :rspec, fixture: true
26
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
27
+ g.view_specs false
28
+ g.helper_specs false
29
+ g.controller_specs false
30
+ end
31
+
32
+
33
+ RUBY
34
+
35
+
36
+ gsub_file spec_helper_path, 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', ''
37
+
38
+ inject_into_file "config/application.rb", generators_config, :after => "class Application < Rails::Application"
39
+
40
+ ## ===============================================================
41
+ ## DATABASE CLEANER
42
+ ## ===============================================================
43
+
44
+ say("\nConfigurando Database Cleaner...\n", :green)
45
+
46
+ database_cleaner_config = <<-RUBY
47
+
48
+ config.before(:suite) do
49
+ DatabaseCleaner.strategy = :truncation
50
+ end
51
+
52
+ config.before(:each) do
53
+ DatabaseCleaner.start
54
+ end
55
+
56
+ config.after(:each) do
57
+ DatabaseCleaner.clean
58
+ end
59
+
60
+ RUBY
61
+
62
+
63
+ inject_into_file spec_helper_path, database_cleaner_config, :after => 'config.order = "random"'
64
+
65
+
66
+ ## ===============================================================
67
+ ## FACTORY GIRLS
68
+ ## ===============================================================
69
+
70
+ say("\nConfigurando FactoryGirl...\n", :green)
71
+
72
+ inject_into_file spec_helper_path, "\n\n config.include FactoryGirl::Syntax::Methods", :after => 'RSpec.configure do |config|'
73
+
74
+
75
+ ## ===============================================================
76
+ ## Email Spec
77
+ ## ===============================================================
78
+
79
+ say("\nConfigurando EmailSpec...\n", :green)
80
+
81
+ inject_into_file spec_helper_path, "\nrequire 'email_spec'", :after => "require 'rspec/rails'"
82
+
83
+ ## ===============================================================
84
+ ## SimpleCov
85
+ ## ===============================================================
86
+
87
+ say("\nConfigurando SimpleCov...\n", :green)
88
+
89
+ simple_cov_config = <<-TEXT
90
+ require 'simplecov'
91
+ SimpleCov.start
92
+ TEXT
93
+
94
+ inject_into_file spec_helper_path, simple_cov_config, :before => "ENV[\"RAILS_ENV\"] ||= 'test'"
95
+
96
+ ## ===============================================================
97
+ ## Paperclip
98
+ ## ===============================================================
99
+
100
+ say("\nConfigurando Paperclip...\n", :green)
101
+
102
+ inject_into_file spec_helper_path, "\nrequire 'paperclip/matchers'", :after => "require 'rspec/autorun'"
103
+
104
+
105
+ ## ===============================================================
106
+ ## Cancan
107
+ ## ===============================================================
108
+
109
+ say("\nConfigurando Cancan...\n", :green)
110
+
111
+ inject_into_file spec_helper_path, "\nrequire 'cancan/matchers'", :after => "require 'rspec/autorun'"
112
+
113
+
114
+
115
+ ## ===============================================================
116
+ ## USER SPECS
117
+ ## ===============================================================
118
+
119
+ say("\nConfigurando Testes para User...\n", :green)
120
+
121
+ remove_file "spec/models/user_spec.rb"
122
+ create_file "spec/models/user_spec.rb", templater.load_snippet('user_model_spec','rspec')
123
+
124
+
125
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ gem 'simple_form'
3
+
4
+ templater.post_bundler do
5
+ generate 'simple_form:install', "--bootstrap"
6
+ end
@@ -1,11 +1,10 @@
1
1
  # encoding: utf-8
2
-
3
- print_wrapped("=================================================")
4
-
5
- if yes?("O projeto deverá ter Autenticação por Token? [yes,no]", :green)
6
-
7
- templater.post_bundler do
2
+ templater.post_bundler do
3
+
4
+ if Agilib::Composer.options[:all] || yes?("\nO projeto deverá ter Autenticação por Token? [yes,no]\n", :green)
5
+ say("\nConfigurando o módulo Token Authenticatable... \n\n", :green)
8
6
  generate 'agilib:token'
7
+ rake 'db:migrate'
9
8
  end
10
9
 
11
10
  end
@@ -1,9 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('./../../', __FILE__))
2
- # puts File.expand_path('./../../', __FILE__)
2
+
3
+ require File.join(File.expand_path('./../../../../', __FILE__), 'agilib.rb')
3
4
  require 'composer'
4
5
  require File.join(File.dirname(__FILE__), 'core_ext.rb')
5
6
 
6
- %w(default gems token).each do |recipe|
7
+ %w(default gems responders simple_form devise token push rspec cancan better_errors).each do |recipe|
7
8
  apply templater.recipe(recipe)
8
9
  end
9
10
 
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+
5
+ before(:each) do
6
+ @attr = {
7
+ :name => "Example User",
8
+ :email => "user@example.com",
9
+ :password => "changeme",
10
+ :password_confirmation => "changeme"
11
+ }
12
+ end
13
+
14
+ it "should create a new instance given a valid attribute" do
15
+ User.create!(@attr)
16
+ end
17
+
18
+ it "should require an email address" do
19
+ no_email_user = User.new(@attr.merge(:email => ""))
20
+ no_email_user.should_not be_valid
21
+ end
22
+
23
+ it "should accept valid email addresses" do
24
+ addresses = %w[user@foo.com THE_USER@foo.bar.org first.last@foo.jp]
25
+ addresses.each do |address|
26
+ valid_email_user = User.new(@attr.merge(:email => address))
27
+ valid_email_user.should be_valid
28
+ end
29
+ end
30
+
31
+ it "should reject invalid email addresses" do
32
+ addresses = %w[user@foo,com user_at_foo.org example.user@foo.]
33
+ addresses.each do |address|
34
+ invalid_email_user = User.new(@attr.merge(:email => address))
35
+ invalid_email_user.should_not be_valid
36
+ end
37
+ end
38
+
39
+ it "should reject duplicate email addresses" do
40
+ User.create!(@attr)
41
+ user_with_duplicate_email = User.new(@attr)
42
+ user_with_duplicate_email.should_not be_valid
43
+ end
44
+
45
+ it "should reject email addresses identical up to case" do
46
+ upcased_email = @attr[:email].upcase
47
+ User.create!(@attr.merge(:email => upcased_email))
48
+ user_with_duplicate_email = User.new(@attr)
49
+ user_with_duplicate_email.should_not be_valid
50
+ end
51
+
52
+ describe "passwords" do
53
+
54
+ before(:each) do
55
+ @user = User.new(@attr)
56
+ end
57
+
58
+ it "should have a password attribute" do
59
+ @user.should respond_to(:password)
60
+ end
61
+
62
+ it "should have a password confirmation attribute" do
63
+ @user.should respond_to(:password_confirmation)
64
+ end
65
+ end
66
+
67
+ describe "password validations" do
68
+
69
+ it "should require a password" do
70
+ User.new(@attr.merge(:password => "", :password_confirmation => "")).
71
+ should_not be_valid
72
+ end
73
+
74
+ it "should require a matching password confirmation" do
75
+ User.new(@attr.merge(:password_confirmation => "invalid")).
76
+ should_not be_valid
77
+ end
78
+
79
+ it "should reject short passwords" do
80
+ short = "a" * 5
81
+ hash = @attr.merge(:password => short, :password_confirmation => short)
82
+ User.new(hash).should_not be_valid
83
+ end
84
+
85
+ end
86
+
87
+ describe "password encryption" do
88
+
89
+ before(:each) do
90
+ @user = User.create!(@attr)
91
+ end
92
+
93
+ it "should have an encrypted password attribute" do
94
+ @user.should respond_to(:encrypted_password)
95
+ end
96
+
97
+ it "should set the encrypted password attribute" do
98
+ @user.encrypted_password.should_not be_blank
99
+ end
100
+
101
+ end
102
+
103
+ end
@@ -2,7 +2,6 @@ require 'active_support/dependencies'
2
2
  require 'agilib/push_notification/platforms/ios'
3
3
  require 'agilib/push_notification/platforms/android'
4
4
  require 'agilib/push_notification/model'
5
- require 'agilib/push_notification/routing'
6
5
 
7
6
  module Agilib
8
7
  module PushNotification
@@ -0,0 +1,39 @@
1
+ module Agilib
2
+ module Routing
3
+ module MapperExtensions
4
+
5
+ def agilib
6
+
7
+ if Agilib.rails4? && Rails.env.development?
8
+ get "/" => "agilib/welcome#index"
9
+ end
10
+
11
+ if Agilib.use_modules[:token_authenticatable].present?
12
+ agilib_token_authenticatable
13
+ end
14
+
15
+ if Agilib.use_modules[:push_notification].present?
16
+ agilib_push_notification
17
+ end
18
+
19
+ end
20
+
21
+ def agilib_token_authenticatable
22
+ route = Agilib::TokenAuthenticatable.route
23
+ devise_scope :user do
24
+ post "#{route}" => "agilib/tokens#create"
25
+ delete "#{route}" => "agilib/tokens#destroy"
26
+ end
27
+ end
28
+
29
+ def agilib_push_notification
30
+ path = Agilib::PushNotification.device_route
31
+ resources :devices, :path => path, :controller => "agilib/devices"
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ if defined? ActionDispatch
38
+ ActionDispatch::Routing::Mapper.send :include, Agilib::Routing::MapperExtensions
39
+ end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/dependencies'
2
- require 'agilib/token_authenticatable/routing'
3
2
  require 'agilib/token_authenticatable/token_authentication_handler'
4
3
 
5
4
 
@@ -3,7 +3,7 @@ module Agilib
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
5
  PATCH = 2
6
- BUILD = 'beta1'
6
+ BUILD = 'beta2'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
data/lib/agilib.rb CHANGED
@@ -79,6 +79,7 @@ end
79
79
 
80
80
  require 'agilib/version'
81
81
  require 'agilib/engine'
82
+ require 'agilib/routing'
82
83
 
83
84
  require 'agilib/token_authenticatable/token_authentication'
84
85
  require 'agilib/push_notification/push_notification'
@@ -16,6 +16,10 @@ module Agilib
16
16
  end
17
17
  end
18
18
 
19
+ def add_route
20
+ route("agilib")
21
+ end
22
+
19
23
  def config_push
20
24
  if options[:push]
21
25
  invoke "agilib:push", ["Push"], options
@@ -57,59 +57,6 @@ Agilib.setup do |config|
57
57
 
58
58
  end
59
59
 
60
- # Define se a aplicação vai usar notificação por push
61
- # Caso esteja habilitado, será preciso adicionar o helper da agilib para que sejam criadas
62
- # as rotas para o Agilib::DevicesController
63
- #
64
- # Exemplo:
65
- #
66
- # config/routes.rb
67
- #
68
- # agilib_push_notification
69
- #
70
- # Este procedimento é necessário para que a rota /devices.json esteja disponível
71
- config.use :push_notification do |options|
72
60
 
73
- # ===============================================================================
74
- # Define qual será a rota para cadastrar/alterar/apagar os Devices
75
- #
76
- # Exemplo: /devices.json
77
- # Se alterar para: options.device_route = "/celulares"
78
- # A rota será: /celulares.json
79
- #
80
- #
81
- # Default: "/devices"
82
- options.device_route = "/devices"
83
-
84
- # ===============================================================================
85
- # Habilita o envio de notificação por push para dispositivos IOS
86
- #
87
- options.platform :ios do |ios|
88
-
89
- # =========================================
90
- # Caminho do arquivo de certificado .pem
91
- #
92
- ios.pem = ""
93
-
94
- # =========================================
95
- # Porta de conexão com o servidor da Apple
96
- #
97
- ios.port = 2195
98
-
99
- end
100
-
101
- # ===============================================================================
102
- # Habilita o envio de notificação por push para dispositivos ANDROID
103
- #
104
- options.platform :android do |android|
105
-
106
- # =========================================
107
- # Chave API do Google
108
- #
109
- android.api_key = "Insert here you api key"
110
-
111
- end
112
-
113
- end
114
61
 
115
62
  end
@@ -16,7 +16,9 @@ module Agilib
16
16
  end
17
17
 
18
18
  def add_route
19
- route("agilib_push_notification")
19
+ unless File.exists?(File.join("config/initializers/agilib.rb"))
20
+ route("agilib_push_notification")
21
+ end
20
22
  end
21
23
 
22
24
  def update_model
@@ -2,6 +2,7 @@
2
2
  module Agilib
3
3
  module Generators
4
4
  class TokenGenerator < ::Rails::Generators::Base
5
+
5
6
  desc "Instalação do módulo Token Authenticatable da Agilib"
6
7
  class_option :"skip-migration", type: :boolean, desc: 'Caso não queira que seja criado o arquivo de migração'
7
8
 
@@ -16,7 +17,9 @@ module Agilib
16
17
  end
17
18
 
18
19
  def add_route
19
- route("agilib_token_authenticatable")
20
+ unless File.exists?(File.join("config/initializers/agilib.rb"))
21
+ route("agilib_token_authenticatable")
22
+ end
20
23
  end
21
24
 
22
25
  def update_application_controller_and_model
@@ -3,8 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "AgilibRails" do
4
4
  it "test agilib" do
5
5
 
6
- puts Agilib::Composer.template_runner
7
-
6
+ templater = Agilib::Composer::Templater.new
7
+ puts templater.snippet_path('rspec')
8
+ puts templater.load_snippet('user_model_spec','rspec')
8
9
  end
9
10
 
10
11
  it "is rails 4" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.beta1
4
+ version: 0.1.2.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Junior
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-14 00:00:00.000000000 Z
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: executable-hooks
@@ -173,7 +173,15 @@ files:
173
173
  - app/controllers/.DS_Store
174
174
  - app/controllers/agilib/devices_controller.rb
175
175
  - app/controllers/agilib/tokens_controller.rb
176
+ - app/controllers/agilib/welcome_controller.rb
176
177
  - app/models/agilib/device.rb
178
+ - app/views/agilib/devices/_form.html.erb
179
+ - app/views/agilib/devices/edit.html.erb
180
+ - app/views/agilib/devices/index.html.erb
181
+ - app/views/agilib/devices/new.html.erb
182
+ - app/views/agilib/devices/show.html.erb
183
+ - app/views/agilib/welcome/index.html
184
+ - app/views/agilib/welcome/index.html.erb
177
185
  - bin/agilib
178
186
  - lib/.DS_Store
179
187
  - lib/agilib.rb
@@ -182,18 +190,24 @@ files:
182
190
  - lib/agilib/composer/composer.rb
183
191
  - lib/agilib/composer/templater.rb
184
192
  - lib/agilib/composer/templates/core_ext.rb
193
+ - lib/agilib/composer/templates/recipes/better_errors.rb
194
+ - lib/agilib/composer/templates/recipes/cancan.rb
185
195
  - lib/agilib/composer/templates/recipes/default.rb
186
196
  - lib/agilib/composer/templates/recipes/devise.rb
187
197
  - lib/agilib/composer/templates/recipes/gems.rb
198
+ - lib/agilib/composer/templates/recipes/push.rb
199
+ - lib/agilib/composer/templates/recipes/responders.rb
200
+ - lib/agilib/composer/templates/recipes/rspec.rb
201
+ - lib/agilib/composer/templates/recipes/simple_form.rb
188
202
  - lib/agilib/composer/templates/recipes/token.rb
189
203
  - lib/agilib/composer/templates/runner.rb
204
+ - lib/agilib/composer/templates/snippets/rspec/user_model_spec.rb
190
205
  - lib/agilib/engine.rb
191
206
  - lib/agilib/push_notification/model.rb
192
207
  - lib/agilib/push_notification/platforms/android.rb
193
208
  - lib/agilib/push_notification/platforms/ios.rb
194
209
  - lib/agilib/push_notification/push_notification.rb
195
- - lib/agilib/push_notification/routing.rb
196
- - lib/agilib/token_authenticatable/routing.rb
210
+ - lib/agilib/routing.rb
197
211
  - lib/agilib/token_authenticatable/token_authentication.rb
198
212
  - lib/agilib/token_authenticatable/token_authentication_handler.rb
199
213
  - lib/agilib/version.rb
@@ -1,15 +0,0 @@
1
- module Agilib
2
- module Routing
3
- module MapperExtensions
4
- def agilib_push_notification
5
- if Agilib.use_modules[:push_notification].present?
6
- path = Agilib::PushNotification.device_route
7
- resources :devices, :path => path, :controller => "agilib/devices"
8
- end
9
- end
10
- end
11
- end
12
- end
13
- if defined? ActionDispatch
14
- ActionDispatch::Routing::Mapper.send :include, Agilib::Routing::MapperExtensions
15
- end
@@ -1,18 +0,0 @@
1
- module Agilib
2
- module Routing
3
- module MapperExtensions
4
- def agilib_token_authenticatable
5
- if Agilib.use_modules[:token_authenticatable].present?
6
- route = Agilib::TokenAuthenticatable.route
7
- devise_scope :user do
8
- post "#{route}" => "agilib/tokens#create"
9
- delete "#{route}/:token" => "agilib/tokens#destroy"
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
16
- if defined? ActionDispatch
17
- ActionDispatch::Routing::Mapper.send :include, Agilib::Routing::MapperExtensions
18
- end