nosh 0.1.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.
@@ -0,0 +1,4 @@
1
+ lib/**/*.rb
2
+ README.rdoc
3
+ ChangeLog.rdoc
4
+ LICENSE.txt
File without changes
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.rvmrc ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="1.9.2@nosh"
8
+
9
+ #
10
+ # First we attempt to load the desired environment directly from the environment
11
+ # file, this is very fast and efficicent compared to running through the entire
12
+ # CLI and selector. If you want feedback on which environment was used then
13
+ # insert the word 'use' after --create as this triggers verbose mode.
14
+ #
15
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
17
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
18
+ else
19
+ # If the environment file has not yet been created, use the RVM CLI to select.
20
+ rvm --create "$environment_id"
21
+ fi
22
+
23
+ #
24
+ # If you use bundler and would like to run bundle each time you enter the
25
+ # directory you can uncomment the following code.
26
+ #
27
+
28
+ # Ensure that ore-core is installed.
29
+ if [[ `gem list -i ore-core` -ne "true" ]]; then
30
+ printf "The rubygem 'ore-core' is not installed, installing it now.\n"
31
+ gem install ore-core --version "~> 0.1"
32
+ fi
33
+
34
+ # Ensure that Bundler is installed, install it if it is not.
35
+ if ! command -v bundle ; then
36
+ printf "The rubygem 'bundler' is not installed, installing it now.\n"
37
+ gem install bundler --version "~> 1.0.0"
38
+ fi
39
+
40
+ # Bundle while reducing excess noise.
41
+ printf "Bundling your gems this may take a few minutes on a fresh clone.\n"
42
+ bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake', '~> 0.8.7'
7
+ gem 'ore-tasks', '~> 0.4'
8
+ gem 'rspec', '~> 2.4'
9
+ gem 'guard', '~> 0.4.2'
10
+ gem 'guard-rspec', '~> 0.4.0'
11
+ gem 'growl', '~> 1.0.3'
12
+ gem 'simplecov', '~> 0.4.2'
13
+ end
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ezekiel Templin
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.
@@ -0,0 +1,38 @@
1
+ nosh
2
+ ====
3
+
4
+ Description
5
+ -----------
6
+
7
+ A very simple Typhoeus/Nokogiri wrapper. Conceptually based on the eat library.
8
+
9
+ Usage
10
+ -----
11
+
12
+ require 'nosh'
13
+
14
+ nosh("http://www.google.com/") #=> Response body as string
15
+ "http://www.google.com/".nosh #=> same
16
+
17
+ nosh("http://www.google.com/", true) #=> Parsed Nokogiri XML/HTML document
18
+ "http://www.google.com/".nosh(true) #=> same
19
+
20
+ nosh("http://httpstat.us/301") #=> Prints status code and message
21
+ "http://httpstat.us/301".nosh #=> same
22
+
23
+ Requirements
24
+ ------------
25
+ * Typhoeus (v0.2.4)
26
+ * Nokogiri (v1.4.6)
27
+
28
+ Install
29
+ -------
30
+
31
+ $ gem install nosh
32
+
33
+ Copyright
34
+ ---------
35
+
36
+ Copyright (c) 2011 Ezekiel Templin
37
+
38
+ See LICENSE.txt for details.
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ STDERR.puts e.message
9
+ STDERR.puts "Run `gem install bundler` to install Bundler."
10
+ exit e.status_code
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ STDERR.puts e.message
17
+ STDERR.puts "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'ore/tasks'
24
+ Ore::Tasks.new
25
+
26
+ require 'rake/rdoctask'
27
+ Rake::RDocTask.new do |rdoc|
28
+ rdoc.title = "nosh"
29
+ end
30
+ task :doc => :rdoc
31
+
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new
34
+
35
+ task :test => :spec
36
+ task :default => :spec
37
+
@@ -0,0 +1,14 @@
1
+ name: nosh
2
+ summary: Another Typhoeus/Nokogiri wrapper.
3
+ description: A very simple Typhoeus/Nokogiri wrapper. Conceptually based on the eat library.
4
+ license: MIT
5
+ authors: Ezekiel Templin
6
+ email: ezkl@me.com
7
+ homepage: https://github.com/ezkl/nosh
8
+
9
+ runtime_dependencies:
10
+ typhoeus: ~> 0.2.4
11
+ nokogiri: ~> 1.4.6
12
+
13
+ development_dependencies:
14
+ bundler: ~> 1.0.0
@@ -0,0 +1,26 @@
1
+ require 'typhoeus'
2
+ require 'nokogiri'
3
+ require 'singleton'
4
+
5
+ require_relative 'nosh/version'
6
+
7
+ module Nosh
8
+ module ObjectExtensions
9
+ def nosh(url, parse = false)
10
+ if (response = ::Typhoeus::Request.get(url)).success?
11
+ parse ? ::Nokogiri.parse(response.body) : response.body
12
+ else
13
+ puts "[#{response.code}]: \"#{response.status_message}\""
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ class String
21
+ def nosh(parse = false)
22
+ Nosh::ObjectExtensions.nosh(self, parse)
23
+ end
24
+ end
25
+
26
+ ::Object.send(:include, ::Nosh::ObjectExtensions) unless ::Object.method_defined?(:nosh)
@@ -0,0 +1,4 @@
1
+ module Nosh
2
+ # nosh version
3
+ VERSION = "0.1.0"
4
+ end
@@ -0,0 +1,127 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gemspec|
6
+ files = if File.directory?('.git')
7
+ `git ls-files`.split($/)
8
+ elsif File.directory?('.hg')
9
+ `hg manifest`.split($/)
10
+ elsif File.directory?('.svn')
11
+ `svn ls -R`.split($/).select { |path| File.file?(path) }
12
+ else
13
+ Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
14
+ end
15
+
16
+ filter_files = lambda { |paths|
17
+ case paths
18
+ when Array
19
+ (files & paths)
20
+ when String
21
+ (files & Dir[paths])
22
+ end
23
+ }
24
+
25
+ version = {
26
+ :file => 'lib/nosh/version.rb',
27
+ :constant => 'Nosh::VERSION'
28
+ }
29
+
30
+ defaults = {
31
+ 'name' => File.basename(File.dirname(__FILE__)),
32
+ 'files' => files,
33
+ 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
34
+ 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
35
+ 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
36
+ }
37
+
38
+ metadata = defaults.merge(YAML.load_file('gemspec.yml'))
39
+
40
+ gemspec.name = metadata.fetch('name',defaults[:name])
41
+ gemspec.version = if metadata['version']
42
+ metadata['version']
43
+ elsif File.file?(version[:file])
44
+ require File.join('.',version[:file])
45
+ eval(version[:constant])
46
+ end
47
+
48
+ gemspec.summary = metadata.fetch('summary',metadata['description'])
49
+ gemspec.description = metadata.fetch('description',metadata['summary'])
50
+
51
+ case metadata['license']
52
+ when Array
53
+ gemspec.licenses = metadata['license']
54
+ when String
55
+ gemspec.license = metadata['license']
56
+ end
57
+
58
+ case metadata['authors']
59
+ when Array
60
+ gemspec.authors = metadata['authors']
61
+ when String
62
+ gemspec.author = metadata['authors']
63
+ end
64
+
65
+ gemspec.email = metadata['email']
66
+ gemspec.homepage = metadata['homepage']
67
+
68
+ case metadata['require_paths']
69
+ when Array
70
+ gemspec.require_paths = metadata['require_paths']
71
+ when String
72
+ gemspec.require_path = metadata['require_paths']
73
+ end
74
+
75
+ gemspec.files = filter_files[metadata['files']]
76
+
77
+ gemspec.executables = metadata['executables']
78
+ gemspec.extensions = metadata['extensions']
79
+
80
+ if Gem::VERSION < '1.7.'
81
+ gemspec.default_executable = gemspec.executables.first
82
+ end
83
+
84
+ gemspec.test_files = filter_files[metadata['test_files']]
85
+
86
+ unless gemspec.files.include?('.document')
87
+ gemspec.extra_rdoc_files = metadata['extra_doc_files']
88
+ end
89
+
90
+ gemspec.post_install_message = metadata['post_install_message']
91
+ gemspec.requirements = metadata['requirements']
92
+
93
+ if gemspec.respond_to?(:required_ruby_version=)
94
+ gemspec.required_ruby_version = metadata['required_ruby_version']
95
+ end
96
+
97
+ if gemspec.respond_to?(:required_rubygems_version=)
98
+ gemspec.required_rubygems_version = metadata['required_ruby_version']
99
+ end
100
+
101
+ parse_versions = lambda { |versions|
102
+ case versions
103
+ when Array
104
+ versions.map { |v| v.to_s }
105
+ when String
106
+ versions.split(/,\s*/)
107
+ end
108
+ }
109
+
110
+ if metadata['dependencies']
111
+ metadata['dependencies'].each do |name,versions|
112
+ gemspec.add_dependency(name,parse_versions[versions])
113
+ end
114
+ end
115
+
116
+ if metadata['runtime_dependencies']
117
+ metadata['runtime_dependencies'].each do |name,versions|
118
+ gemspec.add_runtime_dependency(name,parse_versions[versions])
119
+ end
120
+ end
121
+
122
+ if metadata['development_dependencies']
123
+ metadata['development_dependencies'].each do |name,versions|
124
+ gemspec.add_development_dependency(name,parse_versions[versions])
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'nosh'
3
+
4
+ describe Nosh do
5
+ it "should have a VERSION constant" do
6
+ subject.const_get('VERSION').should_not be_empty
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'rspec'
5
+ require 'nosh/version'
6
+
7
+ include Nosh
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nosh
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Ezekiel Templin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-30 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: typhoeus
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.2.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: nokogiri
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ description: A very simple Typhoeus/Nokogiri wrapper. Conceptually based on the eat library.
49
+ email:
50
+ - ezkl@me.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - README.md
57
+ files:
58
+ - .document
59
+ - .gemtest
60
+ - .rspec
61
+ - .rvmrc
62
+ - Gemfile
63
+ - Guardfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - gemspec.yml
68
+ - lib/nosh.rb
69
+ - lib/nosh/version.rb
70
+ - nosh.gemspec
71
+ - spec/nosh_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/ezkl/nosh
74
+ licenses:
75
+ - MIT
76
+ post_install_message:
77
+ rdoc_options: []
78
+
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.3.6
93
+ requirements: []
94
+
95
+ rubyforge_project: nosh
96
+ rubygems_version: 1.8.5
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Another Typhoeus/Nokogiri wrapper.
100
+ test_files:
101
+ - spec/nosh_spec.rb