view · edit · sidebar · attach · print · history

20110808-url-format-migel-search-oddb_org

<< | Index | >>


  1. Fix git merge error
  2. Develop migel search function

Goal/Estimate/Evaluation
  • Change URL format oddb.org / 100% / 100%
  • Migel search function / 70% / 50%
Milestones
Summary
Commits
ToDo Tomorrow
  • Get a migel search result
  • Put the data into a view (state) class

Fix git merge error

Git pull error

$ git pull
remote: Counting objects: 46, done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 26 (delta 20), reused 0 (delta 0)
Unpacking objects: 100% (26/26), done.
From /home/ywesee/git/oddb.org
  81ca738..d8a4e48  master     -> origin
Updating 81ca738..d8a4e48
error: Your local changes to the following files would be overwritten by merge:
       src/util/persistence.rb
Please, commit your changes or stash them before you can merge.
Aborting

Note

  • This error comes because the src/util/persistence.rb is modified directly, not via git.
  • The difference between the source and git repository:
 class Hash
  alias :key :index
 end

Note

  • Hash#index is already defined
  • Hash#key was newly defined in Ruby 1.8.8 (also Ruby 1.9)
  • But, instead of that, Hash#index became obsolete since Ruby 1.9

Example

masa@masa ~/work $ cat test.rb

h = {'a' => 1, 'b' => 2}

p h.index(1)
p h.key(1)

masa@masa ~/work $ ruby186 test.rb
"a"
test.rb:6: undefined method `key' for {"a"=>1, "b"=>2}:Hash (NoMethodError)
masa@masa ~/work $ ruby187 test.rb
"a"
test.rb:6: undefined method `key' for {"a"=>1, "b"=>2}:Hash (NoMethodError)
masa@masa ~/work $ ruby192 test.rb
test.rb:5: warning: Hash#index is deprecated; use Hash#key
"a"
"a"

Namely

  • We should Hash#index in Ruby 1.8, Hash#key in Ruby 1.9

Experiment

class Hash
  alias :key :index
end

h = {'a' => 1, 'b' => 2}

p h.index(1)
p h.key(1)

Result

masa@masa ~/work $ ruby186 test.rb
"a"
"a"
masa@masa ~/work $ ruby187 test.rb
"a"
"a"
masa@masa ~/work $ ruby192 test.rb
test.rb:8: warning: Hash#index is deprecated; use Hash#key
"a"
test.rb:9: warning: Hash#index is deprecated; use Hash#key
"a"

Commit

Note

Bug

  • I have found a bug again
  • 'logged-in' and 'Markenname' (Brand name) search failed with the error
NoMethodError
undefined method `to_csv' for nil:NilClass

Commit

Develop migel search function

Refer to: http://dev.ywesee.com/wiki.php/Masa/20110804-testcases-url-format-oddbOrg#Migel

ToDo

  1. Search the code related to the showing of migel number
  2. How to make a link -> probably I have to create state and view class for the search result
  3. How to search the data related to the migel number

Search the code related to the showing of migel number

URL (example)

Note

  • The event: migel_alphabetical
  • The user_input: key='range', value='e'
  • There is no 'migel_alphabetical' method in src/state/global.rb

Experiment

  • src/view/migel/result.rb

Run

  • bin/oddbd
  • bin/currencyd
  • bin/yusd

Access

class List < HtmlGrid::List
  def migel_code(model)
    link = PointerLink.new(:to_s, model, @session, self)
    link.value = model.migel_code
    link.href = "http://oddb.masa.org"
    link
  end
end
  class ResultList < View::Migel::List
    def compose_subheader(item, offset, css='list atc')
      xval, yval = offset
      #values = [limitation_text(item), nil, item.migel_code, nil, product_description(item)]
      values = [limitation_text(item), nil, migel_code(item), nil, product_description(item)]
      @grid.add(values, xval, yval)
      @grid.add_style(css, xval, yval, 3)
      @grid.set_colspan(xval + 2, yval, @width - xval - 1)
    end
end

Result

Note

  • Link is created

Next

  • Create state and view classes for a migel search result

Note

  • Inheritance structure: ODDB::View::PointerLink <- PointerValue <- HtmlGrid::Value <- NamedComponent <- Component

First design of search result

  • The simplest list view
  • Just only the migel numbers without link

Experiment

  • src/state/global.rb
  • src/util/validator.rb
  • src/state/migel/test.rb
  • src/view/migel/test.rb
  • src/state/global.rb
      def test
        ODDB::State::Migel::Test.new(@session, nil)
      end
  • src/util/validator.rb
    EVENTS = [
...
      :test
    ]
  • src/state/migel/test.rb
#!/usr/bin/env ruby
#  ODDB::State::Migel:Test -- oddb.org -- 08.08.2011 -- mhatakeyama@ywesee.com

require 'state/global_predefine'
require 'view/migel/test'

module ODDB
  module State
    module Migel
class Test < State::Migel::Global
  VIEW = View::Migel::Test
end
    end
  end
end
  • src/view/migel/test.rb
#!/usr/bin/env ruby
# ODDB::View::Migel::Test -- oddb.org -- 08.08.2011 -- mhatakeyama@ywesee.com

module ODDB
  module View
    module Migel
class ResultComposite < HtmlGrid::Composite
  COMPONENTS = {
  }
end
class Test < View::PrivateTemplate
  CONTENT = ResultComposite
end
    end
  end
end

Access

Result

Next

  • Add some list data in the view

Experiment

  • src/state/migel/test.rb
#!/usr/bin/env ruby
#  ODDB::State::Migel:Test -- oddb.org -- 08.08.2011 -- mhatakeyama@ywesee.com

require 'state/global_predefine'
require 'view/migel/test'

module ODDB
  module State
    module Migel
class Test < State::Migel::Global
  VIEW = View::Migel::Test
  def init
    @model = [1,2,3,4]
  end
end
    end
  end
end
  • src/view/migel/test.rb
#!/usr/bin/env ruby
# ODDB::View::Migel::Test -- oddb.org -- 08.08.2011 -- mhatakeyama@ywesee.com

require 'htmlgrid/list'

module ODDB
  module View
    module Migel

class List < HtmlGrid::List
  def init
    @components = {
      [0,0]   =>  'masa',
      [1,0]   =>  'hata',
    }
    super
  end
end
class ResultComposite < HtmlGrid::Composite
  COMPONENTS = {
    [0,0] => List
  }
end
class Test < View::PrivateTemplate
  CONTENT = ResultComposite
end
    end
  end
end

Access

Result

Next

  • How to insert the search data into the state instance
view · edit · sidebar · attach · print · history
Page last modified on August 08, 2011, at 04:57 PM