ricque 0.1.3 → 1.0.0.alpha

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ricque +3 -30
  3. data/lib/ricque/command.rb +11 -0
  4. data/lib/ricque/template.rb +67 -0
  5. data/lib/ricque/templates/.rspec +2 -0
  6. data/lib/ricque/templates/.rubocop.yml +18 -0
  7. data/lib/ricque/templates/.ruby-version +1 -0
  8. data/lib/ricque/templates/Gemfile +6 -0
  9. data/lib/ricque/templates/README.md.tt +24 -0
  10. data/lib/{template/Rakefile → ricque/templates/Rakefile.tt} +1 -1
  11. data/lib/ricque/templates/config/application.rb.tt +6 -0
  12. data/lib/ricque/templates/config/boot.rb.tt +58 -0
  13. data/lib/{template/config/environment.rb → ricque/templates/config/environment.rb.tt} +1 -1
  14. data/lib/ricque/templates/config/initializers/logger.rb.tt +1 -0
  15. data/lib/ricque/templates/lib/tasks/%project%.rake.tt +4 -0
  16. data/lib/ricque/templates/rspec/.rspec +2 -0
  17. data/lib/ricque/templates/rspec/spec/spec_helper.rb +14 -0
  18. data/lib/ricque/templates/script/console +10 -0
  19. data/lib/ricque/version.rb +2 -2
  20. data/lib/ricque.rb +5 -26
  21. metadata +100 -38
  22. data/lib/ricque/app_generator.rb +0 -62
  23. data/lib/template/.rspec +0 -4
  24. data/lib/template/Gemfile +0 -16
  25. data/lib/template/Gemfile.lock +0 -35
  26. data/lib/template/README +0 -0
  27. data/lib/template/config/application.rb +0 -91
  28. data/lib/template/config/boot.rb +0 -69
  29. data/lib/template/config/environments/development.rb +0 -3
  30. data/lib/template/config/environments/production.rb +0 -3
  31. data/lib/template/config/environments/test.rb +0 -3
  32. data/lib/template/config/initializers/00_logger.rb +0 -1
  33. data/lib/template/doc/README_FOR_APP +0 -0
  34. data/lib/template/lib/ricque/version.rb +0 -3
  35. data/lib/template/lib/ricque.rb +0 -5
  36. data/lib/template/lib/tasks/ricque.rake +0 -4
  37. data/lib/template/lib/tasks/rspec.rake +0 -10
  38. data/lib/template/script/console +0 -34
  39. data/lib/template/spec/spec_helper.rb +0 -29
  40. /data/lib/{template → ricque/templates}/.gitignore +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8238b52c47ac8db2af76235142fec4a28c64532b
4
+ data.tar.gz: dc797205d6c5a9219fe049ef2e5e0150b26dddc0
5
+ SHA512:
6
+ metadata.gz: ac6732dd3006fa55d335b2738adb31dbb5781c63b996840731dbe2ddcc5c6ef3edc3ac17745dafb7e8c5ff28c6e9e08bfa03abf341625c73e4d3f416e7912e0c
7
+ data.tar.gz: eac10316219c79f3f4c33270e1bb4d6eba6de7c894141597c490aba370e723f2942a4b0bd20732e5a708c90002d6cc4c91236b63279e6bab5da4337499f617ce
data/bin/ricque CHANGED
@@ -1,32 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $:.push File.expand_path("../../lib", __FILE__)
2
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
3
+ require File.expand_path('../../lib/ricque', __FILE__)
3
4
 
