pyonnuka 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e24da70001fb7c68f024f9d4a8166887c9a54036
4
- data.tar.gz: 54b72a5da89d2a4d040dfe34cd360025185742a6
3
+ metadata.gz: d219078888200c4468f93f82319fc19939f14775
4
+ data.tar.gz: 3ae2a5fd922ea2278bcdcb8d0c55be12a06036e1
5
5
  SHA512:
6
- metadata.gz: 81a294adfd35cb46a37c5cd902a7309016da7b6177124078cc345abe8f51a4f7d3d621a773267dcb0019c85c38e069df8cb864467146b6a37e57a068676f8253
7
- data.tar.gz: 5a08b296cc2dbd4b341a73add20f80545cef288e71bd03983e7f7f419cd2e1c378468d4ddd389695ee3b8cc7857ff364370d4f0fa6713b8dcdc72fa158e6280e
6
+ metadata.gz: c24c472ce8494b5b5029a0a95b9567d8cb068f162565172a21f3756083a5affef0ff441183eaea214f1d02835cf9129dc1f754b693a2b790894f4163b322e652
7
+ data.tar.gz: 8111c868ab73545f51545acb3896605f454f2098c384703cd74f3783e0803f3e59c6d777c6ff94c00c259200a12538898040906451edc9088287ef94d20c6def
data/bin/pyonnuka CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'pyonnuka'
4
- require 'pyonnuka/commands/command_task'
4
+ require 'pyonnuka/command'
5
5
 
6
6
  Pyonnuka::Command.discriminate_command(ARGV)
7
7
 
data/lib/pyonnuka.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext'
3
3
  require 'pyonnuka/version'
4
- require 'pyonnuka/app/app_generator'
5
- require 'pyonnuka/helpers/commands'
6
- require 'pyonnuka/app/application'
4
+ require 'pyonnuka/base'
5
+ require 'slim'
7
6
 
8
7
  module Pyonnuka
9
8
  class Application
