code_analyzer 0.4.1 → 0.4.2

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: 181ca088af7fc724c6d7a7085e3dd50b90d31a49
4
- data.tar.gz: 70b0d7541e77386f21d5fc0e99ae0176beaa8aaa
3
+ metadata.gz: 53fb6c883111cef067134b5b5fe328791ae6ccd9
4
+ data.tar.gz: 0fb961476a2a02aac6ecb2d43a3dc7c08fb9d5e1
5
5
  SHA512:
6
- metadata.gz: 5eea1a16c0f746a013ebf8b2a7a8cd46178aa5e2e3151ecd43d2a7977af4472bd1f5d18eaa7c842c70ed3bc598d5af1465cc9ec2efa03ea4b5a6e6dfaa3a6b85
7
- data.tar.gz: 3b61e0c6959affae821256498031bd124f05ba6140e970f47a6a196155f43f4ca121a3c93c28ae88373fd6a62067b444bbf122cdaadb2482fdd37ca9c5a82a4d
6
+ metadata.gz: f4f0f07ebcd584a6747d1320a60ee7ce72e1fdd21e452b8a20df1d269f8c8596cbf8a0a14152723d2a27c1c40bcb92a8b7c2f657f120f9a1450d801277f5b87f
7
+ data.tar.gz: 2c843a87027189ebc42acecbcefd6c92aba0078ed66cdb2a3e71fa9a474db1ff4179e927d18f9631674be6d57755c23c2507ab5fd8f5d320b913b7d67c9d3028
@@ -735,15 +735,30 @@ class Sexp
735
735
  #
736
736
  # @return [Array] array values
737
737
  def array_values
738
- if :array == sexp_type
738
+ case sexp_type
739
+ when :array
739
740
  if nil == self[1]
740
741
  []
742
+ elsif :words_add == self[1].sexp_type
743
+ self[1].array_values
741
744
  elsif :qwords_add == self[1].sexp_type
742
745
  self[1].array_values
743
746
  else
744
747
  arguments.all
745
748
  end
746
- elsif :qwords_add
749
+ when :words_add
750
+ values = []
751
+ node = self
752
+ while true
753
+ if :words_add == node.sexp_type
754
+ values.unshift node[2]
755
+ node = node[1]
756
+ elsif :words_new == node.sexp_type
757
+ break
758
+ end
759
+ end
760
+ values
761
+ when :qwords_add
747
762
  values = []
748
763
  node = self
749
764
  while true
@@ -755,6 +770,8 @@ class Sexp
755
770
  end
756
771
  end
757
772
  values
773
+ else
774
+ []
758
775
  end
759
776
  end
760
777
 
@@ -822,11 +839,9 @@ class Sexp
822
839
  self[1].to_s
823
840
  end
824
841
  when :qwords_add
825
- if s(:qwords_new) == self[1]
826
- self[2].to_s
827
- else
828
- self[1].to_s
829
- end
842
+ self[2].to_s
843
+ when :word_add
844
+ self[2].to_s
830
845
  when :const_path_ref
831
846
  "#{self[1]}::#{self[2]}"
832
847
  when :@label
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module CodeAnalyzer
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
  end
@@ -558,8 +558,13 @@ describe Sexp do
558
558
  node.array_values.should == []
559
559
  end
560
560
 
561
- it "should get array value with qwords" do
562
- node = parse_content("%w(first_name last_name)").grep_node(sexp_type: :qwords_add)
561
+ it "should get array value with array and words_add" do
562
+ node = parse_content("%W{day week fortnight}").grep_node(sexp_type: :array)
563
+ node.array_values.map(&:to_s).should == ["day", "week", "fortnight"]
564
+ end
565
+
566
+ it "should get array value with array and qwords_add" do
567
+ node = parse_content("%w(first_name last_name)").grep_node(sexp_type: :array)
563
568
  node.array_values.map(&:to_s).should == ["first_name", "last_name"]
564
569
  end
565
570
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang