poke-stick 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80ddd2a76761bd1f4b3cfedd158f974bca782a90
4
+ data.tar.gz: 101c1c3ba0d249ae242ed1dea129d3be3c95361a
5
+ SHA512:
6
+ metadata.gz: 3030fc980a35a2cc2d3c3b3c26d8fd62a3720025a94a94a7af1767ea1fddc3e7217c30b93cf3369f8af21ae513b56b88cbb4dbdcee472b75f53f849a38512109
7
+ data.tar.gz: f08b7dd36dcbf715241cdfeaeb0ef5053793b99bc700b55415a0d11053a0f8877d40868a84c957138020a5b60503f69604e4bdfc96413bcc4479cced326c9e9f
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
5
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in poke-stick.gemspec
4
+ gemspec
@@ -0,0 +1,8 @@
1
+ Name: poke-stick
2
+ Copyright (c) 2015 Joel Helbling
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Poke::Stick
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'poke-stick'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install poke-stick
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/poke-stick/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,23 @@
1
+ = poke-stick - DESCRIBE YOUR GEM
2
+
3
+ Author:: YOUR NAME (YOUR EMAIL)
4
+ Copyright:: Copyright (c) 2015 YOUR NAME
5
+
6
+
7
+ License:: mit, see LICENSE.txt
8
+
9
+
10
+
11
+ DESCRIBE YOUR GEM HERE
12
+
13
+ == Links
14
+
15
+ * {Source on Github}[LINK TO GITHUB]
16
+ * RDoc[LINK TO RDOC.INFO]
17
+
18
+ == Install
19
+
20
+ == Examples
21
+
22
+ == Contributing
23
+
@@ -0,0 +1,66 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ if File.exists?(File.join(path,"rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exists?(File.join(path,"rspec","core"))
8
+ puts "Found core"
9
+ if File.exists?(File.join(path,"rspec","core","rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ end
20
+ if found.nil?
21
+ puts "Didn't find rspec/core/rake_task anywhere"
22
+ else
23
+ puts "Found in #{path}"
24
+ end
25
+ end
26
+ require 'bundler'
27
+ require 'rake/clean'
28
+
29
+ begin
30
+ require 'rspec/core/rake_task'
31
+ rescue LoadError
32
+ dump_load_path
33
+ raise
34
+ end
35
+
36
+ require 'cucumber'
37
+ require 'cucumber/rake/task'
38
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
39
+ require 'rdoc/task'
40
+
41
+ include Rake::DSL
42
+
43
+ Bundler::GemHelper.install_tasks
44
+
45
+
46
+ RSpec::Core::RakeTask.new do |t|
47
+ # Put spec opts in a file named .rspec in root
48
+ end
49
+
50
+
51
+ CUKE_RESULTS = 'results.html'
52
+ CLEAN << CUKE_RESULTS
53
+ Cucumber::Rake::Task.new(:features) do |t|
54
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
55
+ t.fork = false
56
+ end
57
+
58
+ Rake::RDocTask.new do |rd|
59
+
60
+ rd.main = "README.rdoc"
61
+
62
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
63
+ end
64
+
65
+ task :default => [:spec,:features]
66
+
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'poke/stick.rb'
6
+ require 'uri'
7
+ require 'rack'
8
+
9
+ class App
10
+ include Methadone::Main
11
+ include Methadone::CLILogging
12
+
13
+ main do |target, filename|
14
+ uri = URI normalize(target)
15
+ if filename
16
+ unless options[:mimetype]
17
+ options[:mimetype] =
18
+ Rack::Mime.mime_type(options[:extension] || File.extname(filename))
19
+ end
20
+ # POST
21
+ File.open(filename) do |fh|
22
+ Poke::Stick.post uri, fh, options
23
+ end
24
+ else
25
+ Poke::Stick.get uri, options
26
+ end
27
+ end
28
+
29
+ # supplemental methods here
30
+
31
+ def self.normalize target
32
+ unless target.match(/^https?:\/\//)
33
+ target = "http://#{target}"
34
+ end
35
+ target
36
+ end
37
+
38
+ # Declare command-line interface here
39
+
40
+ # description "one line description of your app"
41
+ description <<-DESC
42
+ A command-line client for the Poke message transport server. Performs a
43
+ GET request using the target URI, unless a --file is supplied, in which
44
+ case a POST request is made using the contents of the supplied file.
45
+ The mimetype is determined from the file's extension, but this can be
46
+ overridden (see options below).
47
+ DESC
48
+
49
+ on '-m', '--mimetype MIMETYPE', 'Use MIMETYPE (POST only)'
50
+ on '-x', '--extension EXT', 'Use EXT to set mimetype (POST only)'
51
+ on '-v', '--verbose', 'Moar output (status, content-type)'
52
+
53
+ arg :target, 'A URI for the Poke request'
54
+ arg :filename, :optional, 'Contents of file will be POSTed'
55
+
56
+ version Poke::Stick::VERSION
57
+
58
+ use_log_level_option :toggle_debug_on_signal => 'USR1'
59
+
60
+ go!
61
+ end
@@ -0,0 +1,13 @@
1
+ Feature: Poke: The Stick
2
+
3
+ Scenario: --help
4
+ When I get help for "poke-stick"
5
+ Then the exit status should be 0
6
+ And the banner should be present
7
+ And the banner should document that this app takes options
8
+ And the following options should be documented:
9
+ |--version |
10
+ |--help |
11
+ |--file |
12
+ |--mimetype |
13
+ |--extension|
@@ -0,0 +1 @@
1
+ # Put your step definitions here
@@ -0,0 +1,16 @@
1
+ require 'aruba/cucumber'
2
+ require 'methadone/cucumber'
3
+
4
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
6
+
7
+ Before do
8
+ # Using "announce" causes massive warnings on 1.9.2
9
+ @puts = true
10
+ @original_rubylib = ENV['RUBYLIB']
11
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
12
+ end
13
+
14
+ After do
15
+ ENV['RUBYLIB'] = @original_rubylib
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'poke/stick/version'
2
+ require 'net/http'
3
+
4
+ module Poke
5
+ class Stick
6
+ class << self
7
+ def post(uri, io, options)
8
+ request = Net::HTTP::Post.new(uri).tap do |r|
9
+ r.body = io.read # Danger Will Robinson! What if Big File?
10
+ r.content_type = options[:mimetype]
11
+ end
12
+ process_request request, options
13
+ end
14
+
15
+ def get(uri, options)
16
+ request = Net::HTTP::Get.new(uri)
17
+ process_request request, options
18
+ end
19
+
20
+ def process_request(request, options)
21
+ uri = request.uri
22
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
23
+ http.request(request)
24
+ end
25
+ print_response response, options
26
+ end
27
+
28
+ def print_response(response, options)
29
+ if options[:verbose]
30
+ puts <<-OUT
31
+ #{response.code} #{response.msg}
32
+ Content-Type: #{response.content_type}
33
+
34
+ OUT
35
+ end
36
+ puts response.body
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ module Poke
2
+ class Stick
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'poke/stick/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "poke-stick"
8
+ spec.version = Poke::Stick::VERSION
9
+ spec.authors = ["Joel Helbling"]
10
+ spec.email = ["joel@joelhelbling.com"]
11
+ spec.summary = %q{A command-line client for the Poke message transport server.}
12
+ spec.description = %q{A command-line client for the Poke message transport server.}
13
+ spec.homepage = "http://github.com/joelhelbling/poke-stick"
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency('rdoc')
24
+ spec.add_development_dependency('aruba')
25
+ spec.add_dependency('methadone', '~> 1.8.0')
26
+ spec.add_dependency('rack', '~> 1.6.0')
27
+ spec.add_development_dependency('rspec', '~> 2.99')
28
+ spec.add_development_dependency('pry', '~> 0.10.1')
29
+ end
@@ -0,0 +1,5 @@
1
+ describe "TestSomething" do
2
+ it "should be true" do
3
+ true.should == true
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: poke-stick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joel Helbling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
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: aruba
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: methadone
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.99'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.99'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.10.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.10.1
125
+ description: A command-line client for the Poke message transport server.
126
+ email:
127
+ - joel@joelhelbling.com
128
+ executables:
129
+ - stick
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - README.rdoc
138
+ - Rakefile
139
+ - bin/stick
140
+ - features/poke-stick.feature
141
+ - features/step_definitions/poke-stick_steps.rb
142
+ - features/support/env.rb
143
+ - lib/poke/stick.rb
144
+ - lib/poke/stick/version.rb
145
+ - poke-stick.gemspec
146
+ - spec/something_spec.rb
147
+ homepage: http://github.com/joelhelbling/poke-stick
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.4.3
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: A command-line client for the Poke message transport server.
171
+ test_files:
172
+ - features/poke-stick.feature
173
+ - features/step_definitions/poke-stick_steps.rb
174
+ - features/support/env.rb
175
+ - spec/something_spec.rb