rur 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9fb19f4abf43766ef658a07f41f1ccb0dedcef20a8f899fbc12bbc42f3d3eb4
4
- data.tar.gz: 283da1f2087bc71b282d0ae40086610ba890b0ff820214784cd9d0d82ef2ea7b
3
+ metadata.gz: c17ed77b7c8b53bec66069a98c80695b30eb0eec02b18cbe071faef44ec0b577
4
+ data.tar.gz: 073a1495eeef128412d4293c8b9bca527ca11703f067327fed052778a89f4712
5
5
  SHA512:
6
- metadata.gz: 77c40feb84afb322ef267e4c2ec33aeafbc66b7e2b5ed2afc01b9b94913c1b0db5567bd27e2033ff32f89a043fb12d9422731958bffd11a2d374e8d330555ea5
7
- data.tar.gz: 7f0c0992552d658e88913f80794eb00304aee1e0f957679ba99894a7a29025575e447e4d4753954006516dfbb8d2588621b1b7499d4cdedccf0fb18e4c3d0a11
6
+ metadata.gz: 81944c66a687688064200e716f8e0ffd2c6192c8f44c14ac1777fe7f868b9c82b2e3cf316a5eea64f009e9f93d46bfa3334c0c5082e35ed34d0a1372d77b25b4
7
+ data.tar.gz: 0c98383312942c9dc6f967ad01b9397e64080b55c509fac843dbe5fe9b32871f963cb0d4ae9f11b5dd862e4dfb570a825b88a1f4345e24ccf0da14697b4ff05a
data/README.md CHANGED
@@ -25,6 +25,17 @@ Or install it yourself as:
25
25
 
26
26
  $ gem install rur
27
27
 
28
+ And then add `require 'rur'` into `config/application.rb`:
29
+
30
+ ```ruby
31
+ # config/application.rb
32
+ ...
33
+ require 'rails/all'
34
+
35
+ require 'rur'
36
+ ...
37
+ ```
38
+
28
39
  ## Usage
29
40
 
30
41
  ### 1. Init `Rur`
@@ -50,10 +61,14 @@ append .gitignore
50
61
 
51
62
  $ rake rur:produce
52
63
 
53
- 2.1 For specify folder(r) you want
64
+ 2.2 For specify folder(r) you want
54
65
 
55
66
  $ rake rur:produce controllers models views lib
56
67
 
68
+ ### 3. View results:
69
+
70
+ Go to [http://localhost:3000/rur](http://localhost:3000/rur) to see your results.
71
+
57
72
  ## Testing
58
73
  TODO
59
74
 
@@ -0,0 +1,6 @@
1
+ require 'rur'
2
+ require "rur/thor_ultils"
3
+ include Rur::Produce
4
+
5
+ path = File.expand_path(__dir__)
6
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| import f }
Binary file
@@ -0,0 +1,22 @@
1
+ Description:
2
+ Rur will generate `high_voltage` config and `rur` views
3
+
4
+ Example:
5
+ rails generate rur
6
+
7
+ 1) This will create:
8
+ create config/initializers/high_voltage.rb
9
+ create app/views/rur/home.html.erb
10
+ route scope :rur do
11
+ # Rur for all folders
12
+ get '/' => 'high_voltage/pages#show', id: 'home'
13
+ end
14
+ append .gitignore
15
+
16
+ 2) Produces Rubocop reports
17
+ 2.1 For your app
18
+ rake rur:produce
19
+
20
+ 2.1 For specify folder(r) you want
21
+ rake rur:produce controllers models views lib
22
+
@@ -0,0 +1,22 @@
1
+ class RurGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('templates', __dir__)
3
+
4
+ def copy_rur_file
5
+ copy_file "high_voltage.rb", "config/initializers/high_voltage.rb"
6
+ copy_file "home.html.erb", "app/views/rur/home.html.erb"
7
+ end
8
+
9
+ def add_rur_routes
10
+ rur_route = " scope :rur do\n"
11
+ rur_route += " \# Rur for all folders\n"
12
+ rur_route += " get '/' => 'high_voltage/pages#show', id: 'home'\n"
13
+ rur_route += " end\n"
14
+
15
+ route(rur_route)
16
+ end
17
+
18
+ def append_rur_gitignore
19
+ append_to_file('.gitignore', "\n# Rur views\napp/views/rur")
20
+ end
21
+
22
+ end
@@ -0,0 +1,6 @@
1
+ # This file was generated by rur
2
+
3
+ HighVoltage.configure do |config|
4
+ # Change default path and folder of 'pages': 'app/views/rubocop_reports'
5
+ config.content_path = 'rur/'
6
+ end
@@ -0,0 +1,2 @@
1
+ <h2 style="text-align: center;">Rubocop reports</h2>
2
+ <div style="text-align: center;"><i>This file was generated by Rur</i></div>
@@ -0,0 +1,13 @@
1
+ require 'rur'
2
+ require 'rails'
3
+
4
+ module Rur
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :rur
7
+
8
+ rake_tasks do
9
+ path = File.expand_path(__dir__)
10
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
+ end
12
+ end
13
+ end
data/lib/rur.rb CHANGED
@@ -7,8 +7,4 @@ require "rur/produce"
7
7
 
8
8
  module Rur
9
9
  require 'railtie' if defined?(Rails)
10
-
11
- def self.hl
12
- p 'hello'
13
- end
14
10
  end
@@ -0,0 +1,44 @@
1
+ # include Rails::Generators
2
+
3
+ module Rur
4
+ module Produce
5
+ def parse_routes(targets)
6
+ return [] if targets.blank?
7
+
8
+ if targets.include?(',')
9
+ targets.gsub(/[[:space:]]/, '').split(',')
10
+ else
11
+ targets.split(' ')&.compact
12
+ end
13
+ end
14
+
15
+ def r_produce(target)
16
+ dir =
17
+ case target
18
+ when 'app'
19
+ 'app'
20
+ when 'models', 'model'
21
+ 'app/models'
22
+ when 'controllers', 'controller'
23
+ 'app/contollers'
24
+ when 'views', 'view'
25
+ 'app/views'
26
+ when 'config'
27
+ 'config'
28
+ when 'lib'
29
+ 'lib'
30
+ when 'db'
31
+ 'db'
32
+ when '.'
33
+ ''
34
+ else
35
+ false
36
+ end
37
+
38
+ # TODO: catch error here!
39
+ return unless dir
40
+
41
+ `rubocop #{Rails.root}/#{dir}/ --format html -o app/views/rur/#{target}.html.erb`
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ class Rur::ThorUltils < Thor
2
+ include Thor::Actions
3
+
4
+ # Prepend route into config/routes.rb
5
+ no_commands do
6
+ def prepend_rur_route(route)
7
+ route_path = " \# Rur for #{route}\n"
8
+ route_path += " get '#{route}' => 'high_voltage/pages#show', id: '#{route}'\n"
9
+
10
+ insert_into_file("#{Rails.root}/config/routes.rb", route_path, after: "scope :rur do\n")
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Rur
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,27 @@
1
+ include Rur::Produce
2
+ require "rur/thor_ultils"
3
+
4
+ namespace :rur do
5
+ desc "Rur produces app"
6
+ task :produce, [:route] => :environment do |t, args|
7
+ # routes = Rur::Produce.parse_routes(ARGV.drop(1))
8
+
9
+ routes = ARGV.drop(1)
10
+
11
+ if routes.blank?
12
+ p "Rur is producing your app:[#{Rails.root}/]"
13
+ Rur::Produce.r_produce('.')
14
+ p "Rur produced your app:\[#{Rails.root}\/\]\n"
15
+ else
16
+ # dynamically writing tasks on the fly
17
+ routes.each { |a| task a.to_sym do ; end }
18
+
19
+ routes.each do |route|
20
+ p "Rur is producing #{route}..."
21
+ Rur::Produce.r_produce(route)
22
+ Rur::ThorUltils.new.prepend_rur_route(route)
23
+ p "Rur produced #{route}!\n"
24
+ end
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - phunt
@@ -111,8 +111,18 @@ files:
111
111
  - Rakefile
112
112
  - bin/console
113
113
  - bin/setup
114
+ - lib/Rakefile
115
+ - lib/generators/.DS_Store
116
+ - lib/generators/rur/USAGE
117
+ - lib/generators/rur/rur_generator.rb
118
+ - lib/generators/rur/templates/high_voltage.rb
119
+ - lib/generators/rur/templates/home.html.erb
120
+ - lib/railtie.rb
114
121
  - lib/rur.rb
122
+ - lib/rur/produce.rb
123
+ - lib/rur/thor_ultils.rb
115
124
  - lib/rur/version.rb
125
+ - lib/tasks/rur.rake
116
126
  - rur.gemspec
117
127
  homepage: http://phunt.site
118
128
  licenses: