darkhelmet-darkext 0.9.7 → 0.10.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.
- data/VERSION.yml +2 -2
- data/app_generators/sinatra_app_generator.rb +52 -0
- data/app_generators/templates/app.rb +16 -0
- data/app_generators/templates/error.rb +8 -0
- data/app_generators/templates/helpers.rb +12 -0
- data/app_generators/templates/http_method.rb +8 -0
- data/app_generators/templates/options.rb +9 -0
- data/bin/sinatra-app +14 -0
- data/lib/darkext/beagle.rb +3 -3
- data/lib/darkext/net.rb +14 -3
- data/lib/darkext/object.rb +6 -1
- data/lib/darkext/sinatra.rb +2 -1
- data/spec/spec.opts +2 -0
- data/test/{test_darkext.rb → darkext_test.rb} +3 -4
- data/test/{test_helper.rb → helper.rb} +1 -0
- metadata +19 -10
data/VERSION.yml
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
class SinatraAppGenerator < RubiGen::Base
|
4
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
5
|
+
Config::CONFIG['ruby_install_name'])
|
6
|
+
|
7
|
+
default_options(:shebang => DEFAULT_SHEBANG)
|
8
|
+
|
9
|
+
attr_accessor :app_name, :module_name, :app_name_fixed
|
10
|
+
|
11
|
+
def initialize(runtime_args, runtime_options = {})
|
12
|
+
super
|
13
|
+
usage if args.empty?
|
14
|
+
@destination_root = args.shift
|
15
|
+
self.app_name = File.basename(File.expand_path(@destination_root))
|
16
|
+
self.app_name_fixed = self.app_name.split('-').map(&:capitalize).join
|
17
|
+
self.module_name = app_name.camelize
|
18
|
+
end
|
19
|
+
|
20
|
+
def manifest
|
21
|
+
# Use /usr/bin/env if no special shebang was specified
|
22
|
+
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
|
23
|
+
windows = (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
|
24
|
+
|
25
|
+
record do |m|
|
26
|
+
# Root directory and all subdirectories.
|
27
|
+
m.directory('')
|
28
|
+
%w(lib public views).each { |path| m.directory(path) }
|
29
|
+
%w(get put post delete).each do |path|
|
30
|
+
m.template('http_method.rb', "lib/#{path}.rb", :assigns => { :method => path })
|
31
|
+
end
|
32
|
+
m.template('helpers.rb', 'lib/helpers.rb')
|
33
|
+
m.template('options.rb', 'lib/options.rb')
|
34
|
+
m.template('error.rb', 'lib/error.rb')
|
35
|
+
m.template('app.rb', "#{app_name}.rb", script_options)
|
36
|
+
#m.dependency "install_rubigen_scripts", [destination_root, "rubygems"], :shebang => options[:shebang]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def banner
|
42
|
+
"Create a stub for #{File.basename $0} to get started."
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_options!(opts)
|
46
|
+
opts.separator ''
|
47
|
+
opts.separator 'Options:'
|
48
|
+
opts.on("-r", "--ruby=path", String,
|
49
|
+
"Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
|
50
|
+
"Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v }
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
%w(rubygems sinatra/base darkext darkext/sinatra).each { |lib| require lib }
|
4
|
+
Dir['lib/*.rb'].each { |file| load file }
|
5
|
+
|
6
|
+
load 'local_options.rb' if File.exists?('local_options.rb')
|
7
|
+
|
8
|
+
class <%= app_name_fixed %>Site < Sinatra::Default
|
9
|
+
set(:app_file, File.expand_path(__FILE__))
|
10
|
+
register Sinatra::DarkHelpers
|
11
|
+
<% for lib in %w(Options Helpers Error Get Post Put Delete) %>
|
12
|
+
register Sinatra::<%= app_name_fixed %><%= lib %><% end %>
|
13
|
+
register Sinatra::LocalOptions unless defined?(Sinatra::LocalOptions).nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
<%= app_name_fixed %>Site.run! if __FILE__ == $0
|
data/bin/sinatra-app
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require 'newgem/version'
|
8
|
+
puts "#{File.basename($0)} #{Newgem::VERSION}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
RubiGen::Base.use_application_sources!
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'SinatraApp')
|
data/lib/darkext/beagle.rb
CHANGED
@@ -17,16 +17,16 @@ module Beagle
|
|
17
17
|
loop do
|
18
18
|
line = @io.gets
|
19
19
|
break if line.nil?
|
20
|
+
line.chomp!
|
21
|
+
break if line.empty? && 0 < result.keys.size
|
20
22
|
if !line.include?('=') || line.starts_with?(' Snip')
|
21
23
|
parts = line.split(':')
|
22
24
|
k = parts.shift.strip
|
23
|
-
break if result.keys.include?(k)
|
24
25
|
v = parts.join(':').strip
|
25
26
|
result[k] = v unless k.empty? || v.empty?
|
26
27
|
elsif line.include?('=')
|
27
28
|
k,v = line.split('=')
|
28
29
|
k = k.split(':').last.strip
|
29
|
-
break if result.keys.include?(k)
|
30
30
|
v = v.gsub("'",'').strip
|
31
31
|
result[k] = v unless k.empty? || v.empty?
|
32
32
|
end
|
@@ -71,7 +71,7 @@ module Beagle
|
|
71
71
|
args << '--verbose'
|
72
72
|
args << '--max-hits'
|
73
73
|
args << max_hits.to_s
|
74
|
-
args << query
|
74
|
+
args << "\"#{query.gsub('"','\"')}\""
|
75
75
|
return BeagleResultsHelper.new(IO.popen(args.join(' ')))
|
76
76
|
end
|
77
77
|
|
data/lib/darkext/net.rb
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module Net
|
4
|
-
def self.download(url)
|
5
|
-
|
4
|
+
def self.download(url,limit = 10)
|
5
|
+
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
6
|
+
#url = URI.parse(url)
|
7
|
+
#req = Net::HTTP::Get.new(url.path)
|
8
|
+
#req['User-Agent'] = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009030422 Ubuntu/8.10 (intrepid) Firefox/3.0.7"
|
9
|
+
#resp = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
|
10
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
11
|
+
case resp
|
12
|
+
when Net::HTTPSuccess then resp
|
13
|
+
when Net::HTTPRedirection then download(resp['location'], limit - 1)
|
14
|
+
else
|
15
|
+
resp.error!
|
16
|
+
end
|
6
17
|
end
|
7
18
|
|
8
19
|
def self.download_and_save(url,path = nil)
|
@@ -12,6 +23,6 @@ module Net
|
|
12
23
|
path = File.expand_path(path)
|
13
24
|
end
|
14
25
|
resp = download(url)
|
15
|
-
open(path,'w') { |file| file.write(resp) } if resp.
|
26
|
+
open(path,'w') { |file| file.write(resp.body) } if resp.is_a?(Net::HTTPSuccess)
|
16
27
|
end
|
17
28
|
end
|
data/lib/darkext/object.rb
CHANGED
data/lib/darkext/sinatra.rb
CHANGED
data/spec/spec.opts
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darkhelmet-darkext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Huckstep
|
@@ -9,22 +9,30 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-03-18 00:00:00 -07:00
|
13
|
+
default_executable: sinatra-app
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Just some useful Ruby functionality. No particular focus, except usefulness
|
17
17
|
email: darkhelmet@darkhelmetlive.com
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- sinatra-app
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
24
|
files:
|
25
25
|
- VERSION.yml
|
26
26
|
- README.rdoc
|
27
27
|
- History.txt
|
28
|
+
- bin/sinatra-app
|
29
|
+
- app_generators/sinatra_app_generator.rb
|
30
|
+
- app_generators/templates
|
31
|
+
- app_generators/templates/http_method.rb
|
32
|
+
- app_generators/templates/app.rb
|
33
|
+
- app_generators/templates/helpers.rb
|
34
|
+
- app_generators/templates/options.rb
|
35
|
+
- app_generators/templates/error.rb
|
28
36
|
- lib/darkext
|
29
37
|
- lib/darkext/numeric.rb
|
30
38
|
- lib/darkext/string.rb
|
@@ -43,8 +51,9 @@ files:
|
|
43
51
|
- lib/darkext/float.rb
|
44
52
|
- lib/darkext/integer.rb
|
45
53
|
- lib/darkext.rb
|
46
|
-
- test/
|
47
|
-
- test/
|
54
|
+
- test/helper.rb
|
55
|
+
- test/darkext_test.rb
|
56
|
+
- spec/spec.opts
|
48
57
|
has_rdoc: true
|
49
58
|
homepage: http://github.com/darkhelmet/darkext
|
50
59
|
post_install_message:
|
@@ -70,7 +79,7 @@ requirements: []
|
|
70
79
|
rubyforge_project:
|
71
80
|
rubygems_version: 1.2.0
|
72
81
|
signing_key:
|
73
|
-
specification_version:
|
82
|
+
specification_version: 3
|
74
83
|
summary: Just some useful Ruby functionality
|
75
84
|
test_files: []
|
76
85
|
|