activeadmin-generator 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
3
+
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activeadmin-generator (0.0.3)
5
+ aws-s3
6
+ railties
7
+ rake
8
+ thor
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ actionpack (3.2.9)
14
+ activemodel (= 3.2.9)
15
+ activesupport (= 3.2.9)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.9)
24
+ activesupport (= 3.2.9)
25
+ builder (~> 3.0.0)
26
+ activesupport (3.2.9)
27
+ i18n (~> 0.6)
28
+ multi_json (~> 1.0)
29
+ aws-s3 (0.6.3)
30
+ builder
31
+ mime-types
32
+ xml-simple
33
+ builder (3.0.4)
34
+ erubis (2.7.0)
35
+ hike (1.2.1)
36
+ i18n (0.6.1)
37
+ journey (1.0.4)
38
+ json (1.7.5)
39
+ mime-types (1.19)
40
+ multi_json (1.3.7)
41
+ rack (1.4.1)
42
+ rack-cache (1.2)
43
+ rack (>= 0.4)
44
+ rack-ssl (1.3.2)
45
+ rack
46
+ rack-test (0.6.2)
47
+ rack (>= 1.0)
48
+ railties (3.2.9)
49
+ actionpack (= 3.2.9)
50
+ activesupport (= 3.2.9)
51
+ rack-ssl (~> 1.3.2)
52
+ rake (>= 0.8.7)
53
+ rdoc (~> 3.4)
54
+ thor (>= 0.14.6, < 2.0)
55
+ rake (10.0.2)
56
+ rdoc (3.12)
57
+ json (~> 1.4)
58
+ sprockets (2.2.1)
59
+ hike (~> 1.2)
60
+ multi_json (~> 1.0)
61
+ rack (~> 1.0)
62
+ tilt (~> 1.1, != 1.3.0)
63
+ thor (0.16.0)
64
+ tilt (1.3.3)
65
+ xml-simple (1.1.2)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ activeadmin-generator!
data/README.md CHANGED
@@ -0,0 +1,19 @@
1
+ # ActiveAdmin project generator
2
+
3
+ ## Usage
4
+
5
+ ```
6
+ gem install activeadmin-generator
7
+ activeadmin-generator new my_app
8
+ ```
9
+
10
+ ## Default configurations
11
+
12
+ ```bash
13
+ export AMAZON_ACCESS_KEY_ID=''
14
+ export AMAZON_SECRET_ACCESS_KEY=''
15
+ export AMAZON_DEFAULT_BUCKET_LOCATION='EU' # EU and US supported
16
+ export HEROKU_USERNAME=''
17
+ export HEROKU_PASSWORD=''
18
+ export HEROKU_COLLABORATORS='first@email.com, second@email.com'
19
+ ```
@@ -18,5 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency "rake"
19
19
  gem.add_dependency "thor"
20
20
  gem.add_dependency "railties"
21
+ gem.add_dependency "s3"
22
+ gem.add_dependency "heroku-api"
21
23
  end
22
24
 
@@ -1,5 +1,5 @@
1
1
  class Base
2
- BRICKS = %w(base git clean_assets frontend database heroku s3 active_admin active_admin_extras)
2
+ BRICKS = %w(base git clean_assets frontend database heroku active_admin active_admin_extras)
3
3
  attr_reader :context
4
4
 
5
5
  def initialize(context)
@@ -5,8 +5,9 @@ module ::Bricks
5
5
 
6
6
  attr_reader :context, :base_path
7
7
 
8
- delegate :directory, :copy_file, :remove_dir, :gsub_file, :rake, :generate, :route, :empty_directory,
9
- :gem, :git, :remove_file, :append_file, to: :context
8
+ delegate :inject_into_file, :directory, :copy_file, :remove_dir, :gsub_file,
9
+ :rake, :generate, :route, :empty_directory, :gem, :git, :remove_file,
10
+ :append_file, to: :context
10
11
 
11
12
  def initialize(context)
12
13
  @context = context
@@ -30,7 +31,7 @@ module ::Bricks
30
31
 
31
32
  def commit_all(message)
32
33
  git add: "-A ."
33
- git :commit => "-m '#{message}'"
34
+ git commit: "-m '#{message}'"
34
35
  end
35
36
 
36
37
  def before_bundle
@@ -24,15 +24,15 @@ module ::Bricks
24
24
  end
25
25
 
26
26
  def configure_sqlite
27
- gem 'sqlite3'
27
+ gem 'sqlite3', group: 'development'
28
28
  end
29
29
 
30
30
  def configure_mysql
31
- gem 'mysql2'
31
+ gem 'mysql2', group: 'development'
32
32
  end
33
33
 
34
34
  def configure_pg
35
- gem 'pg', '0.13.2'
35
+ gem 'pg', '0.13.2', group: 'development'
36
36
  end
37
37
 
38
38
  end
@@ -1,25 +1,90 @@
1
+ require 's3'
2
+ require 'heroku-api'
3
+
1
4
  module ::Bricks
2
5
  class Heroku < Base
3
6
 
7
+ attr_reader :access_key, :access_secret, :bucket_name
8
+
4
9
  def apply?
5
- yes? "Do you want to deploy this site on Heroku?"
10
+ yes? "Will you be deploying to Heroku+S3?"
6
11
  end
7
12
 
8
13
  def before_bundle
