localtower 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -7
  3. data/app/controllers/localtower/pages_controller.rb +24 -17
  4. data/app/helpers/localtower/application_helper.rb +7 -1
  5. data/app/views/layouts/localtower/application.html.erb +0 -10
  6. data/app/views/localtower/pages/logs.html.erb +2 -2
  7. data/app/views/localtower/pages/migrations.html.erb +40 -4
  8. data/app/views/localtower/pages/models.html.erb +1 -5
  9. data/app/views/localtower/pages/relations.html.erb +7 -5
  10. data/app/views/localtower/pages/tasks.html.erb +48 -0
  11. data/config/routes.rb +3 -1
  12. data/lib/localtower/plugins/capture.rb +8 -5
  13. data/lib/localtower/status.rb +6 -12
  14. data/lib/localtower/tools.rb +9 -21
  15. data/lib/localtower/version.rb +1 -1
  16. data/lib/localtower.rb +1 -3
  17. data/public/css/app.css +4 -0
  18. data/spec/dummy/Gemfile +2 -1
  19. data/spec/dummy/Gemfile.lock +101 -73
  20. data/spec/dummy/app/models/application_record.rb +3 -0
  21. data/spec/dummy/config/application.rb +1 -1
  22. data/spec/dummy/config/environments/development.rb +3 -3
  23. data/spec/dummy/config/environments/production.rb +2 -2
  24. data/spec/dummy/config/initializers/assets.rb +1 -1
  25. data/spec/dummy/log/development.log +10567 -2
  26. data/spec/dummy/log/localtower.log +380 -1640
  27. data/spec/dummy/log/localtower_capture_d8979d360722798f7b6eb1a2694a3791.json +1 -0
  28. data/spec/dummy/log/test.log +209 -1452
  29. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-Y/-YOiiBKqc2UODHFjctm8xc7xFoZaL7zOjWQj6qQ2wyE.cache +1 -0
  30. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-d/-dwueM4vmPt8L51S3jeSyg_AjGDcj0GUN6pDpCA1gCg.cache +3 -0
  31. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0g/0gaJnJQdtd2ACbihXxn8OnjLWlDjnQ_WxfgOpbiLzhg.cache +1 -0
  32. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0r/0rFCsCV9kZnEYtZZ6sfig8329OU31bqjecDFqSVank8.cache +1 -0
  33. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/1J/1J2k_CpnQE3d-PZAQwOVGQALGkta4qVvhdsKjgG0e4Q.cache +0 -0
  34. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2p/2pYVH2Z_syqh6ok8QYxJNKxXpx1Iwppf6JGElZI0gpw.cache +0 -0
  35. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/3W/3WBmqd-2V6q5N-jvbyp-tlcfn3aHYMwBppbOUm7x4qg.cache +1 -0
  36. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/4K/4KFPlHkhdDW0riGUmlbaR-kmDz6JUnQvY6fwW8qsdaE.cache +3 -0
  37. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/6x/6xMeRWmLpNK_flx6-JA3KazvUxSCxyPxHv9Zm3eC26Q.cache +1 -0
  38. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/7d/7dNqI_dCDJLJmI1oM4xwFp9nRRNOem-4P4OD7PMyz2E.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8X/8XquhxVcp5A8QquLtxO8NgKTMJch0eqQmzFmRGIZP6I.cache +1 -0
  40. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ah/AhdfXXtU63kXS4TnsH2Vi1yWgVkIEeV8Z8XA68hrNQc.cache +0 -0
  41. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bt/BtAePnwLSGw82xUGI7wuhWDfuwarOQVS91YqCsweMcs.cache +0 -0
  42. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bx/BxzoG0KxeNLac4xTNeJv3qfeytbNBw58xj2zD-xdbrE.cache +2 -0
  43. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/CC/CCD0ROPX0yxHwNpVZmuP8ZNtgQpaVCMXpdzC0Wb5n24.cache +1 -0
  44. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/DS/DS43oxBg6K5PMWLn2mTy_4EnxI03ehHkxpjV7NCi8yM.cache +1 -0
  45. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +2 -0
  46. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/EI/EI0Nxk-VRATWstMuVCVc0_GdYlQ-a0dx6n2g0l3vIik.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/EN/ENhJnzJAU2IK-7aHqubj9N8Jo_UTmjG_VEQqyIkolQ8.cache +1 -0
  48. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Fc/FcS6VUHN3Bd4pHGqd5NHA8jA4OLwWrU94s3b4GGxX9c.cache +1 -0
  49. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/G0/G0kukI-r0q0Vbrg6e_jnYJoYcOX8K__h-mwKbCf4twE.cache +0 -0
  50. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/I1/I1Jw08-mz8xzgrgi6giCzpf1UmzGTSbl4eJEw4DAoJM.cache +1 -0
  51. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/IV/IVOO1dXBmgjieDk__g57p6aYt0Z3CmfTa32jhegoyko.cache +3 -0
  52. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/JY/JYPmv5WP4wxdI9EKEEPkK_fVtqeSLfmint_5E8fQLQ8.cache +1 -0
  53. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/MX/MXI3KxaQPZGImSvCNZ_TbQVruWCJ3E0xiVxza1ZCAjM.cache +1 -0
  54. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/OU/OUoioCqXALK909jXPV3VSyCJIdNC7bsogUfdnRTpc5o.cache +1 -0
  55. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/PH/PHjtqNLUPAUDiSlu5AbPjlIo20mOGNm0uNjMLhX2NvM.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/RC/RC9vfALY5K634pTeau0BAhTHl7d5_5yA3tM-QTLiKtI.cache +0 -0
  57. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/RG/RG1PrmlixwaUlG8BV0kcm_3F7OQekxsrLYjBdf403-k.cache +2 -0
  58. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ut/UtoMO6n6FHTpRCGk9VfxlfTI2Ao2GYJ_6kMzx3B9VH8.cache +1 -0
  59. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/VE/VExnbpDk3LxYdPk3htUrZQXPI8NK_zlKtSFfVXJlxU4.cache +1 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Wm/WmKTjykiU-Tx_Faf5zduEeEQ-DozAs5omKToM2l1cZM.cache +0 -0
  61. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/X-/X-KjhDPd0nI155N_FaxFSgaOiYo0_ytqlmkBlLM7ayw.cache +1 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/XX/XXVhj-O91tJ5c8pz7DQlTABOv8TIRVg5haw9VOq9HuI.cache +1 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/YC/YCiifo5NCMwDChFqYFiV4EaYEx8hy3Efle1PsGbIdak.cache +1 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ya/YayMISAqD-Y3vBFywwKrXbUovGf5o77HUF5s8mnQgO0.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Zl/Zl-NEb0aDLmZ9gN4gdY1OYlbUXD4JhkFY_y23m55zmo.cache +0 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/_h/_hnjPptBeD3GP5B0iJR6pvyVkiMiq-o2TxaYmGf9KJo.cache +3 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/_p/_poEF6QbTPYJiQCFGoXxIXjmvcn6T0I87ElzJGHguk0.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/aa/aaSj2zt8ddc87nZqTpOI9gRCKVnoalXKFBww7t4t3Kg.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/bZ/bZHWUkrOLp0WM_Ogo36Qjt4cxDt-rOFgtcj4LNB-BVE.cache +1 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/cP/cPSNG_663TNT944Rke919luRS6FtpMwVc_7aDph645w.cache +1 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/ce/ceq8fcZGIoqWrCl9vrCRrywEdx42iy9PrGG9CwFSIF4.cache +0 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/cl/cljhP0Jc018nLnG1rpdg-FUf6mlIqrQYvXTNXTNG9Bw.cache +0 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dm/dmod3fTZdoKso2FGM5RTQtb4kTB6vywsiXLWDygYFN4.cache +1 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dy/dySDGcUTqlKx2MTvOmIEP-WzhyhCfU5xhN9qgxbz3rI.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gQ/gQYdmEzbLjTcFCnsfzXzEmeminOchF263snAk3IvXM0.cache +1 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gh/ghvuMAqccBGljlmEaI3Gt5tH5rEg6hseKYMYfRMkHdY.cache +1 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gt/gt8QC7k92A4hXA3HlCpQulW73tqd6x63I3uT-YrGMj0.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/hf/hfVg-y7dPSQKbb7V3I7M5w7IpOhDiIB2H31d2tmbZMU.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/iF/iFLwyhZIu1Jxm77NUT2qWeTDMmyELW4U85t9rGE_KVg.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/kF/kFlIcBBnSyKE00OjpM90pqSn93mLMUv9esz86nrO-Cs.cache +1 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/ma/MazNt_5OaYexRuZnccZZ_7AONlxn1a4W3KdWyHyBdws.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/ma/ma3w08gnDTeqwY2-C9BlToxA6-AS8bvXlu-nBiz0UYs.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qP/qPmv5snMrDw830S6hSICDcnIy7kVEWoFKXhGKT38lG4.cache +2 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/sY/sYvTb1uPWWmnHJNXKuW_xSco-aUb-rN2f0J35zSIzuc.cache +1 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/su/suQ_jjDxRiIn4VEqFJYKaBWJILaeGKBvoTv49XNX0vo.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/u8/u8IrW5IIQ7espwk2Vpk23zheL9YZA0tnbKq9X7E-WA0.cache +1 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/wh/whzETExjcZCkn4msasD2aylgfhfpKPZrNxTkY-SOIDg.cache +2 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/y6/y6oxsJD3pAY9ph1_5M-77uiEjTVw8BheLZNygCKPm1g.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/yH/yHZ-a1J23ZCf2n5mEHINMz23Iec2cLGTKauW7k4yGTE.cache +0 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/z7/z7KfUWYoSaGq8tQ5mbHwyfXyT3Pa4FWKJswHcIdJuds.cache +1 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/zu/zuExWc5WHxeOUPZUKHl9a9ZRmN50g7jMOD28macn6M0.cache +0 -0
  96. data/spec/dummy/tmp/pids/server.pid +1 -0
  97. data/spec/dummy/tmp/restart.txt +0 -0
  98. metadata +147 -25
  99. data/app/views/localtower/pages/status.html.erb +0 -29
  100. data/spec/dummy/custom_plan.rb +0 -11
  101. data/spec/dummy/db/schema.rb +0 -4
  102. data/spec/dummy/zeus.json +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f62130e44cf4f1047a87b4ab0bed7cd6821d00a7a0767320644d9e78120bba4
