websolr-rails 2.3.3 → 2.4.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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 2.4.0
2
+ - added the --app option for heroku users
1
3
  2.3.3
2
4
  - added a CHANGELOG
3
- - Fixed "master_session" bug with Sunspot
5
+ - Fixed "master_session" bug with Sunspot (via notch8)
data/Rakefile CHANGED
@@ -36,9 +36,21 @@ rescue LoadError
36
36
  end
37
37
  end
38
38
 
39
- task :test => :check_dependencies
39
+ require 'spec/rake/spectask'
40
+ Spec::Rake::SpecTask.new(:spec) do |spec|
41
+ spec.libs << 'lib' << 'spec'
42
+ spec.spec_files = FileList['spec/**/*_spec.rb']
43
+ end
44
+
45
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
46
+ spec.libs << 'lib' << 'spec'
47
+ spec.pattern = 'spec/**/*_spec.rb'
48
+ spec.rcov = true
49
+ end
50
+
51
+ task :spec => :check_dependencies
40
52
 
41
- task :default => :test
53
+ task :default => :spec
42
54
 
43
55
  require 'rake/rdoctask'
44
56
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.0
@@ -6,7 +6,7 @@ require "restclient"
6
6
  HOST = "www.websolr.com"
7
7
 
8
8
  PWD = File.expand_path(".")
9
- controller = PlainOptionParser.new(ARGV) do
9
+ controller = PlainOptionParser.new do
10
10
  def die(s)
11
11
  STDERR.puts(s.strip)
12
12
  exit(1)
@@ -14,7 +14,8 @@ controller = PlainOptionParser.new(ARGV) do
14
14
 
15
15
  def init_heroku
16
16
  puts "Getting username and password from Heroku config ... "
17
- cfg = `heroku config`
17
+ app = flags["app"] ? "--app=#{flags["app"]}" : ""
18
+ cfg = `heroku config #{app}`
18
19
  @user = cfg[/WEBSOLR_USER\s*=>\s*(\S+)/, 1]
19
20
  @pass = cfg[/WEBSOLR_PWD\s*=>\s*(\S+)/, 1]
20
21
  unless @user && @pass
@@ -37,4 +38,4 @@ with the Websolr addon enabled?
37
38
  init_heroku
38
39
  puts RestClient.post(@url, :client => client)
39
40
  end
40
- end.start
41
+ end.start(ARGV)
@@ -1,5 +1,7 @@
1
1
  class PlainOptionParser
2
- def initialize(args, &block)
2
+ attr_reader :flags
3
+
4
+ def initialize(&block)
3
5
  @commands = []
4
6
  desc "Prints help text for your command"
5
7
  cmd "help" do
@@ -10,15 +12,13 @@ class PlainOptionParser
10
12
  pretty_print viable
11
13
  end
12
14
  end
13
- @args = args
14
15
  instance_eval(&block)
15
16
  end
16
17
 
17
- def start
18
- viable, remaining = commands_for_args(@args)
18
+ def start(args)
19
+ viable, remaining = commands_for_args(args)
19
20
  if viable.length == 1
20
21
  viable[0].last.call(*remaining)
21
- exit 0
22
22
  elsif viable.length == 0
23
23
  no_match
24
24
  else
@@ -55,7 +55,29 @@ private
55
55
  puts "COMMANDS: "
56
56
  end
57
57
 
58
+
59
+ KV_FLAG = /--(.*)=(.*)/
60
+ K_FLAG = /--(.*)/
61
+ def strip_flags(args)
62
+ @flags ||= {}
63
+ @prev = nil
64
+ args.map do |arg|
65
+ if arg =~ KV_FLAG
66
+ @flags[$1] = $2
67
+ nil
68
+ elsif @prev
69
+ @flags[@prev] = arg
70
+ @prev = nil
71
+ elsif @prev = arg[K_FLAG, 1]
72
+ nil
73
+ else
74
+ arg
75
+ end
76
+ end.compact
77
+ end
78
+
58
79
  def commands_for_args(args)
80
+ args = strip_flags(args)
59
81
  viable = @commands.dup
60
82
  args.each_with_index do |arg, i|
61
83
  @commands.each do |cmd|
@@ -63,7 +85,7 @@ private
63
85
  viable.delete(cmd) if name[i] != arg
64
86
  end
65
87
  if viable.length == 1
66
- return [viable, args[viable[0][0].length, @args.length]]
88
+ return [viable, args[viable[0][0].length, args.length]]
67
89
  end
68
90
  end
69
91
  return [viable, []]
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ $pop = PlainOptionParser.new do
4
+ desc "set abc"
5
+ cmd "test set abc" do |value|
6
+ $abc = value
7
+ $abc += flags["app"] if flags["app"]
8
+ end
9
+
10
+ desc "unset abc"
11
+ cmd "test unset abc" do |client|
12
+ $abc = false
13
+ end
14
+ end
15
+
16
+ describe "PlainOptionParser" do
17
+ it "should set abc" do
18
+ $pop.start %w[test set abc 123]
19
+ $abc.should == "123"
20
+ end
21
+
22
+ it "should unset abc" do
23
+ $pop.start %w[test unset abc]
24
+ $abc.should be_false
25
+ end
26
+
27
+ it "should take a flag" do
28
+ $pop.start %w[test set abc 123 --app foo]
29
+ $abc.should == "123foo"
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'plain_option_parser'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{websolr-rails}
8
- s.version = "2.3.3"
8
+ s.version = "2.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kyle Maxwell"]
12
- s.date = %q{2009-12-15}
12
+ s.date = %q{2010-01-06}
13
13
  s.default_executable = %q{websolr}
14
14
  s.description = %q{Makes Sunspot and acts_as_solr play with WebSolr}
15
15
  s.email = %q{kyle@kylemaxwell.com}
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/plain_option_parser.rb",
31
31
  "lib/websolr-rails.rb",
32
32
  "lib/websolr.rb",
33
+ "spec/plain_option_parser_spec.rb",
34
+ "spec/spec_helper.rb",
33
35
  "websolr-rails.gemspec"
34
36
  ]
35
37
  s.homepage = %q{http://github.com/onemorecloud/websolr-rails}
@@ -37,6 +39,10 @@ Gem::Specification.new do |s|
37
39
  s.require_paths = ["lib"]
38
40
  s.rubygems_version = %q{1.3.5}
39
41
  s.summary = %q{WebSolr adapter}
42
+ s.test_files = [
43
+ "spec/plain_option_parser_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
40
46
 
41
47
  if s.respond_to? :specification_version then
42
48
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websolr-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Maxwell
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-15 00:00:00 -08:00
12
+ date: 2010-01-06 00:00:00 -08:00
13
13
  default_executable: websolr
14
14
  dependencies: []
15
15
 
@@ -34,6 +34,8 @@ files:
34
34
  - lib/plain_option_parser.rb
35
35
  - lib/websolr-rails.rb
36
36
  - lib/websolr.rb
37
+ - spec/plain_option_parser_spec.rb
38
+ - spec/spec_helper.rb
37
39
  - websolr-rails.gemspec
38
40
  has_rdoc: true
39
41
  homepage: http://github.com/onemorecloud/websolr-rails
@@ -63,5 +65,6 @@ rubygems_version: 1.3.5
63
65
  signing_key:
64
66
  specification_version: 3
65
67
  summary: WebSolr adapter
66
- test_files: []
67
-
68
+ test_files:
69
+ - spec/plain_option_parser_spec.rb
70
+ - spec/spec_helper.rb