@@ -0,0 +1,83 @@
1
+ module Pyonnuka
2
+ class Application
3
+ attr_accessor :env, :request, :response, :params
4
+
5
+ def call(env) # :nodoc:
6
+ @request = Rack::Request.new(env)
7
+ @response = Rack::Response.new
8
+ @params = request.params
9
+ @url = request.fullpath()
10
+
11
+ @filename = filename
12
+ file = ::Slim::Template.new(filename, pretty: true).render()
13
+
14
+ [ @response.status.to_i, @response.header, file.split('\n')]
15
+ end
16
+
17
+ def filename
18
+ # TODO: can add rooting
19
+ "app/views#{@url}.html.slim"
20
+ end
21
+
22
+ class Server
23
+ class << self
24
+ def start(command)
25
+ production_option = 'all_of_the_world'
26
+
27
+ if command[1] == production_option
28
+ on_server(' -E production -p 8080 -o 0.0.0.0')
29
+ elsif command[1].nil?
30
+ on_server
31
+ else
32
+ puts "warning: on server with unknown mode #{command[1]}"
33
+ on_server
34
+ end
35
+ end
36
+
37
+ def on_server(option=nil)
38
+ system("rackup #{option}")
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ module Generators
45
+ require 'fileutils'
46
+ require 'erb'
47
+
48
+ class AppGenerator
49
+ def initialize app_name
50
+ @app_name = app_name
51
+ end
52
+
53
+ def start
54
+ puts "Project #{@app_name} is now creating..."
55
+ ::FileUtils.mkdir(@app_name)
56
+
57
+ %w(gemfile configru app config).each do |file|
58
+ self.send("create_#{file}")
59
+ end
60
+ end
61
+
62
+ def create_gemfile
63
+ ::FileUtils.cp(File.join(File.dirname(__FILE__), './templates/Gemfile'), "#{@app_name}/Gemfile")
64
+ end
65
+
66
+ def create_configru
67
+ ::FileUtils.cp(File.join(File.dirname(__FILE__), './templates/config.ru'), "#{@app_name}/config.ru")
68
+ end
69
+
70
+ def create_app
71
+ ::FileUtils.cp_r(File.join(File.dirname(__FILE__), './templates/app/'), "#{@app_name}/app/")
72
+ end
73
+
74
+ def create_config
75
+ ::FileUtils.mkdir("#{@app_name}/config")
76
+ erb = ::ERB.new(File.read(File.join(File.dirname(__FILE__), './templates/config/application.rb')))
77
+ File.open("#{@app_name}/config/application.rb", 'w') do |f|
78
+ f.write(erb.result(binding))
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,50 @@
1
+ module Pyonnuka
2
+ class Command
3
+ class << self
4
+ def discriminate_command(command)
5
+ if command[0].nil?
6
+ out_help
7
+ return
8
+ end
9
+
10
+ case command[0]
11
+ when 'new'
12
+ app_path = command[1]
13
+ return unless validate_app_path(app_path)
14
+ generator = Pyonnuka::Generators::AppGenerator.new(app_path)
15
+ generator.start
16
+ when 'ikeikegogo'
17
+ Pyonnuka::Application::Server.start(ARGV)
18
+ when '-h'
19
+ out_help
20
+ when '-v'
21
+ puts "Pyonnuka #{Pyonnuka::VERSION}"
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ class << self
29
+ def out_help
30
+ puts <<"EOS"
31
+ Example:
32
+ pyonnuka new ~/Code/Ruby/taskapp
33
+
34
+ This generates a skeletal Pyonnuka installation in ~/Code/Ruby/taskapp.
35
+ See the README in the newly created application to get going.
36
+ Pyonnuka options:
37
+ -h # Show this help message
38
+ -v # Show this pyonnuka version
39
+ EOS
40
+ end
41
+
42
+ def validate_app_path(app_path)
43
+ return true if app_path.present? && ['Pyonnuka', 'pyonnuka'].exclude?(app_path)
44
+
45
+ puts app_path.nil? ? 'required application path' : 'Invalid application name pyonnuka. Please choose another name'
46
+ false
47
+ end
48
+ end
49
+ end
50
+ end
@@ -9,11 +9,7 @@ require 'active_support/core_ext/array/extract_options'
9
9
  module Pyonnuka
10
10
  extend ActiveSupport::Autoload
11
11
 
12
- autoload :WelcomeController
13
-
14
12
  class << self
15
- @application = @app_class = nil
16
-
17
13
  def application
18
14
  app = <%= @app_name %>::Application.new
19
15
  end
@@ -22,12 +18,5 @@ end
22
18
 
23
19
  module <%= @app_name %>
24
20
  class Application < Pyonnuka::Application
25
- def call(env)
26
- env["PATH_INFO"]
27
- [ 200,
28
- { 'Content-Type' => 'text/plain' },
29
- ["Ruby on Pyonnuka\n\n\n", "Hello, world!!\n", "Path : #{env["PATH_INFO"]}"]
30
- ]
31
- end
32
21
  end
33
22
  end
@@ -1,3 +1,3 @@
1
1
  module Pyonnuka
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyonnuka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - masaki_nukaga
@@ -116,15 +116,12 @@ files:
116
116
  - bin/pyonnuka
117
117
  - bin/setup
118
118
  - lib/pyonnuka.rb
119
- - lib/pyonnuka/app/app_generator.rb
120
- - lib/pyonnuka/app/application.rb
121
- - lib/pyonnuka/commands/command_task.rb
122
- - lib/pyonnuka/helpers/commands.rb
119
+ - lib/pyonnuka/base.rb
120
+ - lib/pyonnuka/command.rb
123
121
  - lib/pyonnuka/templates/Gemfile
124
122
  - lib/pyonnuka/templates/app/views/welcome/index.html.slim
125
123
  - lib/pyonnuka/templates/config.ru
126
124
  - lib/pyonnuka/templates/config/application.rb