4
- data.tar.gz: a6c3f44be4d00e2b159170254e8f4424d3ae95e5d4ac0645e8aaffbb882178a6
3
+ metadata.gz: 6eca3e0577b9e6f78d4982d046a3cba50519ee9eddc87367e6f04ce0abe77134
4
+ data.tar.gz: 7df1c8a2b27f095c840cab877023b9920290795d4b257e8c51ce0cff5730d484
5
5
  SHA512:
6
- metadata.gz: fd0523f501766384f7e9a2013e7d0b2256443de640aa627b1513d8c8bca3269627d28fbba6db5c08a8f840deb3b2854dc364772681408cdfcefe86b4e87d9256
7
- data.tar.gz: e1a6e0c03d83e3f12acf2e1acf617e92c0a2f4e365479b8984ad016e3f196eb77fa916378cf02d17196689fe27ed16f14333e8832ac456baa2b9469930dd5b37
6
+ metadata.gz: e8a389075ad641b51eddf4b41ef0a16b49ba8761c09e696edb94832e5b69896fbe051f8458110761e9767979a276e566c04fe162a6fedec6b5487158a3680802
7
+ data.tar.gz: 5b05a0e034ae8c636ccc514423e4434583568440785295963da345cf30a414e4fac11462d39c8fede9e3420e913d8dd02808688e6dd19c2160f7dfd2583ffae8
data/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
  <img src="https://raw.githubusercontent.com/damln/localtower/master/public/logo-localtower-white-300.png" alt="Localtower">