4
- require File.expand_path("../../lib/ricque", __FILE__)
5
-
6
- Ricque.initialize!
7
-
8
- case ARGV[0]
9
- when 'new'
10
- if ARGV[1].nil?
11
- puts 'Invalid application name'
12
- exit
13
- end
14
- app_name = ARGV[1].underscore
15
-
16
- begin
17
- Ricque::AppGenerator
18
- .new(app_name)
19
- .create!
20
- rescue Exception => ex
21
- puts "\n"
22
- puts "=" * 70
23
- puts "FATAL ERROR\n\n"
24
- puts "The following error occurred while trying to create the app:\n"
25
- puts "\tError: #{ex}"
26
- puts "\tBacktrace: \n\t\t#{ex.backtrace.join("\n\t\t")}"
27
- exit 1
28
- end
29
-
30
- else
31
- puts "Usage: ricque new [app_name]"
32
- end
5
+ Ricque::Command.start
@@ -0,0 +1,11 @@
1
+ module Ricque
2
+ class Command < Thor
3
+ register(
4
+ Template, 'new',
5
+ 'new [PROJECT_NAME]',
6
+ "Create a template app \n Options:\n\n" \
7
+ " --test-framework=rspec (default: rspec)\n" \
8
+ ' --app-server=unicorn (default: none)'
9
+ )
10
+ end
11
+ end
@@ -0,0 +1,67 @@
1
+ module Ricque
2
+ class Template < Thor::Group
3
+ include Thor::Actions
4
+
5
+ argument :project, type: :string
6
+ class_option :test_framework, default: 'rspec'
7
+ class_option :app_server, default: 'none'
8
+
9
+ def self.source_root(path = nil)
10
+ @_source_root = path if path
11
+ @_source_root ||= File.join(File.dirname(__FILE__), 'templates')
12
+ end
13
+
14
+ def underscorize_project_name
15
+ @project = @project.underscore
16
+ end
17
+
18
+ def structure
19
+ directory('.', dest_dir, recursive: false)
20
+ end
21
+
22
+ def config_dir
23
+ directory('config', dest_dir('config'))
24
+ end
25
+
26
+ def app_dir
27
+ directory('app', dest_dir('app'))
28
+ end
29
+
30
+ def lib_dir
31
+ directory('lib', dest_dir('lib'))
32
+ end
33
+
34
+ def script_dir
35
+ directory('script', dest_dir('script'))
36
+ chmod(dest_dir('script/console'), 'a+x')
37
+ end
38
+
39
+ def rspec
40
+ return unless options[:test_framework] == 'rspec'
41
+ directory('rspec', dest_dir)
42
+ append_to_file(dest_dir('Gemfile')) do
43
+ "\ngroup :test do\n" \
44
+ " gem 'rspec'\n" \
45
+ " gem 'simplecov'\n" \
46
+ " gem 'simplecov-rcov'\n" \
47
+ 'end'
48
+ end
49
+ end
50
+
51
+ def finish
52
+ say("\n === App #{project} created in #{full_path}")
53
+ end
54
+
55
+ private
56
+
57
+ def full_path
58
+ File.expand_path(dest_dir)
59
+ end
60
+
61
+ def dest_dir(path = nil)
62
+ dest = project.downcase
63
+ dest << "/#{path}" if path
64
+ dest
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --require spec_helper
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ # Include gemspec and Rakefile
3
+ Include:
4
+ - '**/*.gemspec'
5
+ - '**/Rakefile'
6
+ Exclude:
7
+ - 'vendor/**/*'
8
+ - 'db/**/*'
9
+ - 'config/unicorn.rb'
10
+ # By default, the rails cops are not run. Override in project or home
11
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
12
+ RunRailsCops: false
13
+
14
+ Style/SingleLineBlockParams:
15
+ Enabled: false
16
+
17
+ Documentation:
18
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development, :test do
4
+ gem 'pry'
5
+ gem 'pry-byebug'
6
+ end
@@ -0,0 +1,24 @@
1
+ # <%= project.camelize %>
2
+
3
+ Your App description goes here
4
+
5
+ ## Console
6
+
7
+ $ script/console
8
+
9
+
10
+ ## Configuration
11
+
12
+ The app's configurations are in `<%= project.camelize %>.config` and you
13
+ can set anything you want under this, because it is an `OpenStruct`.
14
+
15
+ ### After initialization
16
+
17
+ If you need to initialize something, after the app's initialization, you should
18
+ do this
19
+
20
+ <%= project.camelize %>.after_initialize do
21
+ # your code goes where
22
+ end
23
+
24
+
@@ -1,3 +1,3 @@
1
1
  require File.expand_path('../config/application', __FILE__)
2
2
 
3
- Ricque.load_tasks
3
+ <%= project.camelize %>.load_tasks
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ Bundler.require('default', ENV['RUBY_ENV'] || 'development')
4
+
5
+ module <%= project.camelize %>
6
+ end
@@ -0,0 +1,58 @@
1
+ require 'logger'
2
+ require 'ostruct'
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
6
+
7
+ module <%= project.camelize %>
8
+ module_function
9
+
10
+ def root
11
+ @root ||= ::File.expand_path('../..', __FILE__)
12
+ end
13
+
14
+ def initialize!
15
+ load_path 'config/initializers'
16
+ load_path 'app'
17
+ execute_after_initialize_blocks
18
+ end
19
+
20
+ def after_initialize(&block)
21
+ @after_initialize_blocks ||= []
22
+ @after_initialize_blocks << block
23
+ end
24
+
25
+ def load_tasks
26
+ load_path 'lib/tasks', extension: 'rake', type: :load
27
+ end
28
+
29
+ def config
30
+ @config ||= OpenStruct.new
31
+ end
32
+
33
+ def logger
34
+ config.logger ||= Logger.new(STDOUT)
35
+ end
36
+
37
+ def logger=(logger)
38
+ config.logger = logger
39
+ end
40
+
41
+ def execute_after_initialize_blocks
42
+ return if @after_initialize_blocks.nil?
43
+ @after_initialize_blocks.each(&:call)
44
+ @after_initialize_blocks.clear
45
+ end
46
+
47
+ def load_path(path, extension: 'rb', type: :require)
48
+ full_path = ::File.join(root, path, '**', "*.#{extension}")
49
+ files = ::Dir[full_path].sort
50
+ files.each do |file|
51
+ if type == :require
52
+ require(file)
53
+ else
54
+ load(file)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  require File.expand_path('../application', __FILE__)
2
2
 
3
- Ricque.initialize!
3
+ <%= project.camelize %>.initialize!
@@ -0,0 +1 @@
1
+ <%= project.camelize %>.logger.level = Logger::INFO
@@ -0,0 +1,4 @@
1
+ desc 'Load <%= project.camelize %>\'s environment'
2
+ task :environment do
3
+ <%= project.camelize %>.initialize!
4
+ end
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ ENV['RUBY_ENV'] = ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'simplecov'
4
+ require 'simplecov-rcov'
5
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
+ SimpleCov.start do
7
+ add_filter '/spec/'
8
+ end
9
+
10
+ require File.expand_path('../../config/environment', __FILE__)
11
+
12
+ RSpec.configure do |config|
13
+ config.order = 'random'
14
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+
4
+ begin
5
+ require 'pry'
6
+ Pry.start
7
+ exit
8
+ rescue LoadError
9
+ warn '=> Unable to load pry'
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Ricque
2
- VERSION = "0.1.3"
3
- end
2
+ VERSION = '1.0.0.alpha'
3
+ end
data/lib/ricque.rb CHANGED
@@ -1,29 +1,8 @@
1
- require 'rubygems'
1
+ require 'thor'
2
2
  require 'active_support/inflector'
3
- require 'fileutils'
3
+ require_relative 'ricque/version'
4
+ require_relative 'ricque/template'
5
+ require_relative 'ricque/command'
4
6
 
5
7
  module Ricque
6
- def self.root
7
- ::File.expand_path('../..', __FILE__)
8
- end
9
-
10
- def self.template_path
11
- ::File.join(root, 'lib', 'template', '.')
12
- end
13
-
14
- def self.lib_path
15
- ::File.join(::File.expand_path("lib/ricque", self.root), '**', '*.rb')
16
- end
17
-
18
- def self.initialize!
19
- load_path lib_path
20
- end
21
-
22
- private
23
-
24
- def self.load_path path
25
- files = ::Dir[path]
26
- files.each { |file| load file }
27
- nil
28
- end
29
- end
8
+ end
metadata CHANGED
@@ -1,32 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ricque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 1.0.0.alpha
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ricardo Tealdi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: activesupport
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
- - - ! '>='
31
+ - - ">="
20
32
  - !ruby/object:Gem::Version
