Browse Source

Merge pull request #124 from Shopify/fix_cli

Locking Thor to 0.18.1 to fix the CLI
Kevin Hughes 11 years ago
parent
commit
91fd968947
6 changed files with 58 additions and 49 deletions
  1. 4 0
      CHANGELOG
  2. 5 3
      Gemfile.lock
  3. 20 19
      lib/shopify_api/cli.rb
  4. 1 1
      lib/shopify_api/version.rb
  5. 4 2
      shopify_api.gemspec
  6. 24 24
      test/cli_test.rb

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+== Version 3.2.2
+
+* Temporary fix for the CLI
+
 == Version 3.2.1
 
 * Added CarrierService resource

+ 5 - 3
Gemfile.lock

@@ -1,9 +1,9 @@
 PATH
   remote: .
   specs:
-    shopify_api (3.2.1)
-      activeresource (~> 4.0.0)
-      thor (>= 0.14.4)
+    shopify_api (3.2.2)
+      activeresource (>= 3.0.0)
+      thor (~> 0.18.1)
 
 GEM
   remote: https://rubygems.org/
@@ -42,7 +42,9 @@ PLATFORMS
   ruby
 
 DEPENDENCIES
+  activeresource (~> 4.0.0)
   fakeweb
+  minitest (~> 4.0)
   mocha (>= 0.9.8)
   rake
   shopify_api!

+ 20 - 19
lib/shopify_api/cli.rb

@@ -1,10 +1,11 @@
 require 'thor'
 require 'abbrev'
+require 'yaml'
 
 module ShopifyAPI
   class Cli < Thor
     include Thor::Actions
-    
+
     class ConfigFileError < StandardError
     end
 
@@ -15,7 +16,7 @@ module ShopifyAPI
         puts prefix + c
       end
     end
-    
+
     desc "add CONNECTION", "create a config file for a connection named CONNECTION"
     def add(connection)
       file = config_file(connection)
@@ -35,7 +36,7 @@ module ShopifyAPI
         default(connection)
       end
     end
-    
+
     desc "remove CONNECTION", "remove the config file for CONNECTION"
     def remove(connection)
       file = config_file(connection)
@@ -46,7 +47,7 @@ module ShopifyAPI
         no_config_file_error(file)
       end
     end
-    
+
     desc "edit [CONNECTION]", "open the config file for CONNECTION with your default editor"
     def edit(connection=nil)
       file = config_file(connection)
@@ -60,7 +61,7 @@ module ShopifyAPI
         no_config_file_error(file)
       end
     end
-    
+
     desc "show [CONNECTION]", "output the location and contents of the CONNECTION's config file"
     def show(connection=nil)
       connection ||= default_connection
@@ -72,7 +73,7 @@ module ShopifyAPI
         no_config_file_error(file)
       end
     end
-    
+
     desc "default [CONNECTION]", "show the default connection, or make CONNECTION the default"
     def default(connection=nil)
       if connection
@@ -90,15 +91,15 @@ module ShopifyAPI
         puts "There is no default connection set"
       end
     end
-    
+
     desc "console [CONNECTION]", "start an API console for CONNECTION"
     def console(connection=nil)
       file = config_file(connection)
-      
+
       config = YAML.load(File.read(file))
       puts "using #{config['domain']}"
       ShopifyAPI::Base.site = site_from_config(config)
-      
+
       require 'irb'
       require 'irb/completion'
       ARGV.clear
@@ -110,15 +111,15 @@ module ShopifyAPI
     end
 
     private
-    
+
     def shop_config_dir
       @shop_config_dir ||= File.join(ENV['HOME'], '.shopify', 'shops')
     end
-    
+
     def default_symlink
       @default_symlink ||= File.join(shop_config_dir, 'default')
     end
-    
+
     def config_file(connection)
       if connection
         File.join(shop_config_dir, "#{connection}.yml")
@@ -126,35 +127,35 @@ module ShopifyAPI
         default_symlink
       end
     end
-    
+
     def site_from_config(config)
       protocol = config['protocol'] || 'https'
       api_key  = config['api_key']
       password = config['password']
       domain   = config['domain']
-    
+
       ShopifyAPI::Base.site = "#{protocol}://#{api_key}:#{password}@#{domain}/admin"
     end
-    
+
     def available_connections
       @available_connections ||= begin
         pattern = File.join(shop_config_dir, "*.yml")
         Dir.glob(pattern).map { |f| File.basename(f, ".yml") }
       end
     end
-    
+
     def default_connection_target
       @default_connection_target ||= File.readlink(default_symlink)
     end
-    
+
     def default_connection
       @default_connection ||= File.basename(default_connection_target, ".yml")
     end
-    
+
     def default?(connection)
       default_connection == connection
     end
