alex 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3906c307b29edebc0658926986d560a9165a1b85
4
+ data.tar.gz: 1138d4a226087f6c4cd714b17cd01b5c1f69d70c
5
+ SHA512:
6
+ metadata.gz: 3c2e5b40467dba696925e57a7ef9f7a905c3dae6347ed76719ec0772618c790632dfecbeb2d21f360d2ca29f559ef4e3343a53c1a1b88505c3e9caefbe7501f2
7
+ data.tar.gz: 6f07992fe7b91b064892793cd25c214ff85c222e9ed0fabf119e14e05757846329b2a45c511976aa979d4dead788e3f47d0aabce849b19ea8c6a86a7b7e6cfa9
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alex.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Juan Gesino
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # Alex
2
+
3
+ Alex is a Ruby on Rails template generator. Alex asks the user some questions to generate the templates and then applies the template to the new app.
4
+
5
+ ## Installation
6
+ First, make sure you have Ruby installed.
7
+
8
+ **On a Mac**, open `/Applications/Utilities/Terminal.app` and type:
9
+
10
+ ruby -v
11
+
12
+ If the output looks something like this, you're in good shape:
13
+
14
+ ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin13.0.0]
15
+
16
+ If the output looks more like this, you need to [install Ruby][ruby]:
17
+ [ruby]: https://www.ruby-lang.org/en/downloads/
18
+
19
+ ruby: command not found
20
+
21
+ **On Linux**, for Debian-based systems, open a terminal and type:
22
+
23
+ sudo apt-get install ruby-dev
24
+
25
+ or for Red Hat-based distros like Fedora and CentOS, type:
26
+
27
+ sudo yum install ruby-devel
28
+
29
+ (if necessary, adapt for your package manager)
30
+
31
+ **On Windows**, you can install Ruby with [RubyInstaller][].
32
+ [rubyinstaller]: http://rubyinstaller.org/downloads/
33
+
34
+ Once you've verified that Ruby is installed:
35
+
36
+ gem install alex
37
+
38
+ ## Usage
39
+
40
+ To start the wizard just run:
41
+
42
+ alex new APPNAME
43
+
44
+
45
+ Then you need to run the alex initialization. Navigate to the new app:
46
+
47
+ cd APPNAME/
48
+
49
+ And run:
50
+
51
+
52
+ alex init
53
+
54
+
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/juangesino/alex/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'alex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alex"
8
+ spec.version = Alex::VERSION
9
+ spec.authors = ["Juan I. Gesino"]
10
+ spec.email = ["juangesino@gmail.com"]
11
+ spec.summary = %q{Alex Command-line tool.}
12
+ spec.description = %q{Alex is a Ruby on Rails template generator. Alex asks the user some questions to generate the templates and then applies the template to the new app.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.executables << 'alex'
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'thor', "~> 0.19.1"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+
27
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'alex'
4
+
5
+ Alex::Cli.start( ARGV )
@@ -0,0 +1,8 @@
1
+ require "alex/version"
2
+ require "alex/cli"
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+
6
+ module Alex
7
+
8
+ end
@@ -0,0 +1,157 @@
1
+ require 'thor'
2
+ require 'fileutils'
3
+ require 'json'
4
+
5
+ module Alex
6
+ class Cli < Thor
7
+
8
+ desc "new APPNAME", "This will start the new app wizard"
9
+ long_desc <<-NEW_APP
10
+
11
+ `new APPNAME` will start the new app wizard creating a new app with the name of your choosing.
12
+
13
+ NEW_APP
14
+
15
+ def new( appname )
16
+
17
+ FileUtils.mkdir_p ".alex"
18
+ template_file = File.new(".alex/#{appname}.rb", 'w')
19
+
20
+ puts "Creating template file for new app `#{appname}`...\n"
21
+
22
+ puts "\nDatabase:\n"
23
+ puts "Using SQLite for development.\n"
24
+ db = ask("Which do you use for production?\n\n[0] PostgreSQL (default)\n[1] SQLite\n[2] None\n\n")
25
+ db = 0 if db.blank?
26
+
27
+ # puts "\nServer Type:\n"
28
+ # server_type = ask("Which type of server are you building?\n\n[0] WebServer (default)\n[1] API\n[2] WebServer + API\n\n")
29
+ # server_type = 0 if server_type.blank?
30
+
31
+ puts "\nDevise:\n"
32
+ if yes?("Would you like to install Devise?")
33
+ devise = true
34
+
35
+ devise_model_name = ask("What would you like the user model to be called? [user]")
36
+ devise_model_name = "user" if devise_model_name.blank?
37
+
38
+ if yes?("Would you like Devise's views?")
39
+ devise_views = true
40
+ else
41
+ devise_views = false
42
+ end
43
+
44
+ if yes?("Would you like to have UserRoles?")
45
+ user_roles = true
46
+ puts "\nCanCan:\n"
47
+ if yes?("Would you like to install CanCan to handle authorization?")
48
+ cancan = true
49
+ else
50
+ cancan = false
51
+ end
52
+ else
53
+ user_roles = false
54
+ end
55
+
56
+ puts "\nActiveAdmin:\n"
57
+ if yes?("Would you like to install ActiveAdmin?")
58
+ active_admin = true
59
+ else
60
+ active_admin = false
61
+ end
62
+
63
+ else
64
+ devise = false
65
+ end
66
+
67
+ puts "\nFigaro:\n"
68
+ if yes?("Would you like to install Figaro?")
69
+ figaro = true
70
+ else
71
+ figaro = false
72
+ end
73
+
74
+ options = OpenStruct.new({
75
+ :appname => appname,
76
+ :db => db,
77
+ # :server_type => server_type,
78
+ :devise => devise,
79
+ :devise_model_name => devise_model_name,
80
+ :devise_views => devise_views,
81
+ :user_roles => user_roles,
82
+ :cancan => cancan,
83
+ :active_admin => active_admin,
84
+ :figaro => figaro
85
+ })
86
+
87
+ init_file = "gsub_file \"Gemfile\", \"gem \\'spring\\'\", \"\"\n"
88
+
89
+ if options.devise
90
+ template_file.puts("gem 'devise'\n")
91
+ init_file = init_file + "generate \\'devise:install\\'\ngenerate \\'devise\\', \\'#{options.devise_model_name}\\'\n"
92
+
93
+ if options.devise_views
94
+ init_file = init_file + "generate \\'devise:views\\'\n"
95
+ end
96
+ end
97
+
98
+ if options.user_roles
99
+ init_file = init_file + "generate(:scaffold, \\'user_role\\',\\'name:string\\',\\'-c=scaffold_controller\\')\n"
100
+ init_file = init_file + "insert_into_file \\'app/models/user_role.rb\\', \"has_many :users\\n\", after: \"class UserRole < ActiveRecord::Base\\n\" \n"
101
+ init_file = init_file + "insert_into_file \\'app/models/user.rb\\', \"belongs_to :user_role\\n\", after: \"class User < ActiveRecord::Base\\n\" \n"
102
+ init_file = init_file + "generate(:migration, \\'AddUserRoleIdToUser\\',\\'user_role_id:integer\\')\n"
103
+ end
104
+
105
+ if options.cancan
106
+ template_file.puts("gem 'cancan'\n")
107
+ init_file = init_file + "generate \\'cancan:ability\\'\n"
108
+ end
109
+
110
+ if options.active_admin
111
+ template_file.puts("gem 'activeadmin'\n")
112
+ init_file = init_file + "generate \\'active_admin:install\\'\n"
113
+ init_file = init_file + "generate \\'active_admin:resource #{options.devise_model_name}\\'\n"
114
+ if options.user_roles
115
+ init_file = init_file + "generate \\'active_admin:resource user_role\\'\n"
116
+ end
117
+ end
118
+
119
+ if options.figaro
120
+ template_file.puts("gem 'figaro'\n")
121
+ init_file = init_file + "run \\'bundle exec figaro install\\'\n"
122
+ end
123
+
124
+ init_file = init_file + "rake \\'db:migrate\\'\n"
125
+ init_file = init_file + "git add: \\'.\\', commit: \\'-m \"initial commit\"\\'\n"
126
+ init_file = init_file + "gsub_file \"Gemfile\", \"gem \\'spring\\'\", \"\"\n"
127
+
128
+ if options.db.to_i == 0
129
+ template_file.puts("gsub_file 'Gemfile', \"gem \'sqlite3\'\", \"gem \'sqlite3\', group: :development\"\n")
130
+ template_file.puts("gem('pg', group: :production)\n")
131
+ elsif options.db.to_i == 1
132
+
133
+ else
134
+ template_file.puts("gsub_file 'Gemfile', \"gem \'sqlite3\'\", \"gem \'sqlite3\', group: :development\"\n")
135
+ end
136
+
137
+ template_file.puts("append_file '.gitignore', '.idea/'")
138
+ template_file.puts("git :init")
139
+ template_file.puts("create_file 'config/alex/init.rb', '#{init_file}'")
140
+ template_file.close
141
+
142
+ exec "rails new #{appname} -m .alex/#{appname}.rb"
143
+ end
144
+
145
+ desc "init", "This will run the initilization template of your app"
146
+ long_desc <<-INIT_APP
147
+
148
+ `init` will run the initilization template of your app.
149
+
150
+ INIT_APP
151
+
152
+ def init
153
+ exec "rake rails:template LOCATION=config/alex/init.rb"
154
+ end
155
+
156
+ end
157
+ end
@@ -0,0 +1,3 @@
1
+ module Alex
2
+ VERSION = "0.0.1"
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Juan I. Gesino
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Alex is a Ruby on Rails template generator. Alex asks the user some questions
56
+ to generate the templates and then applies the template to the new app.
57
+ email:
58
+ - juangesino@gmail.com
59
+ executables:
60
+ - alex
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - alex.gemspec
70
+ - bin/alex
71
+ - lib/alex.rb
72
+ - lib/alex/cli.rb
73
+ - lib/alex/version.rb
74
+ - templates/.keep
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Alex Command-line tool.
99
+ test_files: []