run_shell 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbb258e2883b4f5777190b86e76a47b65f56bb98
4
+ data.tar.gz: 023e430c975551600c6ae18db532e2b02b11b8dc
5
+ SHA512:
6
+ metadata.gz: c992a2bf02e6349f800d6705b049ec097060701b3f3d8e25721a18b6937ccb3c84ba3b9029a1066a724d37ea22b2f851e64a83f9ce5ab7ee973d60ac0df2345e
7
+ data.tar.gz: 96c0fef30d68aad0cfc546826a9bf2ff99beef866f25c7da87dd766168d369a5b0710ceba14b02138f2b93ca18254b7abe03c040a1c0cab7f30a6f6bf63a4263
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in run_shell.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 bruce
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RunShell
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'run_shell'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install run_shell
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/run_shell/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/active_record'
4
+
5
+ module RunShell
6
+ class InstallGenerator < ::Rails::Generators::Base
7
+ include ::Rails::Generators::Migration
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+
11
+ desc 'Generates (but does not run) a migration to add a shells table.'
12
+
13
+ def create_migration_file
14
+ migration_template 'create_shells.rb', 'db/migrate/create_shells.rb'
15
+ end
16
+
17
+ def copy_initializer
18
+ template "run_shell.rb", "config/initializers/run_shell.rb"
19
+ end
20
+
21
+ def self.next_migration_number(dirname)
22
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ class CreateShells < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shells do |t|
4
+ t.string :file_path
5
+ t.string :content
6
+ t.string :whodunnit
7
+ t.boolean :result
8
+ t.datetime :created_at
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :shells
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ RunShell.setup do |config|
2
+ config.shell_path = ''
3
+ config.shell_command = 'echo hello'
4
+ end
data/lib/run_shell.rb ADDED
@@ -0,0 +1,36 @@
1
+ require "run_shell/version"
2
+ require "run_shell/configuration"
3
+ require "run_shell/shell"
4
+
5
+ Dir[File.join(File.dirname(__FILE__), 'run_shell', 'frameworks', '*.rb')].each { |file| require file }
6
+
7
+ module RunShell
8
+ # Your code goes here...
9
+ class << self
10
+ def setup
11
+ yield config
12
+ end
13
+
14
+ def config
15
+ @config ||= Configuration.new
16
+ end
17
+ end
18
+
19
+ def self.whodunnit
20
+ run_shell_store[:whodunnit]
21
+ end
22
+
23
+ def self.whodunnit=(value)
24
+ run_shell_store[:whodunnit] = value
25
+ end
26
+
27
+ def self.run_shell_store
28
+ Thread.current[:run_shell] ||= { }
29
+ end
30
+ end
31
+
32
+ if defined?(ActionController)
33
+ ActiveSupport.on_load(:action_controller) do
34
+ include RunShell::Rails::Controller
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ module RunShell
2
+ class Configuration
3
+ def shell_path
4
+ @shell_path ||= ""
5
+ end
6
+
7
+ def shell_path=(value)
8
+ @shell_path = value
9
+ end
10
+
11
+ def shell_command
12
+ @shell_command ||= ""
13
+ end
14
+
15
+ def shell_command=(value)
16
+ @shell_command = value
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module RunShell
2
+ module Rails
3
+ module Controller
4
+
5
+ def self.included(base)
6
+ if defined?(ActionController) && base == ActionController::Base
7
+ base.before_filter :set_run_shell_whodunnit
8
+ end
9
+ end
10
+
11
+ protected
12
+ def user_for_run_shell
13
+ current_user if defined?(current_user)
14
+ end
15
+
16
+ def set_run_shell_whodunnit
17
+ ::RunShell.whodunnit = user_for_run_shell
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module RunShell
2
+ class Shell < ActiveRecord::Base
3
+ #attr_accessible :whodunnit, :file_path, :content, :result
4
+
5
+ def self.run
6
+ if File.exists?(RunShell.config.shell_path)
7
+ content = File.read(RunShell.config.shell_path)
8
+ result = system content
9
+ shell = Shell.new(file_path:RunShell.config.shell_path, content:content, result:result, whodunnit:RunShell.whodunnit)
10
+ shell.save
11
+ end
12
+
13
+ if !RunShell.config.shell_command.blank?
14
+ content = RunShell.config.shell_command
15
+ result = system content
16
+ shell = Shell.new(content:content, result:result, whodunnit:RunShell.whodunnit)
17
+ shell.save
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module RunShell
2
+ VERSION = "0.0.1"
3
+ end
data/run_shell.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'run_shell/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "run_shell"
8
+ spec.version = RunShell::VERSION
9
+ spec.authors = ["bruce"]
10
+ spec.email = ["zth5906@gmail.com"]
11
+ spec.summary = %q{run shell}
12
+ spec.description = %q{run shell }
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'activerecord', ['>= 3.0', '< 5.0']
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'railties', ['>= 3.0', '< 5.0']
26
+ spec.add_development_dependency "rspec-rails", "~> 2.14"
27
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: run_shell
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - bruce
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: railties
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '5.0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '5.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec-rails
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.14'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '2.14'
95
+ description: 'run shell '
96
+ email:
97
+ - zth5906@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - ".gitignore"
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/generators/run_shell/install_generator.rb
108
+ - lib/generators/run_shell/templates/create_shells.rb
109
+ - lib/generators/run_shell/templates/run_shell.rb
110
+ - lib/run_shell.rb
111
+ - lib/run_shell/configuration.rb
112
+ - lib/run_shell/frameworks/rails.rb
113
+ - lib/run_shell/shell.rb
114
+ - lib/run_shell/version.rb
115
+ - run_shell.gemspec
116
+ - spec/spec_helper.rb
117
+ homepage: ''
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.5
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: run shell
141
+ test_files:
142
+ - spec/spec_helper.rb