activeadmin-generator 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -16,4 +16,8 @@ export AMAZON_DEFAULT_BUCKET_LOCATION='EU' # EU and US supported
16
16
  export HEROKU_USERNAME=''
17
17
  export HEROKU_PASSWORD=''
18
18
  export HEROKU_COLLABORATORS='first@email.com, second@email.com'
19
+ export ERRBIT_URL='http://errbit.yourhost.com'
20
+ export ERRBIT_EMAIL=''
21
+ export ERRBIT_PASSWORD=''
22
+ export ERRBIT_COLLABORATORS='4f991e12cc9cb10008000001, 4f99204fcc9cb1000b00000a'
19
23
  ```
@@ -20,5 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency "railties"
21
21
  gem.add_dependency "s3"
22
22
  gem.add_dependency "heroku-api"
23
+ gem.add_dependency "mechanize"
23
24
  end
24
25
 
@@ -1,5 +1,5 @@
1
1
  class Base
2
- BRICKS = %w(base git clean_assets frontend database heroku active_admin active_admin_extras)
2
+ BRICKS = %w(init git clean_assets errbit frontend database heroku active_admin active_admin_extras)
3
3
  attr_reader :context
4
4
 
5
5
  def initialize(context)
@@ -7,6 +7,7 @@ class Base
7
7
  end
8
8
 
9
9
  def require_bricks
10
+ context.apply "bricks/base.rb"
10
11
  BRICKS.each do |brick_module|
11
12
  context.apply "bricks/#{brick_module}.rb"
12
13
  end
@@ -14,13 +15,9 @@ class Base
14
15
 
15
16
  def bricks
16
17
  @bricks ||= BRICKS.map do |brick_module|
17
- brick_class = "bricks/#{brick_module}".camelize.constantize rescue nil
18
- if brick_class
19
- brick = brick_class.new(context)
20
- brick.apply? ? brick : nil
21
- else
22
- nil
23
- end
18
+ brick_class = "bricks/#{brick_module}".camelize.constantize
19
+ brick = brick_class.new(context)
20
+ brick.apply? ? brick : nil
24
21
  end.compact
25
22
  end
26
23
 
@@ -40,8 +37,8 @@ class Base
40
37
 
41
38
  def hook(name)
42
39
  bricks.each do |brick|
40
+ puts brick.class.name
43
41
  if brick.respond_to? name
44
- context.send :log, name.to_s.titleize, "brick: #{brick.title}"
45
42
  brick.send(name)
46
43
  end
47
44
  end
@@ -3,7 +3,8 @@ module ::Bricks
3
3
  def before_bundle
4
4
  gem "activeadmin"
5
5
  gem "meta_search"
6
- @site_title = ask("Name to be shown in admin backend")
6
+ copy_file "config/locales/devise.it.yml"
7
+ @site_title = ENV['APP_NAME']
7
8
  end
8
9
 
9
10
  def after_bundle
@@ -15,7 +15,7 @@ module ::Bricks
15
15
  end
16
16
 
17
17
  def title
18
- "Base"
18
+ self.class.name
19
19
  end
20
20
 
21
21
  def template(source)
@@ -34,12 +34,6 @@ module ::Bricks
34
34
  git commit: "-m '#{message}'"
35
35
  end
36
36
 
37
- def before_bundle
38
- say "=" * 80
39
- say "Welcome to ActiveAdmin Generator! :)".center(80) + "\n"
40
- say "=" * 80
41
- end
42
-
43
37
  def format(text)
44
38
  string = ""
45
39
  if title
@@ -0,0 +1,95 @@
1
+ require 'mechanize'
2
+ require 'uri'
3
+
4
+ module ::Bricks
5
+ class Errbit < Base
6
+
7
+ def apply?
8
+ yes? "Do you want to configure Errbit?"
9
+ end
10
+
11
+ def before_bundle
12
+ gem 'airbrake'
13
+
14
+ ask_name_and_collaborators
15
+
16
+ @errbit_url = ENV['ERRBIT_URL'] || ask("Errbit URL")
17
+ uri = URI(@errbit_url)
18
+
19
+ @errbit_host = uri.host
20
+ @errbit_port = uri.scheme == "https" ? 443 : 80
21
+
22
+ @errbit_email = ENV['ERRBIT_EMAIL'] || ask("Errbit email")
23
+ @errbit_password = ENV['ERRBIT_PASSWORD'] || ask("Errbit password")
24
+
25
+ login!
26
+ @api_key = find_app_key
27
+
28
+ while @api_key.blank?
29
+ begin
30
+ @api_key = create_app_key
31
+ rescue RuntimeError => e
32
+ say e.message
33
+ ask_name_and_collaborators
34
+ end
35
+ end
36
+
37
+ template "config/initializers/errbit.rb"
38
+ end
39
+
40
+ def ask_name_and_collaborators(force = false)
41
+ @app_name = ENV['APP_NAME']
42
+ @collaborators = ( ENV['ERRBIT_COLLABORATORS'] || ask("Specify collaborators' User IDs:") ).split(/\s*,\s*/).map(&:strip)
43
+ end
44
+
45
+ def agent
46
+ @agent ||= Mechanize.new
47
+ end
48
+
49
+ def login!
50
+ agent.get(abs_path('/users/sign_in')) do |page|
51
+ page.form_with(action: '/users/sign_in') do |f|
52
+ f["user[email]"] = @errbit_email
53
+ f["user[password]"] = @errbit_password
54
+ end.submit
55
+ end
56
+ end
57
+
58
+ def fetch_api_key(page)
59
+ page.search("span.meta").text.gsub(/^.*API Key:/m, '').strip
60
+ rescue
61
+ nil
62
+ end
63
+
64
+ def find_app_key
65
+ page = agent.get(abs_path('/apps'))
66
+ link = page.search("td.name a").find { |link| link.text == @app_name }
67
+ link.present? ? fetch_api_key(agent.get(link["href"])) : nil
68
+ end
69
+
70
+ def create_app_key
71
+ new_page = agent.get(abs_path('/apps/new'))
72
+ result_page = new_page.form_with(action: '/apps') do |f|
73
+ f["app[name]"] = @app_name
74
+ f["app[notify_on_errs]"] = "1"
75
+ @collaborators.each_with_index do |uid, i|
76
+ f["app[watchers_attributes][#{i}][user_id]"] = uid
77
+ end
78
+ end.submit
79
+
80
+ api_key = fetch_api_key(result_page)
81
+
82
+ if api_key.nil?
83
+ fail result_page.search(".error-messages ul li").map(&:text).join("\n")
84
+ end
85
+
86
+ api_key
87
+ end
88
+
89
+ def abs_path(path)
90
+ @errbit_url + path
91
+ end
92
+
93
+ end
94
+ end
95
+
@@ -18,6 +18,10 @@ module ::Bricks
18
18
  apply_i18n_routes!
19
19
  end
20
20
 
21
+ def deflate_assets
22
+ copy_file "config.ru"
23
+ end
24
+
21
25
  def apply_i18n_routes!
22
26
  gem 'i18n_routing'
23
27
  copy_file "config/locales/it.yml"
@@ -5,6 +5,7 @@ module ::Bricks
5
5
 
6
6
  append_file ".gitignore", <<-END
7
7
  *.swp
8
+ .DS_Store
8
9
  .sass-cache
9
10
  root.dir
10
11
  .rake_tasks~
@@ -0,0 +1,16 @@
1
+ module ::Bricks
2
+ class Init < Base
3
+
4
+ def before_bundle
5
+ say "=" * 80
6
+ say "Welcome to ActiveAdmin Generator! :)".center(80) + "\n"
7
+ say "=" * 80
8
+ ENV['APP_NAME'] = ask("Name of the project:")
9
+ end
10
+
11
+ end
12
+ end
13
+
14
+
15
+
16
+
@@ -1 +1 @@
1
- @import "active_admin/extra/base"
1
+ @import active_admin/extra/base
@@ -0,0 +1 @@
1
+ use Rack::Deflater
@@ -0,0 +1,6 @@
1
+ Airbrake.configure do |config|
2
+ config.api_key = "<%= @api_key %>"
3
+ config.host = "<%= @errbit_host %>"
4
+ config.port = <%= @errbit_port %>
5
+ config.secure = config.port == 443
6
+ end
@@ -0,0 +1,55 @@
1
+ it:
2
+ errors:
3
+ messages:
4
+ expired: "è scaduto, si prega di richiederne uno nuovo"
5
+ not_found: "non trovato"
6
+ already_confirmed: "è stato già confermato, prova ad effettuare un nuovo accesso"
7
+ not_locked: "non era bloccato"
8
+ not_saved:
9
+ one: "Non posso salvare questo %{resource}: 1 errore"
10
+ other: "Non posso salvare questo %{resource}: %{count} errori."
11
+
12
+ devise:
13
+ failure:
14
+ already_authenticated: "Hai già effettuato l'accesso."
15
+ unauthenticated: "Devi accedere o registrarti per continuare."
16
+ unconfirmed: "Devi confermare il tuo account per continuare."
17
+ locked: "Il tuo account è bloccato."
18
+ invalid: "Indirizzo email o password non validi."
19
+ invalid_token: "Codice di autenticazione non valido."
20
+ timeout: "Sessione scaduta, accedere nuovamente per continuare."
21
+ inactive: "Il tuo account non è stato ancora attivato."
22
+ sessions:
23
+ signed_in: "Accesso effettuato con successo."
24
+ signed_out: "Sei uscito correttamente."
25
+ passwords:
26
+ send_instructions: "Entro qualche minuto riceverai un messaggio email con le istruzioni per reimpostare la tua password."
27
+ updated: "La tua password è stata cambiata. Ora sei collegato."
28
+ updated_not_active: "La tua password è stata cambiata."
29
+ send_paranoid_instructions: "Se la tua email esiste nel nostro database, entro qualche minuto riceverai un messaggio email contentente un link per il ripristino della password"
30
+ confirmations:
31
+ send_instructions: "Riceverai un messaggio email con le istruzioni per confermare il tuo account entro qualche minuto."
32
+ send_paranoid_instructions: "Se la tua email esiste nel nostro database, entro qualche minuto riceverai un messaggio email con le istruzioni per confermare il tuo account."
33
+ confirmed: "Il tuo account è stato correttamente confermato. Ora sei collegato."
34
+ registrations:
35
+ signed_up: "Benvenuto! Ti sei registrato correttamente."
36
+ signed_up_but_unconfirmed: "Ti sei registrato correttamente. Tuttavia non puoi effettuare l'accesso perchè il tuo account è da confermare. Per favore apri il link che hai ricevuto tramite email per attivare il tuo account."
37
+ signed_up_but_inactive: "Ti sei registrato correttamente. Tuttavia non puoi effettuare l'accesso perchè il tuo account non è stato ancora attivato."
38
+ signed_up_but_locked: "Ti sei registrato correttamente. Tuttavia non puoi effettuare l'accesso perchè il tuo account è bloccato."
39
+ updated: "Il tuo account è stato aggiornato."
40
+ update_needs_confirmation: "Il tuo account è stato aggiornato, tuttavia è necessario verificare il tuo nuovo indirizzo email. Entro qualche minuto riceverai un messaggio email con le istruzioni per confermare il tuo nuovo indirizzo email."
41
+ destroyed: "Arrivederci! L'account è stato cancellato. Speriamo di rivederci presto."
42
+ unlocks:
43
+ send_instructions: "Entro qualche minuto riceverai un messaggio email con le istruzioni per sbloccare il tuo account."
44
+ unlocked: "Il tuo account è stato correttamente sbloccato. Ora sei collegato."
45
+ send_paranoid_instructions: "Se la tua email esiste nel nostro database, entro qualche minuto riceverai un messaggio email con le istruzioni per sbloccare il tuo account."
46
+ omniauth_callbacks:
47
+ success: "Autenticato con successo dall'account %{kind}."
48
+ failure: 'Non è stato possibile autenticarti come %{kind} perchè "%{reason}".'
49
+ mailer:
50
+ confirmation_instructions:
51
+ subject: "Istruzioni per la conferma"
52
+ reset_password_instructions:
53
+ subject: "Istruzioni per reimpostare la password"
54
+ unlock_instructions:
55
+ subject: "Istruzioni per sbloccare l'account"
@@ -1,6 +1,6 @@
1
1
  module ActiveAdmin
2
2
  module Generator
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: mechanize
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
94
110
  description: Generate ActiveAdmin projects
95
111
  email:
96
112
  - stefano.verna@welaika.com
@@ -116,6 +132,7 @@ files:
116
132
  - lib/active_admin/generator/bricks/frontend.rb
117
133
  - lib/active_admin/generator/bricks/git.rb
118
134
  - lib/active_admin/generator/bricks/heroku.rb
135
+ - lib/active_admin/generator/bricks/init.rb
119
136
  - lib/active_admin/generator/cli.rb
120
137
  - lib/active_admin/generator/templates/app/assets/fonts/.empty_directory
121
138
  - lib/active_admin/generator/templates/app/assets/images/.empty_directory
@@ -140,10 +157,13 @@ files:
140
157
  - lib/active_admin/generator/templates/app/views/application/_js_includes.html.slim
141
158
  - lib/active_admin/generator/templates/app/views/layouts/application.html.slim
142
159
  - lib/active_admin/generator/templates/app/views/static/homepage.html.slim
160
+ - lib/active_admin/generator/templates/config.ru
143
161
  - lib/active_admin/generator/templates/config/active_admin_initializer.rb
144
162
  - lib/active_admin/generator/templates/config/database.yml
145
163
  - lib/active_admin/generator/templates/config/initializers/active_admin.rb
146
164
  - lib/active_admin/generator/templates/config/initializers/dragonfly.rb
165
+ - lib/active_admin/generator/templates/config/initializers/errbit.rb
166
+ - lib/active_admin/generator/templates/config/locales/devise.it.yml
147
167
  - lib/active_admin/generator/templates/config/locales/it.yml
148
168
  - lib/active_admin/generator/templates/db/migrate/20121126113057_create_asset_thumbs.rb
149
169
  - lib/active_admin/generator/version.rb