mini-clean-kit 0.0.1

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/mini-clean-kit.gemspec +12 -0
  3. data/spring-4.7.0/LICENSE.txt +23 -0
  4. data/spring-4.7.0/README.md +467 -0
  5. data/spring-4.7.0/bin/spring +49 -0
  6. data/spring-4.7.0/lib/spring/application/boot.rb +25 -0
  7. data/spring-4.7.0/lib/spring/application.rb +449 -0
  8. data/spring-4.7.0/lib/spring/application_manager.rb +145 -0
  9. data/spring-4.7.0/lib/spring/binstub.rb +13 -0
  10. data/spring-4.7.0/lib/spring/boot.rb +10 -0
  11. data/spring-4.7.0/lib/spring/client/binstub.rb +190 -0
  12. data/spring-4.7.0/lib/spring/client/command.rb +18 -0
  13. data/spring-4.7.0/lib/spring/client/help.rb +62 -0
  14. data/spring-4.7.0/lib/spring/client/rails.rb +34 -0
  15. data/spring-4.7.0/lib/spring/client/run.rb +297 -0
  16. data/spring-4.7.0/lib/spring/client/server.rb +18 -0
  17. data/spring-4.7.0/lib/spring/client/status.rb +30 -0
  18. data/spring-4.7.0/lib/spring/client/stop.rb +22 -0
  19. data/spring-4.7.0/lib/spring/client/version.rb +11 -0
  20. data/spring-4.7.0/lib/spring/client.rb +48 -0
  21. data/spring-4.7.0/lib/spring/command_wrapper.rb +82 -0
  22. data/spring-4.7.0/lib/spring/commands/rails.rb +112 -0
  23. data/spring-4.7.0/lib/spring/commands/rake.rb +30 -0
  24. data/spring-4.7.0/lib/spring/commands.rb +57 -0
  25. data/spring-4.7.0/lib/spring/configuration.rb +99 -0
  26. data/spring-4.7.0/lib/spring/env.rb +115 -0
  27. data/spring-4.7.0/lib/spring/errors.rb +36 -0
  28. data/spring-4.7.0/lib/spring/failsafe_thread.rb +14 -0
  29. data/spring-4.7.0/lib/spring/json.rb +623 -0
  30. data/spring-4.7.0/lib/spring/process_title_updater.rb +65 -0
  31. data/spring-4.7.0/lib/spring/server.rb +162 -0
  32. data/spring-4.7.0/lib/spring/version.rb +3 -0
  33. data/spring-4.7.0/lib/spring/watcher/abstract.rb +117 -0
  34. data/spring-4.7.0/lib/spring/watcher/polling.rb +98 -0
  35. data/spring-4.7.0/lib/spring/watcher.rb +30 -0
  36. metadata +75 -0
