This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
forked from twitter/twitter-text
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[twitter#211] Update top-level namespace to Twitter::TwitterText::
The popular Twitter gem (https://github.com/sferik/twitter) uses the Twitter::Configuration namespace and users are reporting that our new Twitter::Configuration class is conflicting with that namespace. This patch changes our top-level namespace from Twitter to Twitter::TwitterText:: to resolve this conflict and prevent further conflicts in the future. Because this is a breaking change for clients written against older versions of the library, the version has been bumped to 2.1. There's also a new CHANGELOG.md file that details important changes in this revision and will be updated going forward.
- Loading branch information
David LaMacchia
authored and
FelixRubio
committed
Feb 12, 2018
1 parent
7c9850f
commit e304fc6
Showing
24 changed files
with
1,498 additions
and
1,454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
## [Unreleased] | ||
|
||
## [2.1] - 2017-12-20 | ||
### Added | ||
- This CHANGELOG.md file | ||
|
||
### Changed | ||
- Top-level namespace changed from `Twitter` to `Twitter::TwitterText`. This | ||
resolves a namespace collision with the popular | ||
[twitter gem](https://github.com/sferik/twitter). This is considered | ||
a breaking change, so the version has been bumped to 2.1. This fixes | ||
issue [#221](https://github.com/twitter/twitter-text/issues/221), | ||
"NoMethodError Exception: undefined method `[]' for nil:NilClasswhen | ||
using gem in rails app" | ||
|
||
## [2.0.2] - 2017-12-18 | ||
### Changed | ||
- Resolved issue | ||
[#211](https://github.com/twitter/twitter-text/issues/211), "gem | ||
breaks, asset file is a dangling symlink" | ||
- config files, tld_lib.yml files now copied into the right place | ||
- Rakefile now included `prebuild`, `clean` tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,54 @@ | ||
# encoding: UTF-8 | ||
|
||
module Twitter | ||
class Configuration | ||
require 'json' | ||
|
||
PARSER_VERSION_CLASSIC = "v1" | ||
PARSER_VERSION_DEFAULT = "v2" | ||
|
||
class << self | ||
attr_accessor :default_configuration | ||
end | ||
|
||
attr_reader :version, :max_weighted_tweet_length, :scale | ||
attr_reader :default_weight, :transformed_url_length, :ranges | ||
|
||
CONFIG_V1 = File.join( | ||
File.expand_path('../../../config', __FILE__), # project root | ||
"#{PARSER_VERSION_CLASSIC}.json" | ||
) | ||
|
||
CONFIG_V2 = File.join( | ||
File.expand_path('../../../config', __FILE__), # project root | ||
"#{PARSER_VERSION_DEFAULT}.json" | ||
) | ||
|
||
def self.parse_string(string, options = {}) | ||
JSON.parse(string, options.merge(symbolize_names: true)) | ||
module TwitterText | ||
class Configuration | ||
require 'json' | ||
|
||
PARSER_VERSION_CLASSIC = "v1" | ||
PARSER_VERSION_DEFAULT = "v2" | ||
|
||
class << self | ||
attr_accessor :default_configuration | ||
end | ||
|
||
attr_reader :version, :max_weighted_tweet_length, :scale | ||
attr_reader :default_weight, :transformed_url_length, :ranges | ||
|
||
CONFIG_V1 = File.join( | ||
File.expand_path('../../../config', __FILE__), # project root | ||
"#{PARSER_VERSION_CLASSIC}.json" | ||
) | ||
|
||
CONFIG_V2 = File.join( | ||
File.expand_path('../../../config', __FILE__), # project root | ||
"#{PARSER_VERSION_DEFAULT}.json" | ||
) | ||
|
||
def self.parse_string(string, options = {}) | ||
JSON.parse(string, options.merge(symbolize_names: true)) | ||
end | ||
|
||
def self.parse_file(filename) | ||
string = File.open(filename, 'rb') { |f| f.read } | ||
parse_string(string) | ||
end | ||
|
||
def self.configuration_from_file(filename) | ||
config = parse_file(filename) | ||
config ? self.new(config) : nil | ||
end | ||
|
||
def initialize(config = {}) | ||
@version = config[:version] | ||
@max_weighted_tweet_length = config[:maxWeightedTweetLength] | ||
@scale = config[:scale] | ||
@default_weight = config[:defaultWeight] | ||
@transformed_url_length = config[:transformedURLLength] | ||
@ranges = config[:ranges].map { |range| Twitter::TwitterText::WeightedRange.new(range) } if config.key?(:ranges) && config[:ranges].is_a?(Array) | ||
end | ||
|
||
self.default_configuration = self.configuration_from_file(CONFIG_V2) | ||
end | ||
|
||
def self.parse_file(filename) | ||
string = File.open(filename, 'rb') { |f| f.read } | ||
parse_string(string) | ||
end | ||
|
||
def self.configuration_from_file(filename) | ||
config = parse_file(filename) | ||
config ? Twitter::Configuration.new(config) : nil | ||
end | ||
|
||
def initialize(config = {}) | ||
@version = config[:version] | ||
@max_weighted_tweet_length = config[:maxWeightedTweetLength] | ||
@scale = config[:scale] | ||
@default_weight = config[:defaultWeight] | ||
@transformed_url_length = config[:transformedURLLength] | ||
@ranges = config[:ranges].map { |range| Twitter::WeightedRange.new(range) } if config.key?(:ranges) && config[:ranges].is_a?(Array) | ||
end | ||
|
||
self.default_configuration = Twitter::Configuration.configuration_from_file(Twitter::Configuration::CONFIG_V2) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.