jinda 0.7.2 → 0.7.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +61 -42
  3. data/app/assets/stylesheets/images/gears.png +0 -0
  4. data/lib/generators/jinda/config_generator.rb +0 -1
  5. data/lib/generators/jinda/install_generator.rb +161 -133
  6. data/lib/generators/jinda/installer/gemfiles-org/custom_gems.rb +8 -0
  7. data/lib/generators/jinda/installer/gemfiles-org/dev_gems.rb +20 -0
  8. data/lib/generators/jinda/installer/gemfiles-org/runtime_gems.rb +30 -0
  9. data/lib/generators/jinda/installer/gemfiles-org/todo.md +3 -0
  10. data/lib/generators/jinda/installer/gems_install.rb +132 -0
  11. data/lib/generators/jinda/installer/test.rb +6 -0
  12. data/lib/generators/jinda/templates/README.md +2 -2
  13. data/lib/generators/jinda/templates/app/controllers/jinda_org/articles_controller.rb +3 -1
  14. data/lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb +1 -0
  15. data/lib/generators/jinda/templates/app/views/articles/_report.haml +8 -5
  16. data/lib/generators/jinda/templates/app/views/articles/show.html.haml +52 -40
  17. data/lib/generators/jinda/templates/app/views/docs/doc_new/doc_form.html.erb +21 -15
  18. data/lib/generators/jinda/templates/app/views/users/user/enter_user.html.erb +2 -0
  19. data/lib/generators/jinda/templates/spec/controllers/sessions_controller_spec.rb +7 -5
  20. data/lib/generators/jinda/templates/spec/features/userlogins_spec.rb +2 -2
  21. data/lib/generators/jinda/templates/spec/rails_helper.rb +0 -2
  22. data/lib/generators/jinda/templates/spec/spec_helper.rb +6 -3
  23. data/lib/generators/jinda/templates/spec/support/databasecleaner.rb +13 -0
  24. data/lib/jinda/themes.rb +166 -154
  25. data/lib/jinda/version.rb +1 -1
  26. data/lib/tasks/jinda.rake +14 -5
  27. metadata +29 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faef5ea06cc850bbbf7ebb2b1f8d3ac4e59688d0b5197c124bc4ca525b2ce466
4
- data.tar.gz: f84ac716bb2ae580fcfeda5178544f7809440ae998c1f0cd263bbdfd5f58e1ae
3
+ metadata.gz: ee2a5a7ffea60abcbb7b1a2e7fac2fd16cd90f4aa77887eafa3363c66f677cc6
4
+ data.tar.gz: 61a2f45ac00392816e11fab72d79dd6c162b8cade1ea46740ce9eaeb64c539f6
5
5
  SHA512:
6
- metadata.gz: 1ab17b915d572b178f1d709037c9b1af2ed64db23b14d8cb36d68c1c010bb0e75dabcc8c1e1172acc628826f591ee4ef4278137191a53bfe1c0454b42858f274
7
- data.tar.gz: 1404b46acb45165bccd3087926380ee9bf986edee9f8726691a5037ef25504b7b3b56d6ab3e467e752d9e2ac506a0d7e5d6198b1db07c795a2fc13210e1e4e13
6
+ metadata.gz: 4e703d4c8fcd6aed9b09a4e51b75c1418b86e850ee2177094a177cd2e9360bf967fad78141d59b59e42e075286a8ebc1a523abacca157d557255d3632adfd51a
7
+ data.tar.gz: d17fdccc2c4787d1cd8dff612c310ec39a07139ac7e8a03311c7ddf7ca2713f95d7177eeb42afb788fa8c15a610c75f03545cfe83d99d93bea668e233f09637b
data/README.md CHANGED
@@ -1,37 +1,62 @@
1
1
  # Jinda