@@ -0,0 +1,48 @@
1
+ require "spring/errors"
2
+ require "spring/json"
3
+
4
+ require "spring/client/command"
5
+ require "spring/client/run"
6
+ require "spring/client/help"
7
+ require "spring/client/binstub"
8
+ require "spring/client/stop"
9
+ require "spring/client/status"
10
+ require "spring/client/rails"
11
+ require "spring/client/version"
12
+ require "spring/client/server"
13
+
14
+ module Spring
15
+ module Client
16
+ COMMANDS = {
17
+ "help" => Client::Help,
18
+ "-h" => Client::Help,
19
+ "--help" => Client::Help,
20
+ "binstub" => Client::Binstub,
21
+ "stop" => Client::Stop,
22
+ "status" => Client::Status,
23
+ "rails" => Client::Rails,
24
+ "-v" => Client::Version,
25
+ "--version" => Client::Version,
26
+ "server" => Client::Server,
27
+ }
28
+
29
+ def self.run(args)
30
+ command_for(args.first).call(args)
31
+ rescue CommandNotFound
32
+ Client::Help.call(args)
33
+ rescue ClientError => e
34
+ $stderr.puts e.message
35
+ exit 1
36
+ end
37
+
38
+ def self.command_for(name)
39
+ COMMANDS[name] || Client::Run
40
+ end
41
+ end
42
+ end
43
+
44
+ # allow users to add hooks that do not run in the server
45
+ # or modify start/stop
46
+ if File.exist?("config/spring_client.rb")
47
+ require "./config/spring_client.rb"
48
+ end
@@ -0,0 +1,82 @@
1
+ require "spring/configuration"
2
+
3
+ module Spring
4
+ class CommandWrapper
5
+ attr_reader :name, :command
6
+
7
+ def initialize(name, command = nil)
8
+ @name = name
9
+ @command = command
10
+ @setup = false
11
+ end
12
+
13
+ def description
14
+ if command.respond_to?(:description)
15
+ command.description
16
+ else
17
+ "Runs the #{name} command"
18
+ end
19
+ end
20
+
21
+ def setup?
22
+ @setup
23
+ end
24
+
25
+ def setup
26
+ if !setup? && command.respond_to?(:setup)
27
+ command.setup
28
+ @setup = true
29
+ return true
30
+ else
31
+ @setup = true
32
+ return false
33
+ end
34
+ end
35
+
36
+ def call
37
+ if command.respond_to?(:call)
38
+ command.call
39
+ else
40
+ load exec
41
+ end
42
+ end
43
+
44
+ def gem_name
45
+ if command.respond_to?(:gem_name)
46
+ command.gem_name
47
+ else
48
+ exec_name
49
+ end
50
+ end
51
+
52
+ def exec_name
53
+ if command.respond_to?(:exec_name)
54
+ command.exec_name
55
+ else
56
+ name
57
+ end
58
+ end
59
+
60
+ def binstub
61
+ Spring.application_root_path.join(binstub_name)
62
+ end
63
+
64
+ def binstub_name
65
+ "bin/#{name}"
66
+ end
67
+
68
+ def exec
69
+ if binstub.exist?
70
+ binstub.to_s
71
+ else
72
+ Gem.bin_path(gem_name, exec_name)
73
+ end
74
+ end
75
+
76
+ def env(args)
77
+ if command.respond_to?(:env)
78
+ command.env(args)
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,112 @@
1
+ module Spring
2
+ module Commands
3
+ class Rails
4
+ def call
5
+ ARGV.unshift command_name
6
+ load Dir.glob(::Rails.root.join("{bin,script}/rails")).first
7
+ end
8
+
9
+ def description
10
+ nil
11
+ end
12
+ end
13
+
14
+ class RailsConsole < Rails
15
+ def env(args)
16
+ return args.first if args.first && !args.first.index("-")
17
+
18
+ environment = nil
19
+
20
+ args.each.with_index do |arg, i|
21
+ if arg =~ /--environment=(\w+)/
22
+ environment = $1
23
+ elsif i > 0 && args[i - 1] == "-e"
24
+ environment = arg
25
+ end
26
+ end
27
+
28
+ environment
29
+ end
30
+
31
+ def command_name
32
+ "console"
33
+ end
34
+ end
35
+
36
+ class RailsGenerate < Rails
37
+ def command_name
38
+ "generate"
39
+ end
40
+ end
41
+
42
+ class RailsDestroy < Rails
43
+ def command_name
44
+ "destroy"
45
+ end
46
+ end
47
+
48
+ class RailsRunner < Rails
49
+ def call
50
+ ARGV.replace extract_environment(ARGV).first
51
+ super
52
+ end
53
+
54
+ def env(args)
55
+ extract_environment(args).last
56
+ end
57
+
58
+ def command_name
59
+ "runner"
60
+ end
61
+
62
+ def extract_environment(args)
63
+ environment = nil
64
+
65
+ args = args.select.with_index { |arg, i|
66
+ case arg
67
+ when "-e"
68
+ false
69
+ when /--environment=(\w+)/
70
+ environment = $1
71
+ false
72
+ else
73
+ if i > 0 && args[i - 1] == "-e"
74
+ environment = arg
75
+ false
76
+ else
77
+ true
78
+ end
79
+ end
80
+ }
81
+
82
+ [args, environment]
83
+ end
84
+ end
85
+
86
+ class RailsTest < Rails
87
+ def env(args)
88
+ environment = "test"
89
+
90
+ args.each.with_index do |arg, i|
91
+ if arg =~ /--environment=(\w+)/
92
+ environment = $1
93
+ elsif i > 0 && args[i - 1] == "-e"
94
+ environment = arg
95
+ end
96
+ end
97
+
98
+ environment
99
+ end
100
+
101
+ def command_name
102
+ "test"
103
+ end
104
+ end
105
+
106
+ Spring.register_command "rails_console", RailsConsole.new
107
+ Spring.register_command "rails_generate", RailsGenerate.new
108
+ Spring.register_command "rails_destroy", RailsDestroy.new
109
+ Spring.register_command "rails_runner", RailsRunner.new
110
+ Spring.register_command "rails_test", RailsTest.new
111
+ end
112
+ end
@@ -0,0 +1,30 @@
1
+ module Spring
2
+ module Commands
3
+ class Rake
4
+ class << self
5
+ attr_accessor :environment_matchers
6
+ end
7
+
8
+ self.environment_matchers = {
9
+ :default => "test",
10
+ /^test($|:)/ => "test"
11
+ }
12
+
13
+ def env(args)
14
+ # This is an adaption of the matching that Rake itself does.
15
+ # See: https://github.com/jimweirich/rake/blob/3754a7639b3f42c2347857a0878beb3523542aee/lib/rake/application.rb#L691-L692
16
+ if env = args.grep(/^(RAILS|RACK)_ENV=(.*)$/m).last
17
+ return env.split("=").last
18
+ end
19
+
20
+ self.class.environment_matchers.each do |matcher, environment|
21
+ return environment if matcher === (args.first || :default)
22
+ end
23
+
24
+ nil
25
+ end
26
+ end
27
+
28
+ Spring.register_command "rake", Rake.new
29
+ end
30
+ end
@@ -0,0 +1,57 @@
1
+ require "spring/watcher"
2
+ require "spring/command_wrapper"
3
+
4
+ module Spring
5
+ @commands = {}
6
+
7
+ class << self
8
+ attr_reader :commands
9
+ end
10
+
11
+ def self.register_command(name, command = nil)
12
+ commands[name] = CommandWrapper.new(name, command)
13
+ end
14
+
15
+ def self.command?(name)
16
+ commands.include? name
17
+ end
18
+
19
+ def self.command(name)
20
+ commands.fetch name
21
+ end
22
+
23
+ require "spring/commands/rails"
24
+ require "spring/commands/rake"
25
+
26
+ # Load custom commands, if any.
27
+ # needs to be at the end to allow modification of existing commands.
28
+ config = File.expand_path("~/.spring.rb")
29
+ require config if File.exist?(config)
30
+
31
+ # We force the TTY so bundler doesn't show a backtrace in case gems are missing.
32
+ old_env = ENV["BUNDLER_FORCE_TTY"]
33
+ ENV["BUNDLER_FORCE_TTY"] = "true"
34
+ begin
35
+ # If the config/spring.rb contains requires for commands from other gems,
36
+ # then we need to be under bundler.
37
+ require "bundler/setup"
38
+ ensure
39
+ ENV["BUNDLER_FORCE_TTY"] = old_env
40
+ end
41
+
42
+ # Auto-require any Spring extensions which are in the Gemfile
43
+ Gem::Specification.map(&:name).grep(/^spring-/).each do |command|
44
+ begin
45
+ require command
46
+ rescue LoadError => error
47
+ if error.message.include?(command)
48
+ require command.gsub("-", "/")
49
+ else
50
+ raise
51
+ end
52
+ end
53
+ end
54
+
55
+ config = File.expand_path("./config/spring.rb")
56
+ require config if File.exist?(config)
57
+ end
@@ -0,0 +1,99 @@
1
+ require "spring/errors"
2
+
3
+ module Spring
4
+ @connect_timeout = 5
5
+ @boot_timeout = 20
6
+ @dangerously_allow_disabling_reloading = false
7
+
8
+ class << self
9
+ attr_accessor :application_root, :connect_timeout, :boot_timeout
10
+ attr_writer :quiet
11
+
12
+ # Opt-in: skip the `:ensure_reloading_is_enabled` initializer so Spring
13
+ # boots with `config.enable_reloading = false`. Default `false`. See
14
+ # README "Running Spring with reloading disabled" for what this gives up.
15
+ attr_accessor :dangerously_allow_disabling_reloading
16
+
17
+ def gemfile
18
+ require "bundler"
19
+
20
+ if /\s1.9.[0-9]/ === Bundler.ruby_scope.gsub(/[\/\s]+/,'')
21
+ Pathname.new(ENV["BUNDLE_GEMFILE"] || "Gemfile").expand_path
22
+ else
23
+ Bundler.default_gemfile
24
+ end
25
+ end
26
+
27
+ def gemfile_lock
28
+ case gemfile.to_s
29
+ when /\bgems\.rb\z/
30
+ gemfile.sub_ext('.locked')
31
+ else
32
+ gemfile.sub_ext('.lock')
33
+ end
34
+ end
35
+
36
+ def after_fork_callbacks
37
+ @after_fork_callbacks ||= []
38
+ end
39
+
40
+ def after_fork(&block)
41
+ after_fork_callbacks << block
42
+ end
43
+
44
+ def after_environment_load_callbacks
45
+ @after_environment_load_callbacks ||= []
46
+ end
47
+
48
+ def after_environment_load(&block)
49
+ after_environment_load_callbacks << block
50
+ end
51
+
52
+ def spawn_on_env
53
+ @spawn_on_env ||= []
54
+ end
55
+
56
+ def reset_on_env
57
+ @reset_on_env ||= []
58
+ end
59
+
60
+ def verify_environment
61
+ application_root_path
62
+ end
63
+
64
+ def application_root_path
65
+ @application_root_path ||= begin
66
+ if application_root
67
+ path = Pathname.new(File.expand_path(application_root))
68
+ else
69
+ path = project_root_path
70
+ end
71
+
72
+ raise MissingApplication.new(path) unless path.join("config/application.rb").exist?
73
+ path
74
+ end
75
+ end
76
+
77
+ def project_root_path
78
+ @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
79
+ end
80
+
81
+ def quiet
82
+ @quiet || ENV.key?('SPRING_QUIET')
83
+ end
84
+
85
+ private
86
+
87
+ def find_project_root(current_dir)
88
+ if current_dir.join(gemfile).exist?
89
+ current_dir
90
+ elsif current_dir.root?
91
+ raise UnknownProject.new(Dir.pwd)
92
+ else
93
+ find_project_root(current_dir.parent)
94
+ end
95
+ end
96
+ end
97
+
98
+ self.quiet = false
99
+ end
@@ -0,0 +1,115 @@
1
+ require "pathname"
2
+
3
+ require "spring/version"
4
+ require "spring/configuration"
5
+
6
+ module Spring
7
+ IGNORE_SIGNALS = %w(INT QUIT)
8
+ STOP_TIMEOUT = 2 # seconds
9
+
10
+ class Env
11
+ attr_reader :log_file
12
+
13
+ def initialize(options = {})
14
+ @root = options[:root]
15
+ @project_root = options[:root]
16
+ @log_file = options[:log_file] || File.open(ENV["SPRING_LOG"] || File::NULL, "a")
17
+ end
18
+
19
+ def root
20
+ @root ||= Spring.application_root_path
21
+ end
22
+
23
+ def project_root
24
+ @project_root ||= Spring.project_root_path
25
+ end
26
+
27
+ def version
28
+ Spring::VERSION
29
+ end
30
+
31
+ def tmp_path
32
+ require "tmpdir"
33
+ path = Pathname.new(
34
+ ENV["SPRING_TMP_PATH"] ||
35
+ File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}")
36
+ )
37
+ require "fileutils"
38
+ FileUtils.mkdir_p(path) unless path.exist?
39
+ path
40
+ end
41
+
42
+ def application_id
43
+ require "digest/md5"
44
+ ENV["SPRING_APPLICATION_ID"] || Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s)
45
+ end
46
+
47
+ def socket_path
48
+ Pathname.new(ENV["SPRING_SOCKET"] || tmp_path.join(application_id))
49
+ end
50
+
51
+ def socket_name
52
+ socket_path.to_s
53
+ end
54
+
55
+ def pidfile_path
56
+ Pathname.new(ENV["SPRING_PIDFILE"] || socket_path.dirname.join("#{socket_path.basename(".*")}.pid"))
57
+ end
58
+
59
+ def pid
60
+ pidfile_path.exist? ? pidfile_path.read.to_i : nil
61
+ rescue Errno::ENOENT
62
+ # This can happen if the pidfile is removed after we check it
63
+ # exists
64
+ end
65
+
66
+ def app_name
67
+ root.basename
68
+ end
69
+
70
+ def server_running?
71
+ pidfile = pidfile_path.open('r+')
72
+ !pidfile.flock(File::LOCK_EX | File::LOCK_NB)
73
+ rescue Errno::ENOENT
74
+ false
75
+ ensure
76
+ if pidfile
77
+ pidfile.flock(File::LOCK_UN)
78
+ pidfile.close
79
+ end
80
+ end
81
+
82
+ def log(message)
83
+ log_file.puts "[#{Time.now}] [#{Process.pid}] #{message}"
84
+ log_file.flush
85
+ end
86
+
87
+ def stop
88
+ if server_running?
89
+ timeout = Time.now + STOP_TIMEOUT
90
+ kill 'TERM'
91
+ sleep 0.1 until !server_running? || Time.now >= timeout
92
+
93
+ if server_running?
94
+ kill 'KILL'
95
+ :killed
96
+ else
97
+ :stopped
98
+ end
99
+ else
100
+ :not_running
101
+ end
102
+ end
103
+
104
+ def kill(sig)
105
+ pid = self.pid
106
+ Process.kill(sig, pid) if pid
107
+ rescue Errno::ESRCH
108
+ # already dead
109
+ end
110
+
111
+ def server_command
112
+ ENV["SPRING_SERVER_COMMAND"] || "#{File.expand_path("../../../bin/spring", __FILE__)} server --background"
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,36 @@
1
+ module Spring
2
+ class ClientError < StandardError; end
3
+
4
+ class UnknownProject < StandardError
5
+ attr_reader :current_dir
6
+
7
+ def initialize(current_dir)
8
+ @current_dir = current_dir
9
+ end
10
+
11
+ def message
12
+ "Spring was unable to locate the root of your project. There was no Gemfile " \
13
+ "present in the current directory (#{current_dir}) or any of the parent " \
14
+ "directories."
15
+ end
16
+ end
17
+
18
+ class MissingApplication < ClientError
19
+ attr_reader :project_root
20
+
21
+ def initialize(project_root)
22
+ @project_root = project_root
23
+ end
24
+
25
+ def message
26
+ "Spring was unable to find your config/application.rb file. " \
27
+ "Your project root was detected at #{project_root}, so Spring " \
28
+ "looked for #{project_root}/config/application.rb but it doesn't exist. You can " \
29
+ "configure the root of your application by setting Spring.application_root in " \
30
+ "config/spring.rb."
31
+ end
32
+ end
33
+
34
+ class CommandNotFound < ClientError
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ require 'thread'
2
+
3
+ module Spring
4
+ class << self
5
+ def failsafe_thread
6
+ Thread.new {
7
+ begin
8
+ yield
9
+ rescue
10
+ end
11
+ }
12
+ end
13
+ end
14
+ end