3
3
  </p>
4
4
 
5
+ ## Intro
6
+
7
+ Update in 2022, please use localtower version `>= 0.4.1`
8
+ See installation process below.
9
+ Compatibility:
10
+ - Rails >= 5.2
11
+ - Ruby >= 2.3
12
+
5
13
  ### See the schema
6
14
  ![Schema](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/1_schema.png)
7
15
 
@@ -24,7 +32,7 @@ Only tested with Rails 4.2 and Rails 5.1 (should work with any Rails 4.2+ applic
24
32
  Add to your `Gemfile` file:
25
33
  ```ruby
26
34
  group :development do
27
- gem "localtower"
35
+ gem "localtower", ">= 0.4.1"
28
36
  end
29
37
  ```
30
38
 
@@ -60,7 +68,9 @@ Open your browser at [http://localhost:3000/localtower](http://localhost:3000/lo
60
68
 
61
69
  You can put this line anywhere in your code:
62
70
 
63
- Localtower::Plugins::Capture.new(self, binding).save
71
+ ```ruby
72
+ Localtower::Plugins::Capture.new(self, binding).save
73
+ ```
64
74
 
65
75
  For example:
66
76
 
@@ -79,7 +89,7 @@ Then go to the Localtower intercave here: [http://localhost:3000/localtower/logs
79
89
 
80
90
  The value for each variable will try to call `.to_json`. If you have a huge collection of models likes `@users` you will see all the collection as an Array.
81
91
 
82
- ## RSpec and Contribute
92
+ ## Run test
83
93
 
84
94
  If you want to contribute to the gem:
85
95
 
@@ -96,18 +106,22 @@ bundle install
96
106
  bundle exec rspec spec/
97
107
  ```
98
108
 
99
- Notes:
100
- Tests are currently very slow because this is testing rails commands so it boots the framework for each test. Zeus or spring should be introduced.
101
-
102
109
  ## Contribute
103
110
 
104
- Thanks for reporting issues, I'll do my best.
111
+ Thanks for reporting issues, I'll do my best 💪
105
112
 
106
113
  [![Analytics](https://ga-beacon.appspot.com/UA-93841935-1/github-readme?pixel)](https://github.com/damln/localtower)
107
114
 
108
115
 
109
116
  ## Deploy
117
+ Only for official contributors.
110
118
 
111
119
  rm *.gem | gem build localtower.gemspec && gem push localtower-*.gem
112
120
 
121
+ ## Notes
122
+
123
+ Do not hesitate to open issues if you have troubles using the gem.
124
+
125
+ - By Damian Le Nouaille Diez: https://damln.com
126
+ - Link on RubyGems: https://rubygems.org/gems/localtower
113
127
 
@@ -11,32 +11,25 @@ module Localtower
11
11
  end
12
12
 
13
13
  def log
14
- file = Dir["#{Localtower::Plugins::Capture::LOG_PATH.call}/localtower*#{params[:md5]}*"][0]
14
+ file_content = Localtower::Plugins::Capture.log_from_md5(clean_params['md5'])
15
15
 
16
- render json: JSON.parse(open(file).read)
16
+ render json: file_content
17
17
  end
18
18
 
19
19
  def log_var
20
- answer = {}
20
+ file_content = Localtower::Plugins::Capture.log_from_md5(clean_params['md5'])
21
+ returned = file_content["variables"].select {|i| i["event_name"] == clean_params[:var] }[0]["returned"]
21
22
 
22
- file = Dir["#{Localtower::Plugins::Capture::LOG_PATH.call}/localtower*#{params[:md5]}*"][0]
23
- data = JSON.parse(open(file).read)
24
-
25
- answer = data["variables"].select {|i| i["event_name"] == params[:var] }[0]["returned"]
26
-
27
- render json: answer
28
- end
29
-
30
- def status
31
- @data = ::Localtower::Status.new.run
23
+ render json: returned
32
24
  end
33
25
 
34
26
  def migrations
27
+ @migrations = ::Localtower::Status.new.run
35
28
  end
36
29
 
37
30
  def post_migrations
38
31
  # Because we have a list or a field, take the item from the list in priority
39
- params[:migrations][:migrations] = params[:migrations][:migrations].map do |action_line|
32
+ clean_params["migrations"]["migrations"] = clean_params["migrations"]["migrations"].map do |action_line|
40
33
  action_line["new_column_type"] = action_line["column_type"]
41
34
 
42
35
  if action_line["column"].present?
@@ -52,23 +45,34 @@ module Localtower
52
45
  action_line
53
46
  end
54
47
 
55
- use_generator(::Localtower::Generators::Migration, params[:migrations])
48
+ use_generator(::Localtower::Generators::Migration, clean_params["migrations"])
56
49
  redirect_to migrations_path
57
50
  end
58
51
 
59
52
  def relations
53
+ @need_models = ::Localtower::Tools.enought_models_for_relation?
60
54
  end
61
55
 
62
56
  def post_relations
63
- use_generator(::Localtower::Generators::Relation, params[:relations])
57
+ use_generator(::Localtower::Generators::Relation, clean_params["relations"])
64
58
  redirect_to relations_path
65
59
  end
66
60
 
61
+ # def tasks
62
+ # @tasks = ['rake db:migrate RAILS_ENV=test']
63
+ # end
64
+
65
+ # def post_tasks
66
+ # ::Localtower::Tools.perform_cmd(clean_params["task"]["name"], false)
67
+
68
+ # redirect_to tasks_path
69
+ # end
70
+
67
71
  def models
68
72
  end
69
73
 
70
74
  def post_models
71
- use_generator(::Localtower::Generators::Model, params[:models])
75
+ use_generator(::Localtower::Generators::Model, clean_params["models"])
72
76
  redirect_to relations_path
73
77
  end
74
78
 
@@ -78,5 +82,8 @@ module Localtower
78
82
  generator_klass.new(options).run
79
83
  end
80
84
 
85
+ def clean_params
86
+ params.permit!.to_hash.with_indifferent_access
87
+ end
81
88
  end
82
89
  end
@@ -7,7 +7,13 @@ module Localtower
7
7
  else
8
8
  str = name
9
9
  end
10
- link_to str, "subl://open/?url=file://#{file}"
10
+
11
+ link_to str, file_link(file)
12
+ end
13
+
14
+ def file_link(file)
15
+ "vscode://file/#{file}"
16
+ # "vscode://open?url=file://#{file}&line=1"
11
17
  end
12
18
 
13
19
  def to_json_print(hash)
@@ -62,16 +62,6 @@
62
62
  <p>Logs</p>
63
63
  </a>
64
64
  </li>
65
-
66
- <!--
67
- <li class="<%= is_active_link?(status_path, :inclusive) ? "active" : nil %>">
68
- <a href="<%= status_path %>">
69
- <i class=""></i>
70
- <p>Status</p>
71
- </a>
72
- </li>
73
- -->
74
-
75
65
  </ul>
76
66
  </div>
77
67
  </div>
@@ -54,14 +54,14 @@
54
54
  </td>
55
55
  <td>
56
56
  <span>
57
- <a class="code" href="subl://open/?url=file://<%= item["meta"]["sublime_path"] %>">
57
+ <a class="code" href="<%= file_link(item["meta"]["sublime_path"]) %>">
58
58
  <%= item["meta"]["from_klass"] %>
59
59
  </a>
60
60
  </span>
61
61
  </td>
62
62
  <td>
63
63
  <span class="code">
64
- <%= item["meta"]["from_method"] %>
64
+ def <%= item["meta"]["from_method"] %>()
65
65
  </span>
66
66
  </td>
67
67
  <td>
@@ -79,10 +79,6 @@
79
79
  <!-- multiple lines: -->
80
80
  <div class="row">
81
81
  <div class="col-md-12 text-center">
82
- <button name="migrations[run_migrate]" type="submit" value="false" class="btn btn-warning" data-selector="submit">
83
- Create the migration
84
- </button>
85
-
86
82
  <button name="migrations[run_migrate]" type="submit" value="true" class="btn btn-success" data-selector="submit">
87
83
  Create the migration and <b>migrate</b>
88
84
  </button>
@@ -91,5 +87,45 @@
91
87
  <% end %>
92
88
  </div>
93
89
  </div>
90
+
91
+ <div class="card">
92
+ <div class="header">
93
+ <h4 class="title">Migrations</h4>
94
+ </div>
95
+
96
+ <div class="content">
97
+ <table class="table">
98
+ <thead>
99
+ <tr>
100
+ <th>Name</th>
101
+ <th>Date</th>
102
+ <th>Status</th>
103
+ </tr>
104
+
105
+ </thead>
106
+ <tbody>
107
+ <% @migrations.each do |entry| %>
108
+ <%
109
+ klass = (entry["status"] == :done) ? "success" : "danger"
110
+ %>
111
+ <tr class="<%= klass %>">
112
+ <td>
113
+ <%= entry["name"] %>
114
+ </td>
115
+
116
+ <td>
117
+ <%= entry["time"] %>
118
+ </td>
119
+
120
+ <td>
121
+ <%= entry["status"] == :done ? 'done' : 'not executed' %>
122
+ </td>
123
+ </tr>
124
+ <% end %>
125
+ </tbody>
126
+ </table>
127
+ </div>
128
+
129
+ </div>
94
130
  </div>
95
131
  </div>
@@ -21,7 +21,7 @@
21
21
 
22
22
  <table class="table table-hover table-striped">
23
23
  <thead>
24
- <th>Field</th>
24
+ <th>Column Name</th>
25
25
  <th>Type</th>
26
26
  <th>Default</th>
27
27
  <th>Index?</th>
@@ -66,10 +66,6 @@
66
66
  <!-- multiple lines: -->
67
67
  <div class="row">
68
68
  <div class="col-md-12 text-center">
69
- <button name="models[run_migrate]" type="submit" value="false" class="btn btn-warning" data-selector="submit">
70
- Create the model
71
- </button>
72
-
73
69
  <button name="models[run_migrate]" type="submit" value="true" class="btn btn-success" data-selector="submit">
74
70
  Create the model and <b>migrate</b>
75
71
  </button>
@@ -5,6 +5,12 @@
5
5
  <div class="card">
6
6
  <div class="header">
7
7
  <h4 class="title"></h4>
8
+
9
+ <% if not ::Localtower::Tools.enought_models_for_relation? %>
10
+ <div class="alert alert-danger text-center" role="alert">
11
+ <a href="#" class="alert-link">You need at least 2 models to create a relation.</a>
12
+ </div>
13
+ <% end %>
8
14
  </div>
9
15
 
10
16
  <div class="content">
@@ -15,7 +21,7 @@
15
21
  <div class="col-md-offset-4 col-sm-offset-3 col-md-4 col-sm-6">
16
22
  <div class="form-group">
17
23
  <div class="text-center">
18
- <label>Name of the Model (optional)</label>
24
+ <label>Name of the relation (optional, will use Rails conventions by default)</label>
19
25
  </div>
20
26
  <input type="text" name="relations[model_name]" class="form-control">
21
27
  </div>
@@ -47,10 +53,6 @@
47
53
 
48
54
  <div class="row">
49
55
  <div class="col-md-12 text-center">
50
- <button name="relations[run_migrate]" type="submit" value="false" class="btn btn-warning" data-selector="submit">
51
- Create the relation
52
- </button>
53
-
54
56
  <button name="relations[run_migrate]" type="submit" value="true" class="btn btn-success" data-selector="submit">
55
57
  Create the relation and <b>migrate</b>
56
58
  </button>
@@ -0,0 +1,48 @@
1
+ <% content_for :title do %>Tasks<% end %>
2
+
3
+ <div class="row">
4
+ <div class="col-md-12">
5
+ <div class="card">
6
+ <div class="header">
7
+ <h4 class="title"></h4>
8
+ </div>
9
+ <div class="content">
10
+
11
+ <%= form_tag tasks_path, class: "form" do %>
12
+ <div class="row">
13
+ <div class="form-group">
14
+ <div class="col-md-12">
15
+ <div class="form-group">
16
+ <table class="table table-hover table-striped">
17
+ <thead>
18
+ <th>Task</th>
19
+ <th></th>
20
+ </thead>
21
+
22
+ <tbody data-selector="tbody">
23
+ <% @tasks.each do |task_str| %>
24
+ <tr data-selector="tr">
25
+ <td>
26
+ <code>
27
+ <%=task_str%>
28
+ </code>
29
+ <input type="hidden" name="task[name]" value="<%= task_str %>" class="form-control">
30
+ </td>
31
+ <td>
32
+ <button name="" type="submit" class="btn btn-success" data-selector="submit">
33
+ RUN
34
+ </button>
35
+ </td>
36
+ </tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <% end %>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
data/config/routes.rb CHANGED
@@ -8,7 +8,9 @@ Localtower::Engine.routes.draw do
8
8
  get "relations", to: "pages#relations", as: :relations
9
9
  post "relations", to: "pages#post_relations"
10
10
 
11
- get "status", to: "pages#status", as: :status
11
+ # get "tasks", to: "pages#tasks", as: :tasks
12
+ # post "tasks", to: "pages#post_tasks"
13
+
12
14
  # get ':v/:asset', to: 'pages#asset_render', as: 'asset_render', :constraints => { :v => /[^\/]*/, :asset => /[^\/]*/ }
13
15
 
14
16
  get 'dashboard', to: 'pages#dashboard', as: 'dashboard'
@@ -28,6 +28,11 @@ module Localtower
28
28
  end
29
29
  end
30
30
 
31
+ def log_from_md5(md5)
32
+ file = Dir["#{Localtower::Plugins::Capture::LOG_PATH.call}/localtower*#{md5}*"][0]
33
+ JSON.parse(open(file).read)
34
+ end
35
+
31
36
  def type_of(value)
32
37
  if value.instance_of?(Float); return Float.to_s; end;
33
38
  if value.instance_of?(Integer); return Integer.to_s; end;
@@ -82,7 +87,9 @@ module Localtower
82
87
  sublime_path = "#{callers[1].split(":")[0]}:#{line_number}"
83
88
 
84
89
  hash["class"] = self.klass_name
90
+ hash["file_name"] = file
85
91
  hash["file"] = "#{file}##{method}:#{line_number}"
92
+ hash["line_number"] = line_number
86
93
  hash["method"] = method
87
94
  hash["md5"] = Digest::MD5.hexdigest(hash["file"])
88
95
  hash["type"] = "CAPTURE_METHOD"
@@ -107,10 +114,7 @@ module Localtower
107
114
  from_method: hash["method"],
108
115
  klass: klass.to_s,
109
116
  method: method.to_s,
110
- # arguments: data[:arguments],
111
117
  callers: callers,
112
- # table_name: data[:table_name],
113
- # sql: data[:sql],
114
118
  sublime_path: sublime_path,
115
119
  file: hash["file"],
116
120
  line: line_number
@@ -180,10 +184,9 @@ module Localtower
180
184
  self.clear
181
185
 
182
186
  data = self.values
183
- json = data.to_json
184
187
  file = "#{LOG_PATH.call}/localtower_capture_#{data['md5']}.json"
185
188
 
186
- File.open(file, 'w') { |f| f.write(json) }
189
+ File.open(file, 'w') { |f| f.write(data.to_json) }
187
190
  end
188
191
 
189
192
  def log(str)
@@ -7,24 +7,18 @@ module Localtower
7
7
  file_full_path.split("/")[-1]
8
8
  end
9
9
 
10
- results = []
10
+ db_migrations = ActiveRecord::Base.connection.execute("select * from schema_migrations;").map { |e| e["version"].to_s }.sort.reverse
11
11
 
12
- migrations = ActiveRecord::Base.connection.execute("select * from schema_migrations;").map { |e| e["version"].to_s }.sort.reverse
12
+ names.map do |name|
13
+ time = name.split("_")[0]
14
+ status = db_migrations.include?(time) ? :done : :todo
13
15
 
14
- names.each do |name|
15
- number = name.split("_")[0]
16
-
17
- status = migrations.include?(number) ? 1 : 0
18
-
19
- data = {
16
+ {
20
17
  "name" => name,
18
+ "time" => time,
21
19
  "status" => status,
22
20
  }
23
-
24
- results << data
25
21
  end
26
-
27
- results
28
22
  end
29
23
  end
30
24
  end
@@ -14,15 +14,13 @@ module Localtower
14
14
  class << self
15
15
  def force_reload!
16
16
  app_folders = Dir["#{Rails.root}/app/models/**/*.rb"]
17
- lib_folders = Dir["#{Rails.root}/lib/**/*.rb"]
18
-
19
- all_folders = (app_folders + lib_folders).flatten
17
+ all_folders = (app_folders).flatten
20
18
 
21
19
  all_folders.each do |file|
22
20
  begin
23
- ActiveSupport::Dependencies.require_or_load(file)
21
+ require file
24
22
  rescue Exception => e
25
- puts "Error loading: #{file}"
23
+ puts "Error loading: #{file}, #{e.message}"
26
24
  end
27
25
  end
28
26
  end
@@ -31,7 +29,12 @@ module Localtower
31
29
  self.force_reload!
32
30
 
33
31
  root_klass = defined?(ApplicationRecord) ? ApplicationRecord : ActiveRecord::Base
34
- root_klass.subclasses
32
+
33
+ root_klass.subclasses - [ActiveRecord::SchemaMigration]
34
+ end
35
+
36
+ def enought_models_for_relation?
37
+ models.size >= 2
35
38
  end
36
39
 
37
40
  def models_presented
@@ -124,31 +127,16 @@ module Localtower
124
127
  end
125
128
  end
126
129
 
127
- def rails_project
128
- Rails.root.to_s.split("/").last
129
- end
130
-
131
130
  def perform_migration(str, standalone = false)
132
131
  self.perform_cmd("rails g migration #{str}", false)
133
132
 
134
133
  if not standalone
135
- # self.perform_raw_cmd("z rake #{cmd_str}", standalone)
136
134
  self.perform_cmd('rake db:migrate')
137
- # self.perform_cmd('rake db:migrate RAILS_ENV=test')
138
135
  end
139
136
  end
140
137
 
141
138
  def perform_cmd(cmd_str, standalone = true)
142
139
  self.perform_raw_cmd("bundle exec #{cmd_str}", standalone)
143
-
144
- # if cmd_str["rake"]
145
- # self.perform_raw_cmd("zeus #{cmd_str}", standalone)
146
- # elsif cmd_str["rails g migration"]
147
- # cmd = cmd_str.split("rails g migration")[1]
148
- # self.perform_raw_cmd("zeus generate migration #{cmd}", standalone)
149
- # else
150
- # self.perform_raw_cmd("bundle exec #{cmd_str}", standalone)
151
- # end
152
140
  end
153
141
 
154
142
  def perform_raw_cmd(cmd_str, standalone = false, root_dir = false)
@@ -1,3 +1,3 @@
1
1
  module Localtower
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
data/lib/localtower.rb CHANGED
@@ -5,13 +5,11 @@ end
5
5
  require 'thor'
6
6
  require 'active_link_to'
7
7
  require 'zip'
8
- require 'pg'
9
- require 'sqlite3'
10
8
 
11
9
  begin
12
10
  require "pry"
13
11
  rescue Exception => e
14
- puts "No Pry."
12
+ # Nothing
15
13
  end
16
14
 
17
15
  root = File.expand_path(File.dirname(__FILE__))
data/public/css/app.css CHANGED
@@ -23,6 +23,10 @@
23
23
  color: white;
24
24
  }
25
25
 
26
+ .alert {
27
+ padding: 20px 30px;
28
+ }
29
+
26
30
  .tower-a:hover{
27
31
  color: white;
28
32
  }
data/spec/dummy/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '5.2.0'
3
+ # gem 'rails', '5.2.0'
4
+ gem "rails", "~> 7.0.1"
4
5
  gem 'pg'
5
6
  gem 'puma'
6
7
  gem 'jquery-rails'