14
+ @heroku_username = ENV['HEROKU_USERNAME'] || ask("Heroku username:")
15
+ @heroku_password = ENV['HEROKU_PASSWORD'] || ask("Heroku password:")
16
+ @heroku_collaborators = ( ENV['HEROKU_COLLABORATORS'] || ask("Specify collaborators' emails:") ).split(/\s*,\s*/).map(&:strip)
17
+
18
+ heroku = ::Heroku::API.new(username: @heroku_username, password: @heroku_password)
19
+
20
+ begin
21
+ begin
22
+ @heroku_appname = ask("Please specify Heroku app name:")
23
+ @heroku_app = heroku.get_app(@heroku_appname)
24
+ say "App already created!"
25
+ rescue ::Heroku::API::Errors::NotFound
26
+ say "Name available!"
27
+ @heroku_app = heroku.post_app('name' => @heroku_appname)
28
+ say "Heroku app created!"
29
+ @heroku_collaborators.each do |email|
30
+ say "Adding #{email} as collaborator"
31
+ heroku.post_collaborator(@heroku_appname, email)
32
+ say "#{email} added as collaborator"
33
+ end
34
+ rescue ::Heroku::API::Errors::Forbidden
35
+ say "Name already taken! :("
36
+ end
37
+ end while @heroku_app.blank?
38
+
39
+ git remote: "add heroku #{@heroku_app.body['git_url']}"
40
+
41
+ gsub_file "config/environments/production.rb", /Don't fallback to assets pipeline/, "Fallback to assets pipeline"
42
+ gsub_file "config/environments/production.rb", /config\.assets\.compile = false/, "config.assets.compile = true"
43
+ inject_into_file "config/application.rb", " config.assets.initialize_on_precompile = false\n", after: "config.assets.enabled = true\n"
44
+
45
+ @access_key = ENV['AMAZON_ACCESS_KEY_ID'] || ask("Amazon access key ID: ")
46
+ @access_secret = ENV['AMAZON_SECRET_ACCESS_KEY'] || ask("Amazon secret access key: ")
47
+ @bucket_location = ENV['AMAZON_DEFAULT_BUCKET_LOCATION'] || choose("Bucket location", [["Europe", :eu], ["US", :us]])
48
+ @bucket_location = @bucket_location.to_s.downcase.to_sym
49
+ @bucket_name = ask "Specify S3 bucket name:"
50
+
51
+ service = S3::Service.new(access_key_id: @access_key, secret_access_key: @access_secret)
9
52
  copy_file "db/migrate/20121126113057_create_asset_thumbs.rb"
10
53
  copy_file "config/initializers/dragonfly.rb"
11
- end
12
54
 
13
- def after_bundle
14
- rake "activeadmin_gallery:install:migrations"
15
- rake "activeadmin_wysihtml5:install:migrations"
16
- rake "activeadmin_seo:install:migrations"
17
- end
55
+ begin
56
+ @bucket = service.buckets.find(@bucket_name)
57
+ say "Bucket already present!"
58
+ rescue Exception => e
59
+ say e.message
60
+ @bucket = service.buckets.build(@bucket_name)
61
+ @bucket.save(location: @bucket_location)
62
+ say "Bucket created!"
63
+ end
18
64
 
19
- end
20
- end
65
+ fog_regions = {
66
+ eu: 'eu-west-1',
67
+ us: 'us-east-1'
68
+ }
69
+
70
+ heroku.put_config_vars(
71
+ @heroku_appname,
72
+ 'S3_BUCKET' => @bucket_name,
73
+ 'S3_KEY' => @access_key,
74
+ 'S3_SECRET' => @access_secret,
75
+ 'S3_REGION' => fog_regions[@bucket_location]
76
+ )
21
77
 
78
+ gem 'fog', group: 'production'
79
+ gem 'pg', '0.13.2', group: 'production'
22
80
 
81
+ commit_all "Configured Heroku and S3"
82
+ end
23
83
 
84
+ def recap
85
+ say "The app is ready to be deployed on Heroku at #{@heroku_app.body['web_url']} with 'git push heroku master && heroku run rake db:migrate'"
86
+ end
24
87
 
88
+ end
89
+ end
25
90
 
@@ -1,6 +1,6 @@
1
1
  module ActiveAdmin
2
2
  module Generator
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
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-26 00:00:00.000000000 Z
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -59,6 +59,38 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: s3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: heroku-api
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
62
94
  description: Generate ActiveAdmin projects
63
95
  email:
64
96
  - stefano.verna@welaika.com
@@ -68,6 +100,8 @@ extensions: []
68
100
  extra_rdoc_files: []
69
101
  files:
70
102
  - .gitignore
103
+ - Gemfile
104
+ - Gemfile.lock
71
105
  - README.md
72
106
  - Rakefile
73
107
  - activeadmin-generator.gemspec
@@ -82,7 +116,6 @@ files:
82
116
  - lib/active_admin/generator/bricks/frontend.rb
83
117
  - lib/active_admin/generator/bricks/git.rb
84
118
  - lib/active_admin/generator/bricks/heroku.rb
85
- - lib/active_admin/generator/bricks/s3.rb
86
119
  - lib/active_admin/generator/cli.rb
87
120
  - lib/active_admin/generator/templates/app/assets/fonts/.empty_directory
88
121
  - lib/active_admin/generator/templates/app/assets/images/.empty_directory
File without changes