webshellruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ ## Mac OS X
2
+ .DS_Store
3
+ ._*
4
+ *.gem
5
+ *.rbc
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webshellruby.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 TODO: Write your name
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,49 @@
1
+ # Webshellruby
2
+
3
+ Webshell is a scripting language designed for fast API consumption and implementation.
4
+
5
+ Consume, Write and Share your favorites APIs in minutes !
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'webshellruby'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install webshellruby
20
+
21
+ ## Usage
22
+
23
+ ### Install in a Rails app
24
+
25
+ rails g webshellruby:install
26
+
27
+ ### Then you can use this method in view
28
+
29
+ ````ruby
30
+ your_query = 'google test'
31
+ # you can do this
32
+ webshell_html your_query
33
+ #=> render html
34
+ # or you can do this
35
+ webshell_exec
36
+ #=> big array with all what you want
37
+ ````
38
+
39
+ ## Documentation
40
+
41
+ * [Webshell documentation](http://webshell.io/support/docs)
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,13 @@
1
+ module Webshellruby
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates a Webshell initializer"
7
+
8
+ def copy_initializer
9
+ template "webshellruby.rb", "config/initializers/webshellruby.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ Webshellruby.setup do |config|
2
+ # API Key
3
+ config.api_key = "please-feed-me-with-a-valid-api-key"
4
+ # Secret Key
5
+ config.secret_key = "please-give-me-the-magic-secret-key"
6
+ end
@@ -0,0 +1,23 @@
1
+ require 'nokogiri'
2
+ require 'uuid'
3
+ require 'open-uri'
4
+ require 'digest/sha1'
5
+ require 'oj'
6
+ require 'webshellruby/version'
7
+ require 'webshellruby/webshell'
8
+
9
+ module Webshellruby
10
+
11
+ # Api key for webshell.
12
+ mattr_accessor :api_key
13
+ @@api_key = nil
14
+
15
+ # Secret key for your app.
16
+ mattr_accessor :secret_key
17
+ @@secret_key = nil
18
+
19
+ def self.setup
20
+ yield self
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ module Webshellruby
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ module Webshellruby
2
+ module Webshell
3
+ @@base_url = 'http://webshell.io/api'
4
+
5
+ def webshell_exec cmd
6
+ encode_cmd = URI::encode cmd
7
+ uniq_id = Digest::SHA1.hexdigest UUID.new.generate
8
+ request_url = @@base_url + '?response=json&request=' + encode_cmd + '&key=' + Webshellruby.api_key+ '&secret=' + Webshellruby.secret_key + '&cip=' + uniq_id
9
+ result = open(request_url) {|io| io.read}
10
+ result_arr = Oj.load(result)
11
+ if result_arr.last['error']
12
+ return false
13
+ else
14
+ return result_arr
15
+ end
16
+ end
17
+
18
+ def webshell_html cmd
19
+ result = webshell_exec cmd
20
+ return result[1]['view'].html_safe
21
+ end
22
+ end
23
+ end
24
+
25
+ ActionView::Base.send :include, Webshellruby::Webshell
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/webshellruby/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Authier David"]
6
+ gem.email = ["david@awea.fr"]
7
+ gem.description = %q{Webshell API of APIs}
8
+ gem.summary = %q{Webshell API of APIs}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "webshellruby"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Webshellruby::VERSION
17
+
18
+ gem.add_runtime_dependency 'nokogiri'
19
+ gem.add_runtime_dependency 'uuid'
20
+ gem.add_runtime_dependency 'oj'
21
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webshellruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Authier David
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: uuid
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: oj
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Webshell API of APIs
63
+ email:
64
+ - david@awea.fr
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - lib/generators/webshellruby/install/install_generator.rb
75
+ - lib/generators/webshellruby/templates/webshellruby.rb
76
+ - lib/webshellruby.rb
77
+ - lib/webshellruby/version.rb
78
+ - lib/webshellruby/webshell.rb
79
+ - webshellruby.gemspec
80
+ homepage: ''
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.24
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Webshell API of APIs
104
+ test_files: []