Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependencies #7

Merged
merged 7 commits into from
Dec 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/motion-phrase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require "motion/project/phrase"
require "motion-cocoapods"
require "bubble-wrap"
require "afmotion"

Motion::Project::App.setup do |app|
Dir.glob(File.join(File.dirname(__FILE__), 'motion-phrase/**/*.rb')).each do |file|
Expand All @@ -15,7 +13,7 @@
app.files.unshift("./app/phrase_config.rb")

app.pods do
pod 'AFNetworking'
pod 'AFNetworking', '>= 2.5.0'
end
end

Expand Down
27 changes: 12 additions & 15 deletions lib/motion-phrase/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ def storeTranslation(keyName, content, fallbackContent, currentLocale)
skip_verification: true,
api_client: API_CLIENT_IDENTIFIER,
}
client.post("translations/store", authenticated(data)) do |result|
if result.success?
log "Translation stored [#{data.inspect}]"
elsif result.failure?
log "Error while storing translation [#{data.inspect}]"
end
end

client.POST("translations/store", parameters:authenticated(data), success:lambda {|task, responseObject|
log "Translation stored [#{data.inspect}]"
}, failure:lambda {|task, error|
log "Error while storing translation [#{data.inspect}]"
})
end

private
def client
@client ||= buildClient
end

def buildClient
AFMotion::Client.build_shared(API_BASE_URI) do
header "Accept", "application/json"
request_serializer :json
response_serializer :json
Dispatch.once do
@client = begin
_client = AFHTTPSessionManager.alloc.initWithBaseURL(NSURL.URLWithString(API_BASE_URI))
_client
end
end
@client
end

def log(msg="")
Expand Down
23 changes: 19 additions & 4 deletions lib/motion-phrase/nsstring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ def phraseEnabled?
PHRASE_ENABLED == true && development?
end

def development?
App.development?
def currentLocaleName
currentLocale.localeIdentifier
end

def currentLocaleName
App.current_locale.localeIdentifier
# @return [NSLocale] locale of user settings
def currentLocale
languages = NSLocale.preferredLanguages
if languages.count > 0
return NSLocale.alloc.initWithLocaleIdentifier(languages.first)
else
return NSLocale.currentLocale
end
end

def environment
RUBYMOTION_ENV
end

def development?
environment == 'development'
end

end
2 changes: 1 addition & 1 deletion lib/motion-phrase/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module MotionPhrase
VERSION = "0.0.5"
VERSION = "0.0.6"
end
2 changes: 0 additions & 2 deletions motion-phrase.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_dependency 'phrase'
gem.add_dependency 'afmotion', '>= 2.0'
gem.add_dependency 'bubble-wrap'
gem.add_dependency 'motion-cocoapods'
gem.add_development_dependency 'rake'
end