LittleWeasel 3.0.2 → 3.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de2d75fa6cd655bfb217bb6f6c5aaa91d02d9862
4
- data.tar.gz: 765f39d8a4e49a7e7485b365268ac8ce3886a938
3
+ metadata.gz: 8077ebd3ea097532c9ca167b79b3195903a4ff1c
4
+ data.tar.gz: b7ff804920931aff1c2567ae0c056fdfc8768026
5
5
  SHA512:
6
- metadata.gz: 442db04e9f15858c59a773d3d8febe00c9ac2e7acfbe36caa0480deacd00905460211dc2ef229415e05e3c6b820d1d621cbe49dcfd8aac18a0fe339c66bee106
7
- data.tar.gz: df0ca820cdc33934ed610e4683f1d01ff7eaa017de62a0778cbcbec09f9a51d3d68206faa1fb050c0e19ec64e7d8841c23f978588a969a82ad845c65a1ce6d54
6
+ metadata.gz: b6c3711660636e2cd4db68bd86308e31935659fc8499e6fbce8b46331dac57b0d70035a8988612d3fbe6c43eb495464aa021b21b3e12a2d8dbc9d0301227228e
7
+ data.tar.gz: d9a1bf68f2144b54a20ab7010708d0487e5168703dcee4828a2cf557ca4f111012fea5a70361b98e9fb600a36ab25c3d26fabd0aa92c374bb37581d2af4172e1
data/.idea/workspace.xml CHANGED
@@ -2,8 +2,6 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="34d4ec05-51d8-442a-84a5-75b5005cedf0" name="Default" comment="">
5
- <change type="DELETED" beforePath="$PROJECT_DIR$/.rbenv-version" afterPath="" />
6
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/LittleWeasel/version.rb" afterPath="$PROJECT_DIR$/lib/LittleWeasel/version.rb" />
7
5
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
8
6
  </list>
9
7
  <ignored path="LittleWeasel.iws" />
@@ -45,18 +43,28 @@
45
43
  <file leaf-file-name=".ruby-version" pinned="false" current="false" current-in-tab="false">
46
44
  <entry file="file://$PROJECT_DIR$/.ruby-version">
47
45
  <provider selected="true" editor-type-id="text-editor">
48
- <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="105">
46
+ <state vertical-scroll-proportion="0.0" vertical-offset="15" max-vertical-offset="105">
49
47
  <caret line="1" column="22" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
50
48
  <folding />
51
49
  </state>
52
50
  </provider>
53
51
  </entry>
54
52
  </file>
55
- <file leaf-file-name="version.rb" pinned="false" current="true" current-in-tab="true">
53
+ <file leaf-file-name="version.rb" pinned="false" current="false" current-in-tab="false">
56
54
  <entry file="file://$PROJECT_DIR$/lib/LittleWeasel/version.rb">
57
55
  <provider selected="true" editor-type-id="text-editor">
58
- <state vertical-scroll-proportion="0.05586592" vertical-offset="0" max-vertical-offset="537">
59
- <caret line="2" column="18" selection-start-line="2" selection-start-column="18" selection-end-line="2" selection-end-column="18" />
56
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="150">
57
+ <caret line="4" column="17" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
58
+ <folding />
59
+ </state>
60
+ </provider>
61
+ </entry>
62
+ </file>
63
+ <file leaf-file-name="LittleWeasel.gemspec" pinned="false" current="true" current-in-tab="true">
64
+ <entry file="file://$PROJECT_DIR$/LittleWeasel.gemspec">
65
+ <provider selected="true" editor-type-id="text-editor">
66
+ <state vertical-scroll-proportion="0.5009276" vertical-offset="0" max-vertical-offset="539">
67
+ <caret line="18" column="86" selection-start-line="18" selection-start-column="30" selection-end-line="18" selection-end-column="30" />
60
68
  <folding />
61
69
  </state>
62
70
  </provider>
@@ -65,7 +73,7 @@
65
73
  <file leaf-file-name="LittleWeasel.rb" pinned="false" current="false" current-in-tab="false">
66
74
  <entry file="file://$PROJECT_DIR$/lib/LittleWeasel.rb">