-    
+
     def no_config_file_error(filename)
       raise ConfigFileError, "There is no config file at #{filename}"
     end

+ 1 - 1
lib/shopify_api/version.rb

@@ -1,3 +1,3 @@
 module ShopifyAPI
-  VERSION = "3.2.1"
+  VERSION = "3.2.2"
 end

+ 4 - 2
shopify_api.gemspec

@@ -25,15 +25,17 @@ Gem::Specification.new do |s|
   s.license = 'MIT'
 
   s.add_dependency("activeresource", [">= 3.0.0"])
-  s.add_dependency("thor", [">= 0.14.4"])
-  
+  s.add_dependency("thor", ["~> 0.18.1"])
+
   if s.respond_to?(:add_development_dependency)
     s.add_development_dependency("mocha", ">= 0.9.8")
     s.add_development_dependency("fakeweb")
+    s.add_development_dependency("minitest", "~> 4.0")
     s.add_development_dependency("rake")
   else
     s.add_dependency("mocha", ">= 0.9.8")
     s.add_dependency("fakeweb")
+    s.add_dependency("minitest", "~> 4.0")
     s.add_dependency("rake")
   end
 end

+ 24 - 24
test/cli_test.rb

@@ -10,7 +10,7 @@ class CliTest < Test::Unit::TestCase
     `rm -rf #{@test_home}`
     ENV['HOME'] = @test_home
     @cli = ShopifyAPI::Cli.new
-    
+
     FileUtils.mkdir_p(@shop_config_dir)
     File.open(config_file('foo'), 'w') do |file|
       file.puts valid_options.merge('domain' => 'foo.myshopify.com').to_yaml
@@ -20,11 +20,11 @@ class CliTest < Test::Unit::TestCase
       file.puts valid_options.merge('domain' => 'bar.myshopify.com').to_yaml
     end
   end
-  
+
   def teardown
     `rm -rf #{@test_home}`
   end
-  
+
   test "add with blank domain" do
     `rm -rf #{@shop_config_dir}/*`
     $stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
@@ -33,9 +33,9 @@ class CliTest < Test::Unit::TestCase
     $stdin.expects(:gets).times(3).returns("", "key", "pass")
     @cli.expects(:puts).with("\nopen https://foo.myshopify.com/admin/api in your browser to get API credentials\n")
     @cli.expects(:puts).with("Default connection is foo")
-    
+
     @cli.add('foo')
-    
+
     config = YAML.load(File.read(config_file('foo')))
     assert_equal 'foo.myshopify.com', config['domain']
     assert_equal 'key', config['api_key']
@@ -43,7 +43,7 @@ class CliTest < Test::Unit::TestCase
     assert_equal 'https', config['protocol']
     assert_equal config_file('foo'), File.readlink(@default_symlink)
   end
-  
+
   test "add with explicit domain" do
     `rm -rf #{@shop_config_dir}/*`
     $stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
@@ -52,58 +52,58 @@ class CliTest < Test::Unit::TestCase
     $stdin.expects(:gets).times(3).returns("bar.myshopify.com", "key", "pass")
     @cli.expects(:puts).with("\nopen https://bar.myshopify.com/admin/api in your browser to get API credentials\n")
     @cli.expects(:puts).with("Default connection is foo")
-    
+
     @cli.add('foo')
-    
+
     config = YAML.load(File.read(config_file('foo')))
     assert_equal 'bar.myshopify.com', config['domain']
   end
-  
+
   test "list" do
     @cli.expects(:puts).with("   bar")
     @cli.expects(:puts).with(" * foo")
-    
+
     @cli.list
   end
-  
+
   test "show default" do
     @cli.expects(:puts).with("Default connection is foo")
-    
+
     @cli.default
   end
-  
+
   test "set default" do
     @cli.expects(:puts).with("Default connection is bar")
-    
+
     @cli.default('bar')
-    
+
     assert_equal config_file('bar'), File.readlink(@default_symlink)
   end
-  
+
   test "remove default connection" do
     @cli.remove('foo')
-    
+
     assert !File.exist?(@default_symlink)
     assert !File.exist?(config_file('foo'))
     assert File.exist?(config_file('bar'))
   end
-  
+
   test "remove non-default connection" do
     @cli.remove('bar')
-    
+
     assert_equal config_file('foo'), File.readlink(@default_symlink)
     assert File.exist?(config_file('foo'))
     assert !File.exist?(config_file('bar'))
   end
-  
+
   private
-  
+
   def valid_options
     {'domain' => 'snowdevil.myshopify.com', 'api_key' => 'key', 'password' => 'pass', 'protocol' => 'https'}
   end
-  
+
   def config_file(connection)
     File.join(@shop_config_dir, "#{connection}.yml")
   end
-  
-end
+
+end