rails-defaults 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7ea93ecba5f2aa37145ae735fb115477f392ceb
4
+ data.tar.gz: 259be83a014b37f4c310bf2a9172445842b43816
5
+ SHA512:
6
+ metadata.gz: 783600bf0a7e089d2f73fd49f6a55b49afd9c34435a79beb0729f235e413d66388f1f5f99b96b3deb34141407e741e223cc24b6763c8b11598cfde41cf8781eb
7
+ data.tar.gz: 308890316952d1b09891285ae0a4d698211ce56762ab126d1d5ae358e0a3dc958875c9362c038348ea5f71ea0321b8ced53c398318f8a0ffd4c5926ccb564a82
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails-defaults (1.0.0)
5
+ rack
6
+ rails
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (4.0.4)
12
+ actionpack (= 4.0.4)
13
+ mail (~> 2.5.4)
14
+ actionpack (4.0.4)
15
+ activesupport (= 4.0.4)
16
+ builder (~> 3.1.0)
17
+ erubis (~> 2.7.0)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ activemodel (4.0.4)
21
+ activesupport (= 4.0.4)
22
+ builder (~> 3.1.0)
23
+ activerecord (4.0.4)
24
+ activemodel (= 4.0.4)
25
+ activerecord-deprecated_finders (~> 1.0.2)
26
+ activesupport (= 4.0.4)
27
+ arel (~> 4.0.0)
28
+ activerecord-deprecated_finders (1.0.3)
29
+ activesupport (4.0.4)
30
+ i18n (~> 0.6, >= 0.6.9)
31
+ minitest (~> 4.2)
32
+ multi_json (~> 1.3)
33
+ thread_safe (~> 0.1)
34
+ tzinfo (~> 0.3.37)
35
+ arel (4.0.2)
36
+ builder (3.1.4)
37
+ erubis (2.7.0)
38
+ hike (1.2.3)
39
+ i18n (0.6.9)
40
+ mail (2.5.4)
41
+ mime-types (~> 1.16)
42
+ treetop (~> 1.4.8)
43
+ mime-types (1.25.1)
44
+ minitest (4.7.5)
45
+ multi_json (1.9.2)
46
+ polyglot (0.3.4)
47
+ rack (1.5.2)
48
+ rack-test (0.6.2)
49
+ rack (>= 1.0)
50
+ rails (4.0.4)
51
+ actionmailer (= 4.0.4)
52
+ actionpack (= 4.0.4)
53
+ activerecord (= 4.0.4)
54
+ activesupport (= 4.0.4)
55
+ bundler (>= 1.3.0, < 2.0)
56
+ railties (= 4.0.4)
57
+ sprockets-rails (~> 2.0.0)
58
+ railties (4.0.4)
59
+ actionpack (= 4.0.4)
60
+ activesupport (= 4.0.4)
61
+ rake (>= 0.8.7)
62
+ thor (>= 0.18.1, < 2.0)
63
+ rake (10.2.2)
64
+ sprockets (2.12.0)
65
+ hike (~> 1.2)
66
+ multi_json (~> 1.0)
67
+ rack (~> 1.0)
68
+ tilt (~> 1.1, != 1.3.0)
69
+ sprockets-rails (2.0.1)
70
+ actionpack (>= 3.0)
71
+ activesupport (>= 3.0)
72
+ sprockets (~> 2.8)
73
+ thor (0.19.1)
74
+ thread_safe (0.3.3)
75
+ tilt (1.4.1)
76
+ treetop (1.4.15)
77
+ polyglot
78
+ polyglot (>= 0.3.1)
79
+ tzinfo (0.3.39)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ rails-defaults!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Adam Luzsi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ rails-defaults
2
+ ==============
3
+
4
+ Ruby modul for Rails to Patch default used server / port , etc
5
+
6
+ ### Examples for use
7
+
8
+
9
+ ```ruby
10
+
11
+ require 'rails-defaults'
12
+
13
+ RailsDefaults.port 3003
14
+ RailsDefaults.server :puma
15
+ RailsDefaults.environment :development
16
+
17
+ ```
18
+
19
+ or you can use the hash input way with the options/opts call
20
+
21
+ ```ruby
22
+
23
+ require 'rails-defaults'
24
+
25
+ RailsDefaults.opts port: 3210,
26
+ server: :puma,
27
+ env: :development
28
+
29
+ ```
30
+
31
+ now you can use simple rails start up like 'rails s' || 'rails server'
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require File.join "bundler","gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/files.rb ADDED
@@ -0,0 +1,23 @@
1
+ ### Get Files from dir
2
+ begin
3
+
4
+ module RailsDefaults
5
+ SpecFiles= Array.new
6
+ end
7
+
8
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
9
+ one_file_name = File.expand_path one_file_name
10
+ file_name = one_file_name[(File.expand_path(File.dirname(__FILE__)).to_s.length+1)..(one_file_name.length-1)]
11
+
12
+ if !one_file_name.include?("pkg")
13
+ if !File.directory? file_name
14
+
15
+ RailsDefaults::SpecFiles.push file_name
16
+ STDOUT.puts file_name if $DEBUG
17
+
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,133 @@
1
+ module RailsDefaults
2
+
3
+ module Helpers
4
+ class << self
5
+
6
+ def must_be_instance_of obj, *classes
7
+
8
+ var= classes.map { |class_name|
9
+
10
+ if obj.class <= class_name
11
+ true
12
+ else
13
+ nil
14
+ end
15
+
16
+ }.compact
17
+
18
+ if var.empty?
19
+ raise ArgumentError,"invalid input object, must be instance from one of these or they subclasses class: #{classes.join(', ')}"
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ module OPTS
28
+
29
+ def port obj= nil
30
+ unless obj.nil?
31
+ Helpers.must_be_instance_of obj, Numeric, Symbol, String
32
+ @port= obj.to_i
33
+ end
34
+ return @port || 3000
35
+ end
36
+
37
+ def debugger obj= nil
38
+ unless obj.nil?
39
+ Helpers.must_be_instance_of obj, TrueClass,FalseClass
40
+ @debugger= obj
41
+ end
42
+ return @debugger || false
43
+ end
44
+
45
+ def daemonize obj= nil?
46
+ unless obj.nil?
47
+ Helpers.must_be_instance_of obj, TrueClass,FalseClass
48
+ @daemonize= obj
49
+ end
50
+ return @daemonize || false
51
+ end
52
+
53
+ def server server_name= nil
54
+
55
+ unless server_name.nil?
56
+ Helpers.must_be_instance_of server_name, String, Symbol
57
+ @server= server_name
58
+ end
59
+
60
+ ###OLD WORKAROUND
61
+ #require 'rack/handler'
62
+ #begin
63
+ # eval " ::Rack::Handler::WEBrick = Rack::Handler.get(server_name)"
64
+ #rescue LoadError
65
+ # STDERR.puts("#{server_name} gem is not installed, using WEBrick as default")
66
+ #end
67
+
68
+ return @server || :webrick
69
+ end
70
+
71
+
72
+ def environment obj= nil
73
+ unless obj.nil?
74
+ Helpers.must_be_instance_of obj, String,Symbol
75
+ @environment= obj.to_s
76
+ end
77
+ return @environment || "development"
78
+ end
79
+
80
+ alias :env :environment
81
+
82
+ def options opts= {}
83
+ opts.each do |method_name, value|
84
+ begin
85
+ self.__send__ method_name.to_s.downcase, value
86
+ rescue NoMethodError
87
+
88
+ raise ArgumentError,
89
+ "invalid key #{method_name}, try use one from the followings: #{self.singleton_methods-[:opts,:options]}"
90
+
91
+ end
92
+ end
93
+ end
94
+
95
+ alias :opts :options
96
+
97
+ end
98
+
99
+ extend OPTS
100
+
101
+ module DefaultOptions
102
+
103
+ def default_options
104
+
105
+ options_hash= {}
106
+ {
107
+ Port: :port,
108
+ environment: :environment,
109
+ daemonize: :daemonize,
110
+ debugger: :debugger,
111
+ server: :server
112
+ }.each do |default_key,method_name|
113
+
114
+ #puts "#{default_key}: #{::RailsDefaults.__send__(method_name)}"
115
+ options_hash[default_key]= ::RailsDefaults.__send__ method_name
116
+
117
+ end
118
+
119
+ super.merge!( options_hash )
120
+
121
+ end
122
+
123
+ def server
124
+ options[:server] ||= default_options[:server]
125
+ super
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+
132
+ require 'rails/commands/server'
133
+ Rails::Server.__send__( :prepend, RailsDefaults::DefaultOptions )
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__),"files.rb"))
4
+
5
+ ### Specification for the new Gem
6
+ Gem::Specification.new do |spec|
7
+
8
+ spec.name = "rails-defaults"
9
+ spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
10
+ spec.authors = ["Adam Luzsi"]
11
+ spec.email = ["adamluzsi@gmail.com"]
12
+
13
+ spec.description = %q{ this module let you have super easy to configurate way for rails defaults. if you set anything with this, than starting rails with 'rails s'/'rails server' will use your preset behaviors }
14
+ spec.summary = %q{ Set up Rails default behaviors with this simple DSL }
15
+
16
+ spec.homepage = "https://github.com/adamluzsi/rails-defaults"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = RailsDefaults::SpecFiles
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "rails"
25
+ spec.add_dependency "rack"
26
+ spec.required_ruby_version = '>= 2.0.0'
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-defaults
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Luzsi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: " this module let you have super easy to configurate way for rails defaults.
42
+ if you set anything with this, than starting rails with 'rails s'/'rails server'
43
+ will use your preset behaviors "
44
+ email:
45
+ - adamluzsi@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - VERSION
56
+ - files.rb
57
+ - lib/rails-defaults.rb
58
+ - rails-defaults.gemspec
59
+ homepage: https://github.com/adamluzsi/rails-defaults
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.0.0
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Set up Rails default behaviors with this simple DSL
83
+ test_files: []