cear 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1af13bf5e34cce4e32cc71334f97c02fc428f093
4
+ data.tar.gz: 3c1057f65d778b315d11bc455125fd40113cc76e
5
+ SHA512:
6
+ metadata.gz: 68f3f32d3d5ec8d98b3b6e77661f30c315c76186f5fd91cd349234c09b7250e3e4990987639ad4859ad38bd051bfbc00e52b72b369a21e255fb1bf3206e8eb50
7
+ data.tar.gz: df426ffaecb3506c062c103ed3f6931d305c40e2ca45e8f606bd5a39cb231a4ef51acda88ee655df8531f3ec657eed25dddb3b0acf92350c85e7e7661f29a89e
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /cear-*.gem
@@ -0,0 +1,2 @@
1
+ 2.2.1
2
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cear.gemspec
4
+
5
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Gaëtan JUVIN
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ ====
2
+
3
+ CEAR
4
+ ------------
5
+ Creator Empty App Ruby is an internal project to provide a skeleton for ruby app.
6
+ Based on Rails structure it will generate a structure like :
7
+ ```
8
+ new_project
9
+ Gemfile
10
+ Rakefile
11
+ app
12
+ config
13
+ application.rb
14
+ database.yaml
15
+ environment.rb
16
+ db
17
+ lib
18
+ log
19
+ tmp
20
+ new_project.rb
21
+ ```
22
+
23
+ Roadmap
24
+ -------
25
+ - Custom template
26
+ - Library API
27
+
28
+ Testing
29
+ --------------
30
+ Soon.
31
+
32
+ License
33
+ -------
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2013-2015 Gaëtan JUVIN
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cear'
4
+
5
+ Cear.run(ARGV[0])
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cear"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cear/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cear"
8
+ spec.version = Cear::VERSION
9
+ spec.authors = ['Gaëtan JUVIN']
10
+ spec.email = ['gaetanjuvin@gmail.com']
11
+
12
+ spec.summary = %q{Ruby project generator.}
13
+ spec.description = %q{Ruby project generator.}
14
+ spec.homepage = 'https://github.com/GaetanJUVIN/mail'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.executables = ["cear"]
27
+ spec.bindir = "bin"
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "bundler", "~> 1.10"
31
+ spec.add_dependency "rake", "~> 10.0"
32
+
33
+ spec.add_runtime_dependency "actionpack", '~> 0'
34
+ spec.add_runtime_dependency "activerecord", '~> 3'
35
+ spec.add_runtime_dependency "colorize", '~> 0'
36
+ spec.add_runtime_dependency "pry", '~> 0'
37
+ spec.add_runtime_dependency "awesome_print", '~> 0'
38
+
39
+ spec.post_install_message = "Super message"
40
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ #encoding: utf-8
3
+
4
+ ##
5
+ ## cear.rb
6
+ ## Gaetan JUVIN 15/07/2015
7
+ ##
8
+
9
+ require 'active_record'
10
+ require 'colorize'
11
+ require 'active_support/inflector'
12
+ require 'pty'
13
+
14
+ require 'cear/version'
15
+ require 'cear/file'
16
+ require 'cear/project'
17
+ require 'cear/ask_question/ask_question'
18
+
19
+ module Cear
20
+ def self.run(__app_name = nil)
21
+ if __app_name != nil and __app_name.end_with?('.rb')
22
+ Cear::File.run(__app_name)
23
+ else
24
+ Cear::Project.run(__app_name)
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,23 @@
1
+ class AskQuestion
2
+ def initialize(__question, __default = nil)
3
+ @question = __question
4
+ @default = __default
5
+ end
6
+
7
+ def ask
8
+ line = nil
9
+ while line == nil
10
+ print "#{@question} #{@default ? "[#{@default}] " : ""}"
11
+ STDOUT.flush
12
+ line = STDIN.gets.chomp
13
+ if line.empty?
14
+ if @default
15
+ return @default
16
+ else
17
+ line = nil
18
+ end
19
+ end
20
+ end
21
+ return line.downcase
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ #encoding: utf-8
2
+
3
+ ##
4
+ ## file.rb
5
+ ## Gaetan JUVIN 15/07/2015
6
+ ##
7
+
8
+ module Cear
9
+ class File
10
+ def initialize(__app_name, options = {})
11
+ @app_name = __app_name
12
+ @options = options
13
+ end
14
+
15
+ def self.run(__app_name, options = {})
16
+ Cear::File.new(__app_name, options).run
17
+ end
18
+
19
+ def run
20
+ generate_file(@app_name)
21
+ end
22
+
23
+ def add_gems(condition, gems)
24
+ condition ? gems.map {|g| "gem '#{g}'"}.join("\n") : ""
25
+ end
26
+
27
+ def template_exists?(file)
28
+ ::File.exists?(::File.expand_path("../../template/#{file}", __FILE__))
29
+ end
30
+
31
+ def file_generator(file)
32
+ eval('"' + ::File.open(::File.expand_path("../../template/#{file}", __FILE__)).read + '"', binding, __FILE__, __LINE__)
33
+ end
34
+
35
+ def generate_file(filename, options = {})
36
+ @filename = filename
37
+ options = {header: true}.merge(@options).merge(options)
38
+
39
+ if ::File.exists?(@filename) == false or AskQuestion.new("Replace file #{@filename}?", "n/Y").ask != 'n'
40
+ puts "Generate #{filename}".green
41
+ ::File.open(@filename, 'w') do |file|
42
+ file.write(file_generator('header') + "\n") if options[:header]
43
+ if template_exists?(@filename)
44
+ file.write(file_generator(@filename))
45
+ else
46
+ file.write("# require ::File.expand_path('../config/environment', __FILE__)\n")
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,87 @@
1
+ #encoding: utf-8
2
+
3
+ ##
4
+ ## project.rb
5
+ ## Gaetan JUVIN 15/07/2015
6
+ ##
7
+
8
+ # get name
9
+ # ask db
10
+ # ask redis
11
+ # create main directory
12
+ # create Gemfile
13
+ # create other directory [app, config, db, lib, log, tmp]
14
+ # add 2 line at the top of name.rb
15
+
16
+
17
+ # What is the project name ?
18
+ # Do you want to include redis ?
19
+ # Do you want to include pg ?
20
+
21
+ module Cear
22
+ class Project
23
+ def initialize(__app_name = nil)
24
+ @app_name = __app_name
25
+ end
26
+
27
+ def run_bundle
28
+ puts "Run bundle install...".yellow
29
+ begin
30
+ PTY.spawn("bundle") do |stdout, stdin, pid|
31
+ begin
32
+ # Do stuff with the output here. Just printing to show it works
33
+ stdout.each { |line| print line;STDOUT.flush }
34
+ rescue Errno::EIO
35
+ puts "Errno:EIO error, but this probably just means " +
36
+ "that the process has finished giving output"
37
+ end
38
+ end
39
+ rescue PTY::ChildExited
40
+ puts "The child process exited!"
41
+ end
42
+ puts "Run bundle install OK".green
43
+ end
44
+
45
+ def self.run(__app_name)
46
+ Cear::Project.new(__app_name).run
47
+ end
48
+
49
+ def run
50
+ if @app_name == nil
51
+ @app_name = AskQuestion.new("What is the project name?").ask
52
+ end
53
+ @include_pg = AskQuestion.new("Do you want to include pg?", "N/y").ask == 'y'
54
+ @include_redis = AskQuestion.new("Do you want to include redis?", "N/y").ask == 'y'
55
+ @include_rake = AskQuestion.new("Do you want to include rake?", "N/y").ask == 'y'
56
+ @include_advance = AskQuestion.new("Do you want advance mode ? (included subdirectories 'app', 'log', 'tmp')", "N/y").ask == 'y'
57
+ @app_name = @app_name.underscore.gsub(' ', '_')
58
+
59
+ Dir.mkdir(@app_name) unless ::File.exists?(@app_name)
60
+ Dir.chdir(@app_name) do |dir|
61
+ Cear::File.run('Gemfile', header: false)
62
+ Cear::File.run(@app_name + '.rb')
63
+ Cear::File.run('console.rb')
64
+
65
+ directories = ['config', 'lib']
66
+ directories << 'db' if @include_pg
67
+ directories += ['app', 'log', 'tmp'] if @include_advance
68
+ puts "Create directories | #{directories.join(' - ')}".light_green
69
+
70
+ directories.each do |subdirectory|
71
+ Dir.mkdir(subdirectory) unless ::File.exists?(subdirectory)
72
+ end
73
+
74
+ Dir.chdir('config') do |dir|
75
+ Cear::File.run('environment.rb')
76
+ Cear::File.run('application.rb')
77
+ Cear::File.run('database.yaml', header: false) if @include_pg
78
+ end
79
+
80
+ if @include_rake
81
+ Cear::File.run('Rakefile')
82
+ end
83
+ run_bundle
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,3 @@
1
+ module Cear
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'actionpack'
4
+ gem 'activesupport'
5
+ gem 'activerecord', :require => 'active_record'
6
+
7
+ gem 'colorize'
8
+ gem 'pry'
9
+ gem 'awesome_print'
10
+
11
+ #{add_gems(@include_pg, ['pg', 'postgres_ext', 'standalone_migrations'])}
12
+ #{add_gems(@include_redis, ['redis'])}
@@ -0,0 +1,2 @@
1
+ require File.expand_path('../config/application', __FILE__)
2
+ #{@include_pg ? '' : "\nStandaloneMigrations::Tasks.load_tasks"}
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH << '.'
2
+
3
+ $LOAD_PATH << 'lib/'
4
+
5
+ require 'bundler'
6
+ Bundler.require
7
+
8
+ class App
9
+ class << self
10
+ attr_accessor :env
11
+ end
12
+ end
13
+
14
+ App.env = ENV['APP_ENV'] || 'development'
15
+
16
+ # load all models
17
+ # Dir['app/models/*.rb'].each {|name| require name}
18
+ #{@include_pg ? "\nActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))[App.env])" : ''}
@@ -0,0 +1,3 @@
1
+ require ::File.expand_path('../config/environment', __FILE__)
2
+
3
+ binding.pry
@@ -0,0 +1,12 @@
1
+ base: &base
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: 25
5
+ host: localhost
6
+ timeout: 5000
7
+ username: #{ENV['USER']}
8
+ password:
9
+
10
+ development:
11
+ database: #{@app_name}_dev
12
+ <<: *base
@@ -0,0 +1,6 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ require File.expand_path('../application', __FILE__)
5
+
6
+ #ActiveRecord::Base.logger = Logger.new(STDOUT)
@@ -0,0 +1,6 @@
1
+ #encoding: utf-8
2
+
3
+ ##
4
+ ## #{@filename}
5
+ ## Gaetan JUVIN #{Time.now.to_date.strftime('%d/%m/%Y')}
6
+ ##
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cear
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gaëtan JUVIN
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activerecord
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: awesome_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby project generator.
112
+ email:
113
+ - gaetanjuvin@gmail.com
114
+ executables:
115
+ - cear
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".ruby-version"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/cear
126
+ - bin/console
127
+ - bin/setup
128
+ - cear.gemspec
129
+ - lib/cear.rb
130
+ - lib/cear/ask_question/ask_question.rb
131
+ - lib/cear/file.rb
132
+ - lib/cear/project.rb
133
+ - lib/cear/version.rb
134
+ - lib/template/Gemfile
135
+ - lib/template/Rakefile
136
+ - lib/template/application.rb
137
+ - lib/template/console.rb
138
+ - lib/template/database.yaml
139
+ - lib/template/environment.rb
140
+ - lib/template/header
141
+ homepage: https://github.com/GaetanJUVIN/mail
142
+ licenses:
143
+ - MIT
144
+ metadata:
145
+ allowed_push_host: https://rubygems.org
146
+ post_install_message: Super message
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.4.5
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Ruby project generator.
166
+ test_files: []