2
- Rails Application Generator using Freemind
3
- * [jinda](https://github.com/kul1/jinda)
4
- -![Screen Shot 2019-09-07 at 1 00 03 PM](https://user-images.githubusercontent.com/3953832/64478408-f5feb500-d175-11e9-9d07-8b41f3c47924.png)
5
2
 
6
- ## Additional Extension themes also available at
7
- * [jinda_adminlte](https://github.com/kul1/jinda_adminlte)
3
+ Jinda is a gem to create Rails Workflow & Application Generator using Freemind
4
+
5
+ Jinda is a tools for Ruby on Rails developer. (Required: basic Ruby on Rails )
6
+
7
+ ## Jinda use the following technologies:
8
+
9
+ - JQuery Mobile and Bootstrap as Javascript front-end development framework
10
+ - Rails Engine as Jinda core for router, helper
11
+ - Workflow using Freemind design as XML to control Rails flow.
12
+ - User authentication for login and role for each activity
13
+ - Support Social authentication: Facebook, Google
14
+ - Polymorphic Association in mongodb
15
+ - Dynamic role for user and group
16
+ - Rails concern & mixins for rails modules and class
17
+ - Sample app: Articles, API Note, Document
18
+ - Support themes: Jinda_adminlte, Jinda_adminBSB
19
+ - Support HTML, HAML, SCSS
20
+ <br />
21
+
22
+ - [jinda](https://github.com/kul1/jinda) -![Screen Shot 2019-09-07 at 1 00 03 PM](https://user-images.githubusercontent.com/3953832/64478408-f5feb500-d175-11e9-9d07-8b41f3c47924.png)
23
+
24
+ ## Additional Extension themes also available at
25
+
26
+ - [jinda_adminlte](https://github.com/kul1/jinda_adminlte)
27
+
8
28
  - ![j18-screen](https://user-images.githubusercontent.com/3953832/34298172-faa7e962-e6e1-11e7-93e2-19dfd4ab42af.png)
9
29
 
10
- * [jinda_adminbsb](https://github.com/kul1/jinda_adminbsb)
30
+ - [jinda_adminbsb](https://github.com/kul1/jinda_adminbsb)
11
31
  - ![jinda-bsb](https://user-images.githubusercontent.com/3953832/34320779-bb0980d2-e7c6-11e7-855c-fafc23487ba5.png)
12
32
 
13
33
  ## Prerequisites
14
34
 
15
35
  These versions works for sure but others may do.
16
36
 
17
- * Ruby 2.7.1
18
- * Rails 6.1.0
19
- * MongoDB 6
20
- * Freemind 1.0.1
37
+ - Ruby 3.0.0
38
+ - Rails 6.1.3
39
+ - MongoDB 6
40
+ - Freemind 1.0.1
21
41
 
22
42
  ## Convention
23
43
 
24
- * database is MongoDB
25
- * images stored in upload directory, unset IMAGE_LOCATION in `initializer/jinda.rb` to use Cloudinary
26
- * mail use Gmail SMTP, config in `config/application.rb`
27
- * authentication use omniauth-identity
44
+ - database is MongoDB
45
+ - images stored in upload directory, unset IMAGE_LOCATION in `initializer/jinda.rb` to use Cloudinary
46
+ - mail use Gmail SMTP, config in `config/application.rb`
47
+ - authentication use omniauth-identity
28
48
 
29
49
  ## Sample Application
50
+
30
51
  ### Screen shot install Jinda
31
- * https://www.youtube.com/watch?v=XUXv7Yrskjk&feature=youtu.be
52
+
53
+ [![yt_logo_rgb_light](https://user-images.githubusercontent.com/3953832/110579381-4fa9bc00-812c-11eb-973e-da9d0f2a8109.png)](https://www.youtube.com/watch?v=XUXv7Yrskjk&feature=youtu.be)
54
+ <br />
55
+ [![ Jinda Install](https://i9.ytimg.com/vi/XUXv7Yrskjk/mq3.jpg?sqp=CPjUoIIG&rs=AOn4CLBfMkmMtOGz3OfUp2zyhMs3Dy9xrw)](https://www.youtube.com/watch?v=XUXv7Yrskjk&feature=youtu.be)
56
+
32
57
  ### Sample Jinda in Docker
33
58
 
34
- * https://github.com/kul1/b-255523-jd
59
+ - https://github.com/kul1/b-255523-jd
35
60
 
36
61
  Supposed we want to create ecommerce web site, first create a Rails
37
62
  app without ActiveRecord
@@ -40,7 +65,7 @@ app without ActiveRecord
40
65
 
41
66
  ## Add jinda to your Gemfile:
42
67
 
43
- gem 'jinda', '~> 0.7.0.1'
68
+ gem 'jinda'
44
69
 
45
70
  For Development (most updated)
46
71
 
@@ -62,8 +87,6 @@ Then run bundle again to install additional gems added by jinda
62
87
 
63
88
  $ bundle
64
89
 
65
- (or run all with "sh install.sh" )
66
-
67
90
  configure mongoid, omniauth
68
91
 
69
92
  $ rails generate jinda:config
@@ -76,7 +99,7 @@ now the application is ready, start it as any Rails application
76
99
 
77
100
  $ rails server
78
101
 
79
- go to http://localhost:3000, click *Sign In* on the left menu, and enter user name `admin` and password `secret`
102
+ go to http://localhost:3000, click _Sign In_ on the left menu, and enter user name `admin` and password `secret`
80
103
 
81
104
  ![login](https://user-images.githubusercontent.com/3953832/41832924-d868f8f0-7813-11e8-93bb-19c0357cf604.png)
82
105
 
@@ -86,9 +109,9 @@ Now open file `app/jinda/index.mm` using Freemind
86
109
 
87
110
  The 3 main branches are
88
111
 
89
- * models - this defines all the models to use in the application
90
- * services - this defines services which will be come the menu on the left of the screen. There will be 2 levels; the first sub branch is the main menu (modules) and the second sub branch is the sub menu (services)
91
- * roles - this defines role for all users
112
+ - models - this defines all the models to use in the application
113
+ - services - this defines services which will be come the menu on the left of the screen. There will be 2 levels; the first sub branch is the main menu (modules) and the second sub branch is the sub menu (services)
114
+ - roles - this defines role for all users
92
115
 
93
116
  ### models
94
117
 
@@ -98,12 +121,12 @@ Fiirst, we need to create some product so we click on models we'll see 2 models
98
121
 
99
122
  The first sub branch (e.g. person) is the model name. According to Rails convention, this should be a singular word. The next sub branch are columns in the database. Let's take a look at each:
100
123
 
101
- * `fname` - this create a column (field) called fname which is a String by default
102
- * `sex: integer` - this create a column called sex, it is integer so must be explicity defined. The next sub branch (1: male) is disregarded by Jinda so we can put whatever we want. Here I just put some reminder.
103
- * `belongs_to :address` - here we have ![pen](https://cloud.githubusercontent.com/assets/3953832/25600038/3a4ffb66-2f0b-11e7-9f03-b875e550eefe.png)
104
- icon. this means whatever text on this line will be added as is to the model Jinda generates. You use this to specify anything you want such as association, index, remarks in code, etc. according to mongoid gem. To draw the icon, rest mouse on the branch and hit &ltAlt-I&gt.
105
- * `dob: date` - use any type that mongoid provides.
106
- * `photo` - for file field, just use String here. Jinda will receive the binary file and store in file system or cloudinary then generate a url link to it.
124
+ - `fname` - this create a column (field) called fname which is a String by default
125
+ - `sex: integer` - this create a column called sex, it is integer so must be explicity defined. The next sub branch (1: male) is disregarded by Jinda so we can put whatever we want. Here I just put some reminder.
126
+ - `belongs_to :address` - here we have ![pen](https://cloud.githubusercontent.com/assets/3953832/25600038/3a4ffb66-2f0b-11e7-9f03-b875e550eefe.png)
127
+ icon. this means whatever text on this line will be added as is to the model Jinda generates. You use this to specify anything you want such as association, index, remarks in code, etc. according to mongoid gem. To draw the icon, rest mouse on the branch and hit &ltAlt-I&gt.
128
+ - `dob: date` - use any type that mongoid provides.
129
+ - `photo` - for file field, just use String here. Jinda will receive the binary file and store in file system or cloudinary then generate a url link to it.
107
130
 
108
131
  In this example we just want a product model, so delete the person and address model and add a product branch like so
109
132
 
@@ -113,7 +136,7 @@ Save the mind map then run:
113
136
 
114
137
  rake jinda:update
115
138
 
116
- This will create file `app/models/product.rb`. In this file, note the comment lines `# jinda begin` and ` # jinda end`. Everything inside these comments will get overwritten when you change the models branch in the mind map so if you need to put anything inside here, use the mind map instead. You can add anything outside these comment lines which will be preserved when doing jinda:update.
139
+ This will create file `app/models/product.rb`. In this file, note the comment lines `# jinda begin` and ` # jinda end`. Everything inside these comments will get overwritten when you change the models branch in the mind map so if you need to put anything inside here, use the mind map instead. You can add anything outside these comment lines which will be preserved when doing jinda:update.
117
140
 
118
141
  ### services
119
142
 
@@ -123,34 +146,31 @@ Next we'll add some product into the database, we'll first take a look at the se
123
146
 
124
147
  The text `users:User` on the sub branch has these implications:
125
148
 
126
- * `users` correspond to `app/controllers/users_controller.rb` which already exist when you do rails generate jinda:install. New branch will create new controller if not exist. In Jinda term, this will be called module.
127
- * `User` will create entry in main menu on the left of the screen. You don't see it in the screenshot above because it's controlled by the sub branch `role:m` which means this menu only available for login member. If you already signed in as admin, you should see it now.
149
+ - `users` correspond to `app/controllers/users_controller.rb` which already exist when you do rails generate jinda:install. New branch will create new controller if not exist. In Jinda term, this will be called module.
150
+ - `User` will create entry in main menu on the left of the screen. You don't see it in the screenshot above because it's controlled by the sub branch `role:m` which means this menu only available for login member. If you already signed in as admin, you should see it now.
128
151
 
129
152
  The next sub branches has the following:
130
153
 
131
- * `role: m` - means that this module (menu) is available only to user who has role m (if you open the role branch now will see that role m is member). All registered user has role m by default. User who is not log on would not be able to access this module.
132
- * `link:info: /users` - means that this is a link, the format is link: *submenu label* : *url* where submenu label is the text to show in the submenu and url is the link to go to, in this case, it woud go to http://localhost:3000/users which will perform index action of UsersController.
133
- * `user:edit` the branch that do not start with role:, rule:, nor link: will be a Jinda service. You will then specify the sequence of the execution as in this example there are 3 sub branches - enter_user, update_user, and rule:login? Let's take a look at them:
154
+ - `role: m` - means that this module (menu) is available only to user who has role m (if you open the role branch now will see that role m is member). All registered user has role m by default. User who is not log on would not be able to access this module.
155
+ - `link:info: /users` - means that this is a link, the format is link: _submenu label_ : _url_ where submenu label is the text to show in the submenu and url is the link to go to, in this case, it woud go to http://localhost:3000/users which will perform index action of UsersController.
156
+ - `user:edit` the branch that do not start with role:, rule:, nor link: will be a Jinda service. You will then specify the sequence of the execution as in this example there are 3 sub branches - enter_user, update_user, and rule:login? Let's take a look at them:
134
157
 
135
- * `enter_user:edit` - the first step is to display a form to input user information, this is accompanied by icon ![image](https://cloud.githubusercontent.com/assets/3953832/25599946/47c32cf6-2f0a-11e7-80a8-2c02c6294c9a.png)
136
- which means user interface screen. and will correspond to a view file `app/views/users/user/enter_user.html.erb` where `/users` comes from the module name (the sub branch of services), `/user` comes from the service name (the sub branch of users), and `enter_user.html.erb` comes from the first part of this branch. The `edit` after the colon is just a description of this step. This branch also has sub branch `rule:login? && own_xmain?` which specify rule for this step that the user must be login and can continue this task if he is the one who started it. *task* in here means each instance of service.
137
- * `update_user` - this icon ![image](https://cloud.githubusercontent.com/assets/3953832/25599976/87b69ad2-2f0a-11e7-9aba-1bd4e9546d3e.png) means to execute method update_user within `users_controller.rb`
158
+ - `enter_user:edit` - the first step is to display a form to input user information, this is accompanied by icon ![image](https://cloud.githubusercontent.com/assets/3953832/25599946/47c32cf6-2f0a-11e7-80a8-2c02c6294c9a.png)
159
+ which means user interface screen. and will correspond to a view file `app/views/users/user/enter_user.html.erb` where `/users` comes from the module name (the sub branch of services), `/user` comes from the service name (the sub branch of users), and `enter_user.html.erb` comes from the first part of this branch. The `edit` after the colon is just a description of this step. This branch also has sub branch `rule:login? && own_xmain?` which specify rule for this step that the user must be login and can continue this task if he is the one who started it. _task_ in here means each instance of service.
160
+ - `update_user` - this icon ![image](https://cloud.githubusercontent.com/assets/3953832/25599976/87b69ad2-2f0a-11e7-9aba-1bd4e9546d3e.png) means to execute method update_user within `users_controller.rb`
138
161
 
139
162
  Armed with this knowledge, we are ready to add new product into our application like so:
140
163
 
141
164
  ![add_enter](https://cloud.githubusercontent.com/assets/3953832/25600158/582d1fbe-2f0c-11e7-9bde-01a195a45b6c.png)
142
165
 
143
-
144
166
  To generate controller and views we save this mind map and run
145
167
 
146
168
  rake jinda:update
147
169
 
148
170
  open file `app/views/products/add/enter.html.erb` you'll see some sample view already in there but commented. edit the file so it look like this
149
171
 
150
-
151
172
  ![product_enter](https://cloud.githubusercontent.com/assets/3953832/25600363/e5cc8282-2f0d-11e7-81f7-273c9bdc1a63.png)
152
173
 
153
-
154
174
  Note that we do not specify form_tag and submit_tag, these will be supplied by Jinda.
155
175
 
156
176
  then open file `app/controllers/products_controller.rb` and add `create` method as follow. The method name has to be correspond to the ![bookmark](http://songrit.googlecode.com/files/bookmark.png) branch.
@@ -167,7 +187,6 @@ run following command:
167
187
 
168
188
  ![rspec](https://user-images.githubusercontent.com/3953832/34680352-7931d426-f45e-11e7-9f40-8b85b94c61bf.png)
169
189
 
170
-
171
190
  ## Contributing
172
191
 
173
192
  1. Fork it
@@ -43,7 +43,6 @@ module Jinda
43
43
  end
44
44
  end
45
45
 
46
-
47
46
  desc "Set up mongoid config"
48
47
  def setup_mongoid
49
48
  generate "mongoid:config"
@@ -5,68 +5,143 @@ module Jinda
5
5
  def self.source_root
6
6
  File.dirname(__FILE__) + "/templates"
7
7
  end
8
-
9
8
  def setup_gems
10
- gem 'maruku', '~> 0.7.3'
11
- gem 'rouge'
12
- gem 'normalize-rails'
13
- gem 'font-awesome-rails'
14
- gem 'font-awesome-sass', '~> 5.12.0'
15
- gem 'mongoid-paperclip', require: 'mongoid_paperclip'
16
- gem 'meta-tags'
17
- gem 'jquery-turbolinks', '2.1.0'
18
- gem 'mongo', '2.11.3'
19
- gem 'bson', '4.4.2'
20
- gem 'mongoid', git: 'git@github.com:kul1/mongoid.git'
21
- gem 'turbolinks_render'
22
- gem 'nokogiri', '~> 1.11.0'
23
- gem 'haml', '~> 5.1', '>= 5.1.2'
24
- gem 'haml-rails', '~> 2.0.1'
25
- gem 'mail'
26
- gem 'prawn'
27
- gem 'redcarpet'
28
- gem 'bcrypt'
29
- gem 'oauth2', '1.4.4'
30
- gem 'omniauth', '1.9.1'
31
- gem 'omniauth-oauth2', '1.6.0'
32
- gem 'omniauth-identity', '~> 1.1.1'
33
- gem 'omniauth-facebook', '6.0.0'
34
- gem 'omniauth-google-oauth2', '0.8.0'
35
- gem 'dotenv-rails'
36
- gem 'cloudinary', '1.13.2'
37
- gem 'kaminari', '1.2.0'
38
- gem 'kaminari-mongoid', '1.0.1'
39
- gem 'jquery-rails', '4.3.5'
40
- gem_group :development, :test do
41
- gem 'shoulda'
42
- gem 'rspec'
43
- gem 'rspec-rails'
44
- gem 'better_errors'
45
- gem 'binding_of_caller'
46
- gem 'pry-byebug'
47
- gem 'factory_bot_rails'
48
- gem 'database_cleaner'
49
- gem 'guard'
50
- gem 'guard-rspec'
51
- gem 'guard-minitest'
52
- gem 'capybara'
53
- gem 'selenium-webdriver'
54
- gem 'rb-fsevent'
55
- gem 'valid_attribute'
56
- gem 'faker'
9
+ # define required gems: jinda_gem, jinda_dev_gem
10
+ jinda_gem =
11
+ [
12
+ ["bson", "4.4.2"],
13
+ ["maruku", "~> 0.7.3"],
14
+ ["bcrypt"],
15
+ ["rouge"],
16
+ ["normalize-rails"],
17
+ ["font-awesome-rails"],
18
+ ["font-awesome-sass", "~> 5.12.0"],
19
+ ["meta-tags"],
20
+ ["jquery-turbolinks", "2.1.0"],
21
+ ["mongo", "2.11.3"],
22
+ ["turbolinks_render"],
23
+ ["haml-rails", "~> 2.0.1"],
24
+ ["haml", "~> 5.1", ">= 5.1.2"],
25
+ ["mail"],
26
+ ["prawn"],
27
+ ["redcarpet"],
28
+ ["oauth2", "1.4.4"],
29
+ ["omniauth", "1.9.1"],
30
+ ["omniauth-oauth2", "1.6.0"],
31
+ ["omniauth-identity", "~> 1.1.1"],
32
+ ["omniauth-facebook", "6.0.0"],
33
+ ["omniauth-google-oauth2", "0.8.0"],
34
+ ["dotenv-rails"],
35
+ ["cloudinary", "1.13.2"],
36
+ ["kaminari", "1.2.0"],
37
+ ["jquery-rails", "4.3.5"],
38
+ ["mongoid"],
39
+ ["rexml", "~> 3.2.4"]
40
+
41
+ ]
42
+
43
+ jinda_custom =
44
+ [
45
+ ["mongoid-paperclip", require: "mongoid_paperclip"],
46
+ ["kaminari-mongoid", "1.0.1"],
47
+ ["nokogiri", "~> 1.11.0"]
48
+ ]
49
+
50
+ jinda_dev_gem =
51
+ [
52
+ ["shoulda"],
53
+ ["rspec"],
54
+ ["rspec-rails"],
55
+ ["better_errors"],
56
+ ["binding_of_caller"],
57
+ ["pry-byebug"],
58
+ ["factory_bot_rails"],
59
+ ["database_cleaner-mongoid"],
60
+ ["guard"],
61
+ ["guard-rspec"],
62
+ ["guard-minitest"],
63
+ ["capybara"],
64
+ ["selenium-webdriver"],
65
+ ["rb-fsevent"],
66
+ ["valid_attribute"],
67
+ ["faker"]
68
+ ]
69
+
70
+ # Check each jinda_gem and create new array if found one otherwise just create.
71
+ # Open Gemfile add gem if not exist
72
+ jinda_gem.each do |g|
73
+ unless (%x(gem list -e --no-versions #{g[0]})) == "#{g[0]}\n"
74
+ if g.count == 2
75
+ gem g[0], g[1]
76
+ else
77
+ gem g[0]
78
+ end
79
+ else
80
+ if g.count == 2
81
+ xgem_0 = %x(gem list -e #{g[0]})
82
+ unless xgem_0.include?(("#{g[1]}").gsub(/[~> ]/, ''))
83
+ say " Found existing #{xgem_0} in Gemfile or System, Please edit Gemfile", :red
84
+ gem g[0], g[1]
85
+ else
86
+ say " Checking #{g[0]} found Ver. #{g[1]} already exist in Gemfile", :green
87
+ end
88
+ end
89
+ say " SKIP adding #{g[0]} in Gemfile", :yellow
90
+ end
91
+ end
92
+
93
+ # create list of gem in sub-group dev and test
94
+ jinda_dev_new = Array.new
95
+ jinda_dev_gem.each do |g|
96
+ unless (%x(gem list -e --no-versions #{g[0]})) == "#{g[0]}\n"
97
+ jinda_dev_new << g
98
+ else
99
+ say " #{g[0]} already exist in Gemfile", :yellow
100
+ end
101
+ end
102
+ unless jinda_dev_new.count == 0
103
+ gem_group :development, :test do
104
+ jinda_dev_new.each do |n|
105
+ if n.count == 1
106
+ gem n[0]
107
+ else
108
+ gem n[0], n[1]
109
+ end
110
+ end
111
+ end
57
112
  end
58
- end
59
113
 
114
+ # create list of custom gem
115
+ jinda_custom_new = Array.new
116
+ jinda_custom.each do |g|
117
+ unless (%x(gem list -e --no-versions #{g[0]})) == "#{g[0]}\n"
118
+ jinda_custom_new << g
119
+ else
120
+ say " #{g[0]} already exist in Gemfile", :yellow
121
+ end
122
+ end
123
+ unless jinda_custom_new.count == 0
124
+ jinda_custom_new.each do |c|
125
+ say " Checking if #{c[0]} already exist in Gemfile", :yellow
126
+ if c.count == 1
127
+ gem c[0]
128
+ else
129
+ gem c[0], c[1]
130
+ end
131
+ end
132
+ end
133
+
134
+ end
60
135
  def setup_app
61
136
  # inside("public") { run "FileUtils.mv index.html index.html.bak" }
62
- inside("db") {(File.file? "seeds.rb") ? (FileUtils.mv "seeds.rb", "seeds.rb.bak") : ( say "no seeds.rb", :green)}
137
+ inside("db") {(File.file? "seeds.rb") ? (FileUtils.mv "seeds.rb", "seeds.rb.bak") : ( say "no seeds.rb", :green)}
63
138
  inside("app/views/layouts") {(File.file? "application.html.erb") ? (FileUtils.mv 'application.html.erb', 'application.html.erb.bak') : ( say "no app/views/layout/ application.html.erb", :blue )}
64
139
  inside("app/controllers") {(File.file? "application_controller.rb") ? (FileUtils.mv 'application_controller.rb', 'application_controller.rb.bak' ) : ( say "no app/controller/application_controller.rb, :blue ")}
65
140
  inside("app/helpers") {(File.file? "application_helper.rb") ? (FileUtils.mv 'application_helper.rb', 'application_helper.rb.bak') : ( say "no app/helpers/application_helper.rb", :blue)}
66
141
  inside("app/assets/javascripts") {(File.file? 'application.js') ? (FileUtils.mv 'application.js', 'application.js.bak') : ( say "no application.js", :blue)}
67
142
  inside("app/assets/stylesheets") {(File.file? "application.css") ? (FileUtils.mv 'application.css', 'application.css.bak') : ( say "no application.css", :blue)}
68
143
  inside("config/initializers") {(File.file? "omniauth.rb") ? (FileUtils.mv 'omniauth.rb', 'omniauth.rb.bak') : (say "no omniauth.rb", :blue)}
69
- # inside("config/initializers") {(File.file? "mongoid.rb") ? (FileUtils.mv 'mongoid.rb', 'mongoid.rb.bak') : (say "no mongoid.rb")}
144
+ inside("config/initializers") {(File.file? "mongoid.rb") ? (FileUtils.mv 'mongoid.rb', 'mongoid.rb.bak') : (say "no mongoid.rb")}
70
145
  inside("app/assets/config") {(File.file? "manifest.js") ? (FileUtils.mv "manifest.js", "manifest.js-rails") : (puts "backup to manifest.js-rails")}
71
146
  directory "app"
72
147
  directory "spec"
@@ -79,79 +154,32 @@ module Jinda
79
154
  # inside("app/assets/javascripts") {(File.file? "application.js") ? ( say "Please include application-org.js in application.js", :red) : (FileUtils.mv 'application-org.js', 'application.js')}
80
155
  # inside("app/assets/stylesheets") {(File.file? "application.css") ? ( say "Please include application-org.css in application.css", :red) : (FileUtils.mv 'application-org.css', 'application.css')}
81
156
  # inside("app/assets/stylesheets") {(File.file? "application.css.scss") ? ( say "Please include application-org.css.scss in application.css.scss", :red) : (FileUtils.mv 'application-org.css.scss', 'application.css.scss')}
82
- inside("app/controllers") {(File.file? "admins_controller.rb") ? ( say "Please merge existing jinda_org/admins_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/admins_controller.rb', 'admins_controller.rb')}
83
- inside("app/controllers") {(File.file? "articles_controller.rb") ? ( say "Please merge existing jinda_org/articles_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/articles_controller.rb', 'articles_controller.rb')}
84
- inside("app/controllers") {(File.file? "comments_controller.rb") ? ( say "Please merge existing jinda_org/comments_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/comments_controller.rb', 'comments_controller.rb')}
85
- inside("app/controllers") {(File.file? "docs_controller.rb") ? ( say "Please merge existing jinda_org/docs_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/docs_controller.rb', 'docs_controller.rb')}
86
- inside("app/controllers") {(File.file? "identities_controller.rb") ? ( say "Please merge existing jinda_org/identities_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/identities_controller.rb', 'identities_controller.rb')}
87
- inside("app/controllers") {(File.file? "application_controller.rb") ? ( say "Pleas merge existing jinda_org/application_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/application_controller.rb', 'application_controller.rb')}
157
+ inside("app/controllers") {(File.file? "admins_controller.rb") ? ( say " Please merge existing jinda_org/admins_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/admins_controller.rb', 'admins_controller.rb')}
158
+ inside("app/controllers") {(File.file? "articles_controller.rb") ? ( say " Please merge existing jinda_org/articles_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/articles_controller.rb', 'articles_controller.rb')}
159
+ inside("app/controllers") {(File.file? "comments_controller.rb") ? ( say " Please merge existing jinda_org/comments_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/comments_controller.rb', 'comments_controller.rb')}
160
+ inside("app/controllers") {(File.file? "docs_controller.rb") ? ( say " Please merge existing jinda_org/docs_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/docs_controller.rb', 'docs_controller.rb')}
161
+ inside("app/controllers") {(File.file? "identities_controller.rb") ? ( say " Please merge existing jinda_org/identities_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/identities_controller.rb', 'identities_controller.rb')}
162
+ inside("app/controllers") {(File.file? "application_controller.rb") ? ( say " Pleas merge existing jinda_org/application_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/application_controller.rb', 'application_controller.rb')}
88
163
  ## Moved to Engine
89
- # inside("app/controllers") {(File.file? "jinda_controller.rb") ? ( say "Please merge existing jinda_org/jinda_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/jinda_controller.rb', 'jinda_controller.rb')}
90
- inside("app/controllers") {(File.file? "password_resets_controller.rb") ? ( say "Please merge existing jinda_org/password_resets_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/password_resets_controller.rb', 'password_resets_controller.rb')}
91
- inside("app/controllers") {(File.file? "password_resets.rb") ? ( say "Please merge existing jinda_org/password_resets.rb after this installation", :red) : (FileUtils.mv 'jinda_org/password_resets.rb', 'password_resets.rb')}
92
- inside("app/controllers") {(File.file? "sessions_controller.rb") ? ( say "Please merge existing jinda_org/sessions_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/sessions_controller.rb', 'sessions_controller.rb')}
93
- inside("app/controllers") {(File.file? "users_controller.rb") ? ( say "Please merge existing jinda_org/users_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/users_controller.rb', 'users_controller.rb')}
94
- inside("app/controllers") {(File.file? "sitemap_controller.rb") ? ( say "Please merge existing jinda_org/sitemap_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/sitemap_controller.rb', 'sitemap_controller.rb')}
95
- inside("app/controllers") {(File.file? "notes_controller.rb") ? ( say "Please merge existing jinda_org/notes_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/notes_controller.rb', 'notes_controller.rb')}
164
+ # inside("app/controllers") {(File.file? "jinda_controller.rb") ? ( say " Please merge existing jinda_org/jinda_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/jinda_controller.rb', 'jinda_controller.rb')}
165
+ inside("app/controllers") {(File.file? "password_resets_controller.rb") ? ( say " Please merge existing jinda_org/password_resets_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/password_resets_controller.rb', 'password_resets_controller.rb')}
166
+ inside("app/controllers") {(File.file? "password_resets.rb") ? ( say " Please merge existing jinda_org/password_resets.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/password_resets.rb', 'password_resets.rb')}
167
+ inside("app/controllers") {(File.file? "sessions_controller.rb") ? ( say " Please merge existing jinda_org/sessions_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/sessions_controller.rb', 'sessions_controller.rb')}
168
+ inside("app/controllers") {(File.file? "users_controller.rb") ? ( say " Please merge existing jinda_org/users_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/users_controller.rb', 'users_controller.rb')}
169
+ inside("app/controllers") {(File.file? "sitemap_controller.rb") ? ( say " Please merge existing jinda_org/sitemap_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/sitemap_controller.rb', 'sitemap_controller.rb')}
170
+ inside("app/controllers") {(File.file? "notes_controller.rb") ? ( say " Please merge existing jinda_org/notes_controller.rb after this installation", :yellow) : (FileUtils.mv 'jinda_org/notes_controller.rb', 'notes_controller.rb')}
96
171
  end
97
172
  # routes created each line as reversed order in routes
98
173
  # Moved routes to Engine
99
174
  def setup_routes
100
- # route "end"
101
- # route " end"
102
- # route " namespace :v1 do resources :notes, :only => [:index] end"
103
- # route " namespace :api do"
104
- # route "post '/api/v1/notes' => 'api/v1/notes#create', as: 'api_v1_notes'"
105
- # route "get '/api/v1/notes/my' => 'api/v1/notes#my'"
106
- # route "\# api"
107
175
  route "root :to => 'jinda#index'"
108
- # route "resources :jinda, :only => [:index, :new]"
109
- # route "resources :password_resets"
110
- # route "resources :sessions"
111
- # route "resources :identities"
112
- # route "resources :users"
113
- # route "resources :docs"
114
- # route "resources :notes"
115
- # route "resources :comments"
116
- # route "resources :articles do resources :comments end"
117
- # route "get '/jinda/document/:id' => 'jinda#document'"
118
- # route "get '/notes/destroy/:id' => 'notes#destroy'"
119
- # route "get '/notes/my/destroy/:id' => 'notes#destroy'"
120
- # route "get '/docs/my/destroy' => 'docs#destroy'"
121
- # route "get '/notes/my' => 'notes/my'"
122
- # route "get '/docs/my' => 'docs/my'"
123
- # route "get '/articles/edit' => 'articles/edit'"
124
- # route "get '/articles/show' => 'articles/show'"
125
- # route "get '/articles/my/destroy' => 'articles#destroy'"
126
- # route "get '/articles/my' => 'articles#my'"
127
- # route "get '/logout' => 'sessions#destroy', :as => 'logout'"
128
- # route "get '/auth/failure' => 'sessions#destroy'"
129
- # route "get '/auth/:provider/callback' => 'sessions#create'"
130
- # route "post '/auth/:provider/callback' => 'sessions#create'"
131
- # route "\# end jinda method routes"
132
- # route "post '/jinda/end_output' => 'jinda#end_output'"
133
- # route "post '/jinda/end_form' => 'jinda#end_form'"
134
- # route "post '/jinda/pending' => 'jinda#index'"
135
- # route "post '/jinda/init' => 'jinda#init'"
136
- # route "jinda_methods.each do \|aktion\| get \"/jinda/\#\{aktion\}\" => \"jinda#\#\{aktion\}\" end"
137
- # route "jinda_methods += ['error_logs', 'notice_logs', 'cancel', 'run_output', 'end_output']"
138
- # route "jinda_methods += ['run_redirect', 'run_direct_to','run_if']"
139
- # route "jinda_methods += ['init', 'run', 'run_mail', 'document', 'run_do', 'run_form', 'end_form']"
140
- # route "jinda_methods = ['pending', 'status', 'search', 'doc', 'doc_print', 'logs', 'ajax_notice']"
141
- # route "\# start jiinda method routes"
142
- end
176
+ end
143
177
 
144
178
  def setup_env
145
179
  FileUtils.mv "README.md", "README.md.bak"
146
180
  create_file 'README.md', ''
147
- # FileUtils.mv 'install.sh', 'install.sh'
148
- # inject_into_file 'config/application.rb', :after => 'require "active_resource/railtie"' do
149
- # inject_into_file 'config/application.rb', :after => 'require "rails"' do
150
- # "\nrequire 'rexml/document'\n"+
151
- # "\nrequire 'mongoid/railtie'\n"
152
- # end
153
181
  application do
154
- %q{
182
+ %q{
155
183
  # Jinda default
156
184
  config.generators do |g|
157
185
  g.orm :mongoid
@@ -174,10 +202,10 @@ module Jinda
174
202
  # :enable_starttls_auto => true }
175
203
  # config.action_mailer.raise_delivery_errors = true
176
204
  # config.action_mailer.perform_deliveries = true
177
- }
205
+ }
178
206
  end
179
207
  initializer "jinda.rb" do
180
- %q{# encoding: utf-8
208
+ %q{# encoding: utf-8
181
209
  MM = "#{Rails.root}/app/jinda/index.mm"
182
210
  DEFAULT_TITLE = 'Jinda'
183
211
  DEFAULT_HEADER = 'Jinda'
@@ -190,25 +218,26 @@ NEXT = "Next >"
190
218
  IMAGE_LOCATION = "upload"
191
219
  # for debugging
192
220
  # DONT_SEND_MAIL = true
193
- }
221
+ }
194
222
  end
195
-
196
- initializer "mongoid.rb" do
197
- %q{# encoding: utf-8
198
- #
199
- # Mongoid 6 follows the new pattern of AR5 requiring a belongs_to relation to always require its parent
200
- # belongs_to` will now trigger a validation error by default if the association is not present.
201
- # You can turn this off on a per-association basis with `optional: true`.
202
- # (Note this new default only applies to new Rails apps that will be generated with
203
- # `config.active_record.belongs_to_required_by_default = true` in initializer.)
204
- #
205
- Mongoid::Config.belongs_to_required_by_default = false
206
- }
223
+ # Move mongoid.rb to jinda:config
224
+ # To avoid repeate install jinda:install crash
225
+ initializer "mongoid.rb" do
226
+ %q{# encoding: utf-8
227
+ #
228
+ # Mongoid 6 follows the new pattern of AR5 requiring a belongs_to relation to always require its parent
229
+ # belongs_to` will now trigger a validation error by default if the association is not present.
230
+ # You can turn this off on a per-association basis with `optional: true`.
231
+ # (Note this new default only applies to new Rails apps that will be generated with
232
+ # `config.active_record.belongs_to_required_by_default = true` in initializer.)
233
+ #
234
+ Mongoid::Config.belongs_to_required_by_default = false
235
+ }
207
236
  end
208
237
 
209
238
  inject_into_file 'config/environment.rb', :after => "initialize!" do
210
239
  "\n\n# hack to fix cloudinary error https://github.com/archiloque/rest-client/issues/141" +
211
- "\nclass Hash\n remove_method :read\nrescue\nend"
240
+ "\nclass Hash\n remove_method :read\nrescue\nend"
212
241
  end
213
242
  inject_into_file 'config/environments/development.rb', :after => 'config.action_mailer.raise_delivery_errors = false' do
214
243
  "\n config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
@@ -218,16 +247,15 @@ Mongoid::Config.belongs_to_required_by_default = false
218
247
  "\n config.assets.compile = true"
219
248
  end
220
249
  inject_into_file 'config/initializers/assets.rb', :after => '# Precompile additional assets.
221
- ' do
222
- "Rails.application.config.assets.precompile += %w( sarabun.css )" +
223
- "\nRails.application.config.assets.precompile += %w( disable_enter_key.js )\n"
250
+ ' do
251
+ "Rails.application.config.assets.precompile += %w( sarabun.css )" +
252
+ "\nRails.application.config.assets.precompile += %w( disable_enter_key.js )\n"
224
253
  end
225
254
  end
226
255
 
227
256
  def finish
228
257
  say "\n"
229
258
  say "Jinda gem ready for next configuration install.\n"
230
- say " (or short cut with sh install.sh)\n"
231
259
  say "Normally you will use the following command:\n"
232
260
  say "----------------------------------------\n"
233
261
  say "bundle install\n"