21
- version: 3.2.9
33
+ version: '0'
22
34
  type: :runtime
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
28
81
  - !ruby/object:Gem::Version
29
- version: 3.2.9
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov-rcov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
30
97
  description: Ricque is a generator of Ruby applications with bootstrap similar to
31
98
  Rails' bootstrap
32
99
  email:
@@ -36,54 +103,49 @@ executables:
36
103
  extensions: []
37
104
  extra_rdoc_files: []
38
105
  files:
106
+ - bin/ricque
39
107
  - lib/ricque.rb
40
- - lib/template/README
41
- - lib/template/.gitignore
42
- - lib/template/script/console
43
- - lib/template/Gemfile.lock
44
- - lib/template/doc/README_FOR_APP
45
- - lib/template/spec/spec_helper.rb
46
- - lib/template/lib/ricque.rb
47
- - lib/template/lib/ricque/version.rb
48
- - lib/template/lib/tasks/ricque.rake
49
- - lib/template/lib/tasks/rspec.rake
50
- - lib/template/.rspec
51
- - lib/template/config/boot.rb
52
- - lib/template/config/environments/development.rb
53
- - lib/template/config/environments/production.rb
54
- - lib/template/config/environments/test.rb
55
- - lib/template/config/initializers/00_logger.rb
56
- - lib/template/config/application.rb
57
- - lib/template/config/environment.rb
58
- - lib/template/Gemfile
59
- - lib/template/Rakefile
108
+ - lib/ricque/command.rb
109
+ - lib/ricque/template.rb
110
+ - lib/ricque/templates/.gitignore
111
+ - lib/ricque/templates/.rspec
112
+ - lib/ricque/templates/.rubocop.yml
113
+ - lib/ricque/templates/.ruby-version
114
+ - lib/ricque/templates/Gemfile
115
+ - lib/ricque/templates/README.md.tt
116
+ - lib/ricque/templates/Rakefile.tt
117
+ - lib/ricque/templates/config/application.rb.tt
118
+ - lib/ricque/templates/config/boot.rb.tt
119
+ - lib/ricque/templates/config/environment.rb.tt
120
+ - lib/ricque/templates/config/initializers/logger.rb.tt
121
+ - lib/ricque/templates/lib/tasks/%project%.rake.tt
122
+ - lib/ricque/templates/rspec/.rspec
123
+ - lib/ricque/templates/rspec/spec/spec_helper.rb
124
+ - lib/ricque/templates/script/console
60
125
  - lib/ricque/version.rb
61
- - lib/ricque/app_generator.rb
62
- - bin/ricque
63
126
  homepage:
64
127
  licenses:
65
128
  - MIT
129
+ metadata: {}
66
130
  post_install_message:
67
131
  rdoc_options: []
68
132
  require_paths:
69
133
  - lib
70
134
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
135
  requirements:
73
- - - ! '>='
136
+ - - ">="
74
137
  - !ruby/object:Gem::Version
75
138
  version: '0'
76
139
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
140
  requirements:
79
- - - ! '>='
141
+ - - ">"
80
142
  - !ruby/object:Gem::Version
81
- version: '0'
143
+ version: 1.3.1
82
144
  requirements: []
83
145
  rubyforge_project: ricque
84
- rubygems_version: 1.8.25
146
+ rubygems_version: 2.2.2
85
147
  signing_key:
86
- specification_version: 3
148
+ specification_version: 4
87
149
  summary: Ricque is a generator of Ruby applications with bootstrap similar to Rails'
88
150
  bootstrap
89
151
  test_files: []
