Permalink
Browse files

Updating analytics ruby to properly namespace files

  • Loading branch information...
1 parent 452ff78 commit c199b499f6ad9def6b92737dcf2e84adfbb0fda8 @calvinfo calvinfo committed Jan 21, 2013
View
@@ -1,10 +1,14 @@
+0.0.5 / 2013-1-21
+===========
+* Renaming of all the files for proper bundling usage
+
0.0.4 / 2013-1-17
-==========
+===========
* Updated readme and install instruction courtesy of [@zeke](https://github.com/zeke)
* Removed typhoeus and reverted to default adapter
* Removing session_id in favor of a single user_id
0.0.3 / 2013-1-16
-==========
+===========
* Rakefile and renaming courtesy of [@kiennt](https://github.com/kiennt)
* Updated tests with mocks
@@ -1,11 +1,11 @@
$:.push File.expand_path('../lib', __FILE__)
-require 'analytics/version'
+require 'analytics-ruby/version'
Gem::Specification.new do |spec|
spec.name = 'analytics-ruby'
- spec.version = Analytics::VERSION
+ spec.version = AnalyticsRuby::VERSION
spec.files = Dir.glob('**/*')
spec.require_paths = ['lib']
spec.summary = 'Segment.io analytics library'
@@ -1,16 +1,19 @@
require 'forwardable'
-require 'analytics/version'
-require 'analytics/client'
+require 'analytics-ruby/version'
+require 'analytics-ruby/client'
-module Analytics
+module AnalyticsRuby
extend SingleForwardable
def_delegators :@client, :track, :identify
# By default use a single client for the module
def self.init(options = {})
- @client = Analytics::Client.new(options)
+ @client = AnalyticsRuby::Client.new(options)
end
end
+
+# Alias for AnalyticsRuby
+Analytics = AnalyticsRuby
@@ -1,11 +1,11 @@
require 'time'
require 'thread'
-require 'analytics/defaults'
-require 'analytics/consumer'
-require 'analytics/request'
+require 'analytics-ruby/defaults'
+require 'analytics-ruby/consumer'
+require 'analytics-ruby/request'
-module Analytics
+module AnalyticsRuby
class Client
@@ -19,11 +19,11 @@ def initialize (options = {})
@queue = Queue.new
@secret = options[:secret]
- @max_queue_size = options[:max_queue_size] || Analytics::Defaults::Queue::MAX_SIZE
+ @max_queue_size = options[:max_queue_size] || AnalyticsRuby::Defaults::Queue::MAX_SIZE
check_secret
- @consumer = Analytics::Consumer.new(@queue, @secret, options)
+ @consumer = AnalyticsRuby::Consumer.new(@queue, @secret, options)
Thread.new { @consumer.run }
end
@@ -1,8 +1,8 @@
-require 'analytics/defaults'
-require 'analytics/request'
+require 'analytics-ruby/defaults'
+require 'analytics-ruby/request'
-module Analytics
+module AnalyticsRuby
class Consumer
@@ -20,7 +20,7 @@ class Consumer
def initialize(queue, secret, options = {})
@queue = queue
@secret = secret
- @batch_size = options[:batch_size] || Analytics::Defaults::Queue::BATCH_SIZE
+ @batch_size = options[:batch_size] || AnalyticsRuby::Defaults::Queue::BATCH_SIZE
@on_error = options[:on_error] || Proc.new { |status, error| }
@current_batch = []
@@ -45,7 +45,7 @@ def flush
@current_batch << @queue.pop()
end
- req = Analytics::Request.new
+ req = AnalyticsRuby::Request.new
res = req.post(@secret, @current_batch)
@on_error.call(res.status, res.error) unless res.status == 200
@current_batch = []
@@ -0,0 +1,18 @@
+
+module AnalyticsRuby
+ module Defaults
+
+ module Request
+ BASE_URL = 'https://api.segment.io' unless defined? AnalyticsRuby::Defaults::Request::BASE_URL
+ PATH = '/v1/import' unless defined? AnalyticsRuby::Defaults::Request::PATH
+ SSL = { verify: false } unless defined? AnalyticsRuby::Defaults::Request::SSL
+ HEADERS = { accept: 'application/json' } unless defined? AnalyticsRuby::Defaults::Request::HEADERS
+ end
+
+ module Queue
+ BATCH_SIZE = 100 unless defined? AnalyticsRuby::Defaults::Queue::BATCH_SIZE
+ MAX_SIZE = 10000 unless defined? AnalyticsRuby::Defaults::Queue::MAX_SIZE
+ end
+
+ end
+end
@@ -1,22 +1,22 @@
-require 'analytics/defaults'
-require 'analytics/response'
+require 'analytics-ruby/defaults'
+require 'analytics-ruby/response'
require 'multi_json'
require 'faraday'
require 'faraday_middleware'
-module Analytics
+module AnalyticsRuby
class Request
# public: Creates a new request object to send analytics batch
#
def initialize(options = {})
- options[:url] ||= Analytics::Defaults::Request::BASE_URL
- options[:ssl] ||= Analytics::Defaults::Request::SSL
- options[:headers] ||= Analytics::Defaults::Request::HEADERS
- @path = options[:path] || Analytics::Defaults::Request::PATH
+ options[:url] ||= AnalyticsRuby::Defaults::Request::BASE_URL
+ options[:ssl] ||= AnalyticsRuby::Defaults::Request::SSL
+ options[:headers] ||= AnalyticsRuby::Defaults::Request::HEADERS
+ @path = options[:path] || AnalyticsRuby::Defaults::Request::PATH
@conn = Faraday.new(options) do |faraday|
faraday.request :json
@@ -45,7 +45,7 @@ def post(secret, batch)
error = "Connection error: #{err}"
end
- Analytics::Response.new(status, error)
+ AnalyticsRuby::Response.new(status, error)
end
end
end
@@ -1,5 +1,5 @@
-module Analytics
+module AnalyticsRuby
class Response
@@ -0,0 +1,3 @@
+module AnalyticsRuby
+ VERSION = '0.0.5'
+end
@@ -1,18 +0,0 @@
-
-module Analytics
- module Defaults
-
- module Request
- BASE_URL = 'https://api.segment.io' unless defined? Analytics::Defaults::Request::BASE_URL
- PATH = '/v1/import' unless defined? Analytics::Defaults::Request::PATH
- SSL = { verify: false } unless defined? Analytics::Defaults::Request::SSL
- HEADERS = { accept: 'application/json' } unless defined? Analytics::Defaults::Request::HEADERS
- end
-
- module Queue
- BATCH_SIZE = 100 unless defined? Analytics::Defaults::Queue::BATCH_SIZE
- MAX_SIZE = 10000 unless defined? Analytics::Defaults::Queue::MAX_SIZE
- end
-
- end
-end
@@ -1,3 +0,0 @@
-module Analytics
- VERSION = '0.0.4'
-end
View
@@ -1,4 +1,4 @@
-require 'analytics'
+require 'analytics-ruby'
require 'spec_helper'
@@ -1,4 +1,4 @@
-require 'analytics'
+require 'analytics-ruby'
require 'thread'
require 'spec_helper'
View
@@ -1,4 +1,4 @@
-require 'analytics'
+require 'analytics-ruby'
require 'spec_helper'
describe Analytics do

0 comments on commit c199b49

Please sign in to comment.