127
- - lib/pyonnuka/templates/config/test.rb
128
125
  - lib/pyonnuka/version.rb
129
126
  - pyonnuka.gemspec
130
127
  homepage: https://github.com/pyonnuka/pyonnuka
@@ -1,44 +0,0 @@
1
- module Pyonnuka
2
- class AppBuilder
3
- end
4
-
5
- module Generators
6
- require 'fileutils'
7
- require 'erb'
8
-
9
- class AppGenerator
10
- def initialize app_name
11
- @app_name = app_name
12
- end
13
-
14
- def start
15
- puts "Project #{@app_name} is now creating..."
16
- ::FileUtils.mkdir(@app_name)
17
-
18
- %w(gemfile configru app config).each do |file|
19
- self.send("create_#{file}")
20
- end
21
- end
22
-
23
- def create_gemfile
24
- ::FileUtils.cp(File.join(File.dirname(__FILE__), '../templates/Gemfile'), "#{@app_name}/Gemfile")
25
- end
26
-
27
- def create_configru
28
- ::FileUtils.cp(File.join(File.dirname(__FILE__), '../templates/config.ru'), "#{@app_name}/config.ru")
29
- end
30
-
31
- def create_app
32
- ::FileUtils.cp_r(File.join(File.dirname(__FILE__), '../templates/app/'), "#{@app_name}/app/")
33
- end
34
-
35
- def create_config
36
- ::FileUtils.mkdir("#{@app_name}/config")
37
- erb = ::ERB.new(File.read(File.join(File.dirname(__FILE__), '../templates/config/application.rb')))
38
- File.open("#{@app_name}/config/application.rb", 'w') do |f|
39
- f.write(erb.result(binding))
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,24 +0,0 @@
1
- module Pyonnuka
2
- class Application
3
- class Server
4
- class << self
5
- def start(command)
6
- production_option = 'all_of_the_world'
7
-
8
- if command[1] == production_option
9
- on_server(' -E production -p 8080 -o 0.0.0.0')
10
- elsif command[1].nil?
11
- on_server
12
- else
13
- puts "warning: on server with unknown mode #{command[1]}"
14
- on_server
15
- end
16
- end
17
-
18
- def on_server(option=nil)
19
- system("rackup #{option}")
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,26 +0,0 @@
1
- module Pyonnuka
2
- class Command < Pyonnuka::Helpers::Command
3
- class << self
4
- def discriminate_command(command)
5
- if command[0].nil?
6
- out_help
7
- return
8
- end
9
-
10
- case command[0]
11
- when 'new'
12
- app_path = command[1]
13
- return unless validate_app_path(app_path)
14
- generator = Pyonnuka::Generators::AppGenerator.new(app_path)
15
- generator.start
16
- when 'ikeikegogo'
17
- Pyonnuka::Application::Server.start(ARGV)
18
- when '-h'
19
- out_help
20
- when '-v'
21
- puts "Pyonnuka #{Pyonnuka::VERSION}"
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,27 +0,0 @@
1
- module Pyonnuka
2
- module Helpers
3
- class Command
4
- class << self
5
- def out_help
6
- puts <<"EOS"
7
- Example:
8
- pyonnuka new ~/Code/Ruby/taskapp
9
-
10
- This generates a skeletal Pyonnuka installation in ~/Code/Ruby/taskapp.
11
- See the README in the newly created application to get going.
12
- Pyonnuka options:
13
- -h # Show this help message
14
- -v # Show this pyonnuka version
15
- EOS
16
- end
17
-
18
- def validate_app_path(app_path)
19
- return true if app_path.present? && ['Pyonnuka', 'pyonnuka'].exclude?(app_path)
20
-
21
- puts app_path.nil? ? 'required application path' : 'Invalid application name pyonnuka. Please choose another name'
22
- false
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,4 +0,0 @@
1
- require 'erb'
2
-
3
- file = ERB.new(File.read('./application.rb')).result(binding)
4
- puts file