@@ -1,62 +0,0 @@
1
- module Ricque
2
- class AppGenerator
3
- def initialize app_name, path=File.expand_path('.')
4
- @app_name = app_name
5
- @path = path
6
- end
7
-
8
- def app_path
9
- File.join(@path, dashesized_app_name)
10
- end
11
-
12
- def camelized_app_name
13
- @app_name.camelize
14
- end
15
-
16
- def dashesized_app_name
17
- @app_name.dasherize
18
- end
19
-
20
- def template_path
21
- Ricque.template_path
22
- end
23
-
24
- def create!
25
- create_path
26
- copy_files
27
- puts "Application created on path #{app_path}"
28
- end
29
-
30
- private
31
-
32
- def create_path
33
- puts "Creating path #{app_path}"
34
- if Dir.exists?(app_path)
35
- puts "Path #{app_path} already exists"
36
- raise ArgumentError, "Path #{app_path} already exists"
37
- end
38
-
39
- Dir.mkdir app_path
40
- end
41
-
42
- def copy_files
43
- Dir.chdir(app_path) do
44
- puts "Copying files"
45
- FileUtils.cp_r template_path, ".", :preserve => true
46
-
47
- puts "Renaming file content"
48
- if RUBY_PLATFORM.downcase.include?("darwin")
49
- sed_args_platform_specific = "''"
50
- else
51
- sed_args_platform_specific = "-e"
52
- end
53
- `grep -Irl "Ricque" . | xargs sed -i #{sed_args_platform_specific} 's/Ricque/#{camelized_app_name}/g'`
54
- `grep -Irl "ricque" . | xargs sed -i #{sed_args_platform_specific} 's/ricque/#{dashesized_app_name}/g'`
55
- `grep -Irl "{RICQUE_VERSION}" . | xargs sed -i #{sed_args_platform_specific}'s/{RICQUE_VERSION}/#{Ricque::VERSION}/g'`
56
-
57
- puts "Renaming files"
58
- `find . -name '*ricque*' | sed -e "p;s/ricque/#{dashesized_app_name}/" | xargs -n2 mv`
59
- end
60
- end
61
- end
62
- end
data/lib/template/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --color
2
- --format=doc
3
- --drb
4
- --require spec_helper
data/lib/template/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- if RUBY_VERSION =~ /1.9/
4
- Encoding.default_external = Encoding::UTF_8
5
- Encoding.default_internal = Encoding::UTF_8
6
- end
7
-
8
- group :test do
9
- gem 'rspec'
10
- gem "simplecov"
11
- gem "simplecov-rcov"
12
- end
13
-
14
- group :development, :debug do
15
- gem 'debugger', :require => 'debugger'
16
- end
@@ -1,35 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- columnize (0.3.6)
5
- debugger (1.6.1)
6
- columnize (>= 0.3.1)
7
- debugger-linecache (~> 1.2.0)
8
- debugger-ruby_core_source (~> 1.2.3)
9
- debugger-linecache (1.2.0)
10
- debugger-ruby_core_source (1.2.3)
11
- diff-lcs (1.1.3)
12
- multi_json (1.5.0)
13
- rspec (2.12.0)
14
- rspec-core (~> 2.12.0)
15
- rspec-expectations (~> 2.12.0)
16
- rspec-mocks (~> 2.12.0)
17
- rspec-core (2.12.2)
18
- rspec-expectations (2.12.1)
19
- diff-lcs (~> 1.1.3)
20
- rspec-mocks (2.12.1)
21
- simplecov (0.7.1)
22
- multi_json (~> 1.0)
23
- simplecov-html (~> 0.7.1)
24
- simplecov-html (0.7.1)
25
- simplecov-rcov (0.2.3)
26
- simplecov (>= 0.4.1)
27
-
28
- PLATFORMS
29
- ruby
30
-
31
- DEPENDENCIES
32
- debugger
33
- rspec
34
- simplecov
35
- simplecov-rcov
data/lib/template/README DELETED
File without changes
@@ -1,91 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- module Ricque
4
-
5
- @@initialized = false
6
-
7
- def self.initialize!
8
- return if @@initialized
9
-
10
- puts "#{"="*5} Loading application Ricque #{"="*40}"
11
- started_at = Time.now
12
-
13
- initializer_files_path = ::File.join(::File.expand_path('initializers', self.config_dir), '**', '*.rb')
14
- environment_file_path = ::File.join(::File.expand_path('environments', self.config_dir), "#{self.env}.rb")
15
- lib_files_path = ::File.join(::File.expand_path("lib/#{app_name}", self.root), '**', '*.rb')
16
- environment = self.env
17
-
18
- if !File.exists?(environment_file_path)
19
- puts "\t* Environment file was not found for [#{self.env}]"
20
- environment = Ricque::DEFAULT_ENVIRONMENT
21
- environment_file_path = ::File.join(::File.expand_path('environments', self.config_dir), "#{Ricque::DEFAULT_ENVIRONMENT}.rb")
22
- end
23
-
24
- load_path environment_file_path, "\t* Loading environment file for [#{environment}]"
25
-
26
- puts "\t* Executing before_initialize_blocks (#{before_initialize_blocks.count})"
27
- execute_before_initialize!
28
-
29
- load_path initializer_files_path, "\t* Loading initializers"
30
-
31
- load_path lib_files_path, "\t* Loading application files"
32
-
33
- puts "\t* Executing after_initialize_blocks (#{after_initialize_blocks.count})"
34
- execute_after_initialize!
35
-
36
- puts "\t* Ricque loaded on environment \"#{ENV["RUBY_ENV"]}\" in #{Time.now - started_at} seconds"
37
- puts "#{"="*5} Application Ricque loaded #{"="*40}"
38
-
39
- @@initialized = true
40
-
41
- nil
42
- end
43
-
44
- def self.initialized?
45
- @@initialized
46
- end
47
-
48
- def self.before_initialize &block
49
- before_initialize_blocks << block
50
- end
51
-
52
- def self.execute_before_initialize!
53
- before_initialize_blocks.each(&:call)
54
- end
55
-
56
- def self.after_initialize &block
57
- after_initialize_blocks << block
58
- end
59
-
60
- def self.execute_after_initialize!
61
- after_initialize_blocks.each(&:call)
62
- end
63
-
64
- def self.configure &block
65
- block.call configuration
66
- end
67
-
68
- def self.load_tasks
69
- tasks_files = ::File.join(::File.expand_path('lib/tasks', self.root), '**', '*.rake')
70
-
71
- ::Dir[tasks_files].each { |it| import it }
72
- end
73
-
74
- private
75
-
76
- def self.after_initialize_blocks
77
- @@after_initialize_blocks ||= []
78
- @@after_initialize_blocks
79
- end
80
-
81
- def self.before_initialize_blocks
82
- @@before_initialize_blocks ||= []
83
- @@before_initialize_blocks
84
- end
85
-
86
- def self.load_path path, message
87
- files = ::Dir[path]
88
- puts "#{message} (#{files.size})"
89
- files.sort.each { |file| require file }
90
- end
91
- end
@@ -1,69 +0,0 @@
1
- require 'logger'
2
-
3
- module Ricque
4
- APP_NAME = 'ricque'
5
- DEFAULT_ENVIRONMENT = 'development'
6
- APP_ROOT = ::File.expand_path('../..', __FILE__)
7
- CONFIG_ROOT = ::File.expand_path('config', APP_ROOT)
8
- LIB_DIR = ::File.expand_path("lib/#{APP_NAME}", APP_ROOT)
9
- RICQUE_VERSION = '{RICQUE_VERSION}'
10
-
11
- def self.app_name
12
- APP_NAME
13
- end
14
-
15
- def self.lib_dir
16
- LIB_DIR
17
- end
18
-
19
- def self.config_dir
20
- CONFIG_ROOT
21
- end
22
-
23
- def self.config_dir= config_dir
24
- CONFIG_ROOT
25
- end
26
-
27
- def self.root
28
- APP_ROOT
29
- end
30
-
31
- def self.env
32
- ENV["RUBY_ENV"]
33
- end
34
-
35
- def self.groups
36
- ENV["BUNDLER_GROUPS"].split(',')
37
- end
38
-
39
- def self.configuration
40
- @@config ||= {}
41
- @@config
42
- end
43
-
44
- def self.logger= logger
45
- configuration[:logger] = logger
46
- end
47
-
48
- def self.logger
49
- configuration[:logger] ||= Logger.new(STDOUT)
50
- end
51
-
52
- def self.logger?
53
- !configuration[:logger].nil?
54
- end
55
-
56
- def self.development?
57
- ENV["RUBY_ENV"] == "development"
58
- end
59
- end
60
-
61
- ENV["RUBY_ENV"] = ENV["RUBY_ENV"] || ENV["RACK_ENV"] || Ricque::DEFAULT_ENVIRONMENT
62
- ENV["RACK_ENV"] = ENV["RUBY_ENV"]
63
-
64
- ENV["BUNDLER_GROUPS"] = "default,#{ENV["RUBY_ENV"]}"
65
-
66
- require 'rubygems'
67
- require 'bundler/setup'
68
-
69
- Bundler.require(*ENV["BUNDLER_GROUPS"].split(','))
@@ -1,3 +0,0 @@
1
- Ricque.configure do |config|
2
- config[:log_level] = :debug
3
- end
@@ -1,3 +0,0 @@
1
- Ricque.configure do |config|
2
- config[:log_level] = :info
3
- end
@@ -1,3 +0,0 @@
1
- Ricque.configure do |config|
2
- config[:log_level] = :debug
3
- end
@@ -1 +0,0 @@
1
- Ricque.logger = Logger.new(STDOUT) if Ricque.logger.nil?
File without changes
@@ -1,3 +0,0 @@
1
- module Ricque
2
- VERSION = "0.0.1"
3
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path('../../config/application', __FILE__)
2
-
3
- module Ricque
4
-
5
- end
@@ -1,4 +0,0 @@
1
- desc "Load Ricque environment"
2
- task :environment do
3
- require File.expand_path('config/environment', Ricque.root)
4
- end
@@ -1,10 +0,0 @@
1
- begin
2
- require 'rspec/core'
3
- require 'rspec/core/rake_task'
4
-
5
- RSpec::Core::RakeTask.new(:spec) do |t|
6
- t.rspec_opts = "--require spec_helper"
7
- end
8
- rescue Exception => ex
9
- warn "Rspec tasks not loaded... #{ex}"
10
- end
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
-
5
- options = {}
6
-
7
- OptionParser.new do |opt|
8
- opt.banner = "Usage: console [environment] [options]"
9
- opt.on("-e", "--environment=name", String,
10
- "Specifies the environment to run this console under (test/development/production).",
11
- "Default: development") { |v| options[:environment] = v.strip }
12
- opt.on("-d", "--debugger", 'Enable the debugger.') { |v| options[:debugger] = v }
13
- opt.parse!(ARGV)
14
- end
15
-
16
- if ARGV.first && ARGV.first[0] != '-'
17
- env = ARGV.first
18
- options[:environment] = env
19
- ARGV.shift
20
- end
21
-
22
- ENV["RUBY_ENV"] = options[:environment] if options[:environment]
23
-
24
- if options[:debugger]
25
- require 'ruby-debug'
26
- puts "=> Debugger enabled"
27
- end
28
-
29
- require File.expand_path('../../config/environment', __FILE__)
30
-
31
- require 'irb'
32
- require 'irb/completion'
33
-
34
- IRB.start
@@ -1,29 +0,0 @@
1
- ENV["RUBY_ENV"] = ENV["RACK_ENV"] = 'test'
2
-
3
- require 'simplecov'
4
- require 'simplecov-rcov'
5
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
- SimpleCov.start 'rails' do
7
- add_filter "/spec/"
8
- end
9
-
10
- require File.expand_path("../../config/environment", __FILE__)
11
-
12
- require 'rspec/autorun'
13
- # require 'factory_girl'
14
- # require 'database_cleaner'
15
-
16
- Dir["#{Ricque.root}/spec/support/**/*.rb"].each {|f| require f}
17
-
18
- RSpec.configure do |config|
19
-
20
- # config.include FactoryGirl::Syntax::Methods
21
-
22
- # config.before(:suite) do
23
- # end
24
-
25
- # config.after(:each) do
26
- # end
27
-
28
- config.order = "random"
29
- end
File without changes