Skip to content

Commit

Permalink
🌿
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Jan 24, 2025
1 parent 953815a commit 7b9d72f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Parsel
# Parsely

Parsel is a module providing a simple way to parse and extract data from a css selector.
Parsely is a module providing a simple way to parse and extract data from a css selector.

## Installation

Add this line to your application's Gemfile:
```ruby
gem 'parsel'
gem 'parsely'
```

And then execute:
Expand All @@ -16,7 +16,7 @@ bundle install

Or install it yourself as:
```bash
gem install parsel
gem install parsely
```

## Development
Expand All @@ -27,4 +27,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ydah/parsel.
Bug reports and pull requests are welcome on GitHub at https://github.com/ydah/parsely.
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "parsel"
require "parsely"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
2 changes: 1 addition & 1 deletion lib/parsel.rb → lib/parsely.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'strscan'

class Parsel
class Parsely
VERSION = "0.1.0"

def self.sanitize(selector)
Expand Down
10 changes: 5 additions & 5 deletions parsel.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

require_relative "lib/parsel"
require_relative "lib/parsely"

Gem::Specification.new do |spec|
spec.name = "parsel"
spec.version = Parsel::VERSION
spec.name = "parsely"
spec.version = Parsely::VERSION
spec.authors = ["Yudai Takada"]
spec.email = ["t.yudai92@gmail.com"]

spec.summary = "Pure Ruby CSS selector parser."
spec.description = "Parsel is a pure Ruby CSS selector parser. Provides a simple and easy-to-use API for parsing CSS selectors."
spec.homepage = 'https://github.com/ydah/parsel'
spec.description = "Parsely is a pure Ruby CSS selector parser. Provides a simple and easy-to-use API for parsing CSS selectors."
spec.homepage = 'https://github.com/ydah/parsely'
spec.license = "MIT"
spec.required_ruby_version = ">= 2.5"

Expand Down
24 changes: 12 additions & 12 deletions test/test_parsel.rb → test/test_parsely.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
# frozen_string_literal: true

require 'test/unit'
require 'parsel'
require 'parsely'

class TestParsel < Test::Unit::TestCase
class TestParsely < Test::Unit::TestCase
def test_special_case_single_dash
assert_equal '\\-', Parsel.sanitize('-')
assert_equal '\\-', Parsely.sanitize('-')
end

def test_null_character
assert_equal "\uFFFD", Parsel.sanitize("\0")
assert_equal "\uFFFD", Parsely.sanitize("\0")
end

def test_control_characters
input = "\x01\x02\x7F"
expected = "\\1 \\2 \\7f "
assert_equal expected, Parsel.sanitize(input)
assert_equal expected, Parsely.sanitize(input)
end

def test_first_character_digit
input = '1abc'
expected = "\\31 abc"
assert_equal expected, Parsel.sanitize(input)
assert_equal expected, Parsely.sanitize(input)
end

def test_second_character_digit_after_dash
input = '-1abc'
expected = "-\\31 abc"
assert_equal expected, Parsel.sanitize(input)
assert_equal expected, Parsely.sanitize(input)
end

def test_alphanumeric_and_safe_characters
input = 'a-Z_0-9'
assert_equal 'a-Z_0-9', Parsel.sanitize(input)
assert_equal 'a-Z_0-9', Parsely.sanitize(input)
end

def test_escape_special_characters
input = '!@#$%^&*()'
expected = '\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)'
assert_equal expected, Parsel.sanitize(input)
assert_equal expected, Parsely.sanitize(input)
end

def test_mixed_input
input = "-1a\x01b\0c!"
expected = "-\\31 a\\1 b�c\\!"
assert_equal expected, Parsel.sanitize(input)
assert_equal expected, Parsely.sanitize(input)
end

def test_empty_string
assert_equal '', Parsel.sanitize('')
assert_equal '', Parsely.sanitize('')
end

def test_only_safe_characters
input = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
assert_equal input, Parsel.sanitize(input)
assert_equal input, Parsely.sanitize(input)
end
end

0 comments on commit 7b9d72f

Please sign in to comment.