67
75
  <provider selected="true" editor-type-id="text-editor">
68
- <state vertical-scroll-proportion="0.0" vertical-offset="1962" max-vertical-offset="2715">
76
+ <state vertical-scroll-proportion="0.0" vertical-offset="2100" max-vertical-offset="2715">
69
77
  <caret line="140" column="37" selection-start-line="140" selection-start-column="37" selection-end-line="140" selection-end-column="37" />
70
78
  <folding />
71
79
  </state>
@@ -75,7 +83,7 @@
75
83
  <file leaf-file-name="operators.rb" pinned="false" current="false" current-in-tab="false">
76
84
  <entry file="file://$PROJECT_DIR$/vendor/bundle/gems/rspec-expectations-3.0.2/lib/rspec/matchers/built_in/operators.rb">
77
85
  <provider selected="true" editor-type-id="text-editor">
78
- <state vertical-scroll-proportion="0.0" vertical-offset="567" max-vertical-offset="1875">
86
+ <state vertical-scroll-proportion="0.0" vertical-offset="705" max-vertical-offset="1875">
79
87
  <caret line="47" column="0" selection-start-line="47" selection-start-column="0" selection-end-line="47" selection-end-column="0" />
80
88
  <folding />
81
89
  </state>
@@ -503,14 +511,14 @@
503
511
  </component>
504
512
  <component name="ToolWindowManager">
505
513
  <frame x="0" y="22" width="1440" height="874" extended-state="6" />
506
- <editor active="true" />
514
+ <editor active="false" />
507
515
  <layout>
508
516
  <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
509
- <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2526455" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
517
+ <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2519789" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
510
518
  <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
511
519
  <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
512
520
  <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
513
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.28826895" sideWeight="0.6697613" order="0" side_tool="false" content_ui="combo" />
521
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.29256082" sideWeight="0.6697613" order="0" side_tool="false" content_ui="combo" />
514
522
  <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39814815" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
515
523
  <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
516
524
  <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
@@ -518,12 +526,12 @@
518
526
  <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32849604" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
519
527
  <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
520
528
  <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
521
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32539684" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
522
529
  <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
530
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32539684" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
523
531
  <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32936507" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
524
532
  <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
525
- <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
526
533
  <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
534
+ <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
527
535
  </layout>
528
536
  </component>
529
537
  <component name="Vcs.Log.UiProperties">
@@ -793,14 +801,14 @@
793
801
  </provider>
794
802
  </entry>
795
803
  <entry file="file://$PROJECT_DIR$/LICENSE.txt">
804
+ <provider editor-type-id="com.intellij.persistence.database.editor.CsvTableFileEditorProvider">
805
+ <state />
806
+ </provider>
796
807
  <provider selected="true" editor-type-id="text-editor">
797
808
  <state vertical-scroll-proportion="-12.222222" vertical-offset="0" max-vertical-offset="0">
798
809
  <caret line="22" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
799
810
  </state>
800
811
  </provider>
801
- <provider editor-type-id="com.intellij.persistence.database.editor.CsvTableFileEditorProvider">
802
- <state />
803
- </provider>
804
812
  </entry>
805
813
  <entry file="file://$PROJECT_DIR$/Gemfile.lock">
806
814
  <provider selected="true" editor-type-id="text-editor">
@@ -887,18 +895,10 @@
887
895
  </state>
888
896
  </provider>
889
897
  </entry>
890
- <entry file="file://$PROJECT_DIR$/LittleWeasel.gemspec">
891
- <provider selected="true" editor-type-id="text-editor">
892
- <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="510">
893
- <caret line="18" column="86" selection-start-line="18" selection-start-column="30" selection-end-line="18" selection-end-column="30" />
894
- </state>
895
- </provider>
896
- </entry>
897
898
  <entry file="file://$PROJECT_DIR$/vendor/bundle/gems/rspec-core-3.0.2/lib/rspec/core/example.rb">
898
899
  <provider selected="true" editor-type-id="text-editor">
899
900
  <state vertical-scroll-proportion="0.3325301" vertical-offset="2262" max-vertical-offset="7200">
900
901
  <caret line="160" column="0" selection-start-line="160" selection-start-column="0" selection-end-line="160" selection-end-column="0" />
901
- <folding />
902
902
  </state>
903
903
  </provider>
904
904
  </entry>
@@ -906,7 +906,6 @@
906
906
  <provider selected="true" editor-type-id="text-editor">
907
907
  <state vertical-scroll-proportion="0.3325527" vertical-offset="518" max-vertical-offset="2040">
908
908
  <caret line="44" column="0" selection-start-line="44" selection-start-column="0" selection-end-line="44" selection-end-column="0" />
909
- <folding />
910
909
  </state>
911
910
  </provider>
912
911
  </entry>
@@ -944,8 +943,16 @@
944
943
  </entry>
945
944
  <entry file="file://$PROJECT_DIR$/lib/LittleWeasel/version.rb">
946
945
  <provider selected="true" editor-type-id="text-editor">
947
- <state vertical-scroll-proportion="0.05586592" vertical-offset="0" max-vertical-offset="537">
948
- <caret line="2" column="18" selection-start-line="2" selection-start-column="18" selection-end-line="2" selection-end-column="18" />
946
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="150">
947
+ <caret line="4" column="17" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
948
+ <folding />
949
+ </state>
950
+ </provider>
951
+ </entry>
952
+ <entry file="file://$PROJECT_DIR$/LittleWeasel.gemspec">
953
+ <provider selected="true" editor-type-id="text-editor">
954
+ <state vertical-scroll-proportion="0.5009276" vertical-offset="0" max-vertical-offset="539">
955
+ <caret line="18" column="86" selection-start-line="18" selection-start-column="30" selection-end-line="18" selection-end-column="30" />
949
956
  <folding />
950
957
  </state>
951
958
  </provider>
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ### 3.0.3
2
+
3
+ * enhancements
4
+ * Add single_word_mode option (default: false); when single_word_mode: true, LittleWeasel::Checker.instance.exists? will return false, if more than one word is being checked for existance.
5
+
6
+ ### 3.0.2
7
+
8
+ * enhancements
9
+ * None
10
+
11
+ * bug fix
12
+ * Calling #exists? no longer alters the original input.
@@ -1,4 +1,4 @@
1
1
  # The version of this gem
2
2
  module LittleWeasel
3
- VERSION = "3.0.2"
3
+ VERSION = "3.0.3"
4
4
  end
data/lib/LittleWeasel.rb CHANGED
@@ -24,7 +24,7 @@ module LittleWeasel
24
24
 
25
25
  # The constructor
26
26
  def initialize
27
- @options = {exclude_alphabet: false, strip_whitespace: false, ignore_numeric: true}
27
+ @options = { exclude_alphabet: false, strip_whitespace: false, ignore_numeric: true, single_word_mode: false }
28
28
  @alphabet_exclusion_list = %w{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }
29
29
  @numeric_regex = /^[-+]?[0-9]?(\.[0-9]+)?$+/
30
30
  @word_regex = /\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/
@@ -56,9 +56,11 @@ module LittleWeasel
56
56
  # LittleWeasel::Checker.instance.exists?('90210') # true (default options, ignore_numeric => true)
57
57
  # LittleWeasel::Checker.instance.exists?('90210', {ignore_numeric:false}) # false
58
58
  #
59
- # LittleWeasel::Checker.instance.exists?('Hello World') # true, we're accepting multiple words now :)}
59
+ # LittleWeasel::Checker.instance.exists?('Hello World') # true, we're accepting multiple words now by default (default options, single_word_mode => false) :)
60
60
  # LittleWeasel::Checker.instance.exists?("hello, mister; did I \'mention\'' that lemon cake is \"great?\" It's just wonderful!") # true
61
61
  #
62
+ # LittleWeasel::Checker.instance.exists?('I love ice cream', {single_word_mode:true}) # false; while all the words are valid, more than one word will return false
63
+ #
62
64
  def exists?(word, options=nil)
63
65
  options = options || @options
64
66
 
@@ -68,7 +70,12 @@ module LittleWeasel
68
70
  word.strip! if options[:strip_whitespace]
69
71
 
70
72
  return false if word.empty?
71
- return block_exists? word if block?(word)
73
+
74
+ if block? word
75
+ return false if options[:single_word_mode]
76
+ return block_exists? word
77
+ end
78
+
72
79
  return true if options[:ignore_numeric] && number?(word)
73
80
  return false if options[:exclude_alphabet] && word.length == 1 && @alphabet_exclusion_list.include?(word.upcase)
74
81
 
@@ -79,12 +86,11 @@ module LittleWeasel
79
86
  #
80
87
  # @param [Hash] options options that should apply to all subsequent calls to method *exists?* (see #exists?).
81
88
  # Options set via this property apply to all subsequent queries.
89
+ #
82
90
  # @option options [Boolean] :exclude_alphabet (false) If false, letters of the alphabet are considered words.
83
- # For example, LittleWeasel::Checker.instance.exists?('A'), will return true.
84
91
  # @option options [Boolean] :strip_whitespace (false) If true, leading and trailing spaces are removed before checking to see if the word exists.
85
- # For example, LittleWeasel::Checker.instance.exists?(' Hello ', {strip_whitespace:true}), will return true.
86
92
  # @option options [Boolean] :ignore_numeric (true) If true, numeric values are considered valid words.
87
- # For example, LittleWeasel::Checker.instance.exists?('1999', {ignore_numeric:true}), will return true. # For example, LittleWeasel::Checker.instance.exists?(' Hello ', {strip_whitespace:true}), will return true.
93
+ # @option options [Boolean] :single_word_mode (false) If false, word blocks (more than one word) are considered valid if all the words exist in the dictionary.
88
94
  #
89
95
  # @return [Hash] The options
90
96
  #
@@ -109,6 +115,10 @@ module LittleWeasel
109
115
  # LittleWeasel::Checker.instance.exists?('I watch Beverly Hills 90210') # true (default options, ignore_numeric => true)
110
116
  # LittleWeasel::Checker.instance.exists?('I watch Beverly Hills 90210', {ignore_numeric:false}) # false
111
117
  #
118
+ # LittleWeasel::Checker.instance.options({single_word_mode:true})
119
+ # LittleWeasel::Checker.instance.exists?('I love ice cream') # false; while all the words are valid, more than one word will return false
120
+ # LittleWeasel::Checker.instance.exists?('Baby') # true
121
+ #
112
122
  def options=(options)
113
123
  @options = options
114
124
  end
@@ -255,4 +255,32 @@ describe 'LittleWeasel Word Block Tests' do
255
255
  actual.should == expect
256
256
  end
257
257
 
258
+ end
259
+
260
+ describe "option single_word_mode" do
261
+ before (:all) do
262
+ @spell = LittleWeasel::Checker.instance
263
+ #@spell.options = {exclude_alphabet: true, strip_whitespace: true}
264
+ end
265
+
266
+ describe "set globally" do
267
+ it 'should return true for a valid word block by default' do
268
+ @spell.exists?('I love apple pie').should == true
269
+ end
270
+
271
+ it 'should return false for a valid word block if set to true' do
272
+ @spell.options = { single_word_mode: true }
273
+ @spell.exists?('I love apple pie').should == false
274
+ end
275
+ end
276
+
277
+ describe "set inline" do
278
+ it 'should return false for a valid word block if set to true' do
279
+ @spell.exists?('I hate ice cream', single_word_mode: true).should == false
280
+ end
281
+
282
+ it 'should return true for a valid word block if set to false' do
283
+ @spell.exists?('I had a hard day', single_word_mode: false).should == true
284
+ end
285
+ end
258
286
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LittleWeasel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -134,6 +134,7 @@ files:
134
134
  - ".idea/workspace.xml"
135
135
  - ".rspec"
136
136
  - ".ruby-version"
137
+ - CHANGELOG.md
137
138
  - Gemfile
138
139
  - LICENSE.txt
139
140
  - LittleWeasel.gemspec
@@ -172,3 +173,4 @@ summary: Simply checks a word or group of words for validity against an english
172
173
  test_files:
173
174
  - spec/checker/checker_spec.rb
174
175
  - spec/spec_helper.rb
176
+ has_rdoc: