Loading lib/jsduck/ast.rb +5 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ module JsDuck cls[:uses] = make_requires(cfg["uses"]) cls[:alternateClassNames] = make_requires(cfg["alternateClassName"]) cls[:mixins] = make_mixins(cfg["mixins"]) cls[:singleton] = make_singleton(cfg["singleton"]) end end Loading Loading @@ -191,6 +192,10 @@ module JsDuck return classes.all? {|c| c.is_a? String } ? classes : [] end def make_singleton(cfg_value) cfg_value && to_value(cfg_value) == true end def make_method(name, ast=nil) return { :tagname => :method, Loading spec/ast_class_spec.rb +30 −0 Original line number Diff line number Diff line Loading @@ -230,4 +230,34 @@ describe "JsDuck::Ast detects class with" do EOS end end describe "singleton in" do it "Ext.define() with singleton:true" do detect(<<-EOS)[:singleton].should == true /** */ Ext.define('MyClass', { singleton: true }); EOS end end describe "no singleton in" do it "Ext.define() with singleton:false" do detect(<<-EOS)[:singleton].should_not == true /** */ Ext.define('MyClass', { singleton: false }); EOS end it "Ext.define() without singleton" do detect(<<-EOS)[:singleton].should_not == true /** */ Ext.define('MyClass', { }); EOS end end end Loading
lib/jsduck/ast.rb +5 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ module JsDuck cls[:uses] = make_requires(cfg["uses"]) cls[:alternateClassNames] = make_requires(cfg["alternateClassName"]) cls[:mixins] = make_mixins(cfg["mixins"]) cls[:singleton] = make_singleton(cfg["singleton"]) end end Loading Loading @@ -191,6 +192,10 @@ module JsDuck return classes.all? {|c| c.is_a? String } ? classes : [] end def make_singleton(cfg_value) cfg_value && to_value(cfg_value) == true end def make_method(name, ast=nil) return { :tagname => :method, Loading
spec/ast_class_spec.rb +30 −0 Original line number Diff line number Diff line Loading @@ -230,4 +230,34 @@ describe "JsDuck::Ast detects class with" do EOS end end describe "singleton in" do it "Ext.define() with singleton:true" do detect(<<-EOS)[:singleton].should == true /** */ Ext.define('MyClass', { singleton: true }); EOS end end describe "no singleton in" do it "Ext.define() with singleton:false" do detect(<<-EOS)[:singleton].should_not == true /** */ Ext.define('MyClass', { singleton: false }); EOS end it "Ext.define() without singleton" do detect(<<-EOS)[:singleton].should_not == true /** */ Ext.define('MyClass', { }); EOS end end end