Module: GeneratorMessages

Defined in:
lib/generators/react_on_rails/generator_messages.rb

Class Method Summary collapse

Class Method Details

.add_error(message) ⇒ Object



9
10
11
# File 'lib/generators/react_on_rails/generator_messages.rb', line 9

def add_error(message)
  output << format_error(message)
end

.add_info(message) ⇒ Object



17
18
19
# File 'lib/generators/react_on_rails/generator_messages.rb', line 17

def add_info(message)
  output << format_info(message)
end

.add_warning(message) ⇒ Object



13
14
15
# File 'lib/generators/react_on_rails/generator_messages.rb', line 13

def add_warning(message)
  output << format_warning(message)
end

.clearObject



37
38
39
# File 'lib/generators/react_on_rails/generator_messages.rb', line 37

def clear
  @output = []
end

.format_error(msg) ⇒ Object



25
26
27
# File 'lib/generators/react_on_rails/generator_messages.rb', line 25

def format_error(msg)
  Rainbow("ERROR: #{msg}").red
end

.format_info(msg) ⇒ Object



33
34
35
# File 'lib/generators/react_on_rails/generator_messages.rb', line 33

def format_info(msg)
  Rainbow(msg.to_s).green
end

.format_warning(msg) ⇒ Object



29
30
31
# File 'lib/generators/react_on_rails/generator_messages.rb', line 29

def format_warning(msg)
  Rainbow("WARNING: #{msg}").orange
end

.helpful_message_after_installationObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/generators/react_on_rails/generator_messages.rb', line 41

def helpful_message_after_installation
  "\n    What to do next:\n\n      - See the documentation on https://github.com/shakacode/shakapacker#webpack-configuration\n        for how to customize the default webpack configuration.\n\n      - Include your webpack assets to your application layout.\n\n          <%= javascript_pack_tag 'hello-world-bundle' %>\n\n      - To start Rails server run:\n\n          ./bin/dev # Running with HMR\n\n        or\n\n          ./bin/dev-static # Running with statically created bundles, without HMR\n\n      - To server render, change this line app/views/hello_world/index.html.erb to\n        `prerender: true` to see server rendering (right click on page and select \"view source\").\n\n          <%= react_component(\"HelloWorldApp\", props: @hello_world_props, prerender: true) %>\n\n    Alternative steps to run the app:\n\n      - Run `rails s` to start the Rails server.\n\n      - Run bin/shakapacker-dev-server to start the Webpack dev server for compilation of Webpack\n        assets as soon as you save. This default setup with the dev server does not work\n        for server rendering\n\n      - Visit http://localhost:3000/hello_world and see your React On Rails app running!\n\n      - To turn on HMR, edit config/shakapacker.yml and set HMR to true. Restart the rails server\n        and bin/shakapacker-dev-server. Or use Procfile.dev.\n  MSG\nend\n"

.messagesObject



21
22
23
# File 'lib/generators/react_on_rails/generator_messages.rb', line 21

def messages
  output
end

.outputObject



5
6
7
# File 'lib/generators/react_on_rails/generator_messages.rb', line 5

def output
  